none
Serial communication error... RRS feed

  • Question

  • Now it should be said that I am not an expert in C #, but I see no connection between this error message and the serial communication.

    sendBackTheta = "a180".

    myPort is defined a bit further up the code. With the rest of the logic, the serial port seems quite ok, but here it is something that doesn't match here. I have to send "a180" to arduino twice. The first time it goes fine, but the second time I get this error message every time. What can be wrong? ...Thanks for the help.


    • Edited by okrus Thursday, May 2, 2019 1:37 PM
    Thursday, May 2, 2019 1:35 PM

All replies

  • Given the odd error I'm going to say you have a cross threading issue going on. Is this a Winforms app? Is this code being called on a non-UI thread (aka via an event handler)? If so then you are referencing your UI which is a cross threading issue. In release mode this will cause bizarre errors like you're seeing. In debug mode the MDA should kick in and tell you.

    Another possibility is that the Write triggers some other code to be called which is triggering the error. Click the View Details link in the exception and it will show you the stack trace. This should narrow down the issue pretty quickly.

    Lastly, if this is a Winforms app then why do you have a Console call in there? Nobody will ever see it.


    Michael Taylor http://www.michaeltaylorp3.net

    Thursday, May 2, 2019 1:55 PM
    Moderator
  • Hi

    Thank you for posting here.

    Could you provide a complete code about your problem with me via OneDrive?

    We will solve your question in time if you provide the above information.

    Best Regards,

    Jack


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Friday, May 3, 2019 5:27 AM
    Moderator