Serial Communication Problem

Hello, I have an interface written in c#. The full c# code and arduino code may be found in the attached archive.

The program is simple: it sends via serial conection a message to arduino that tells it how to command a stepper motor. The message format is something like this: <0,60,200>, where 0 stands for direction (cw - 0 or ccw - 1), 60 for the speed and 200 for the number of steps. I have included a “check for arduino port” message that is <0,0,0>. When you press “conexiune” (conection) button and then scan (scanare) for ports, the application will send this message and receives (if any Arduino) the message “arduino found”.

I have included a led check also. From serial monitor works fine.

The problem is with the interface: after sending the check message <0,0,0> from it and then a normal message like <1,20,300> the application (scan for port, led blink and also the command) wouldnt work anymore. It’s like the application is getting stuck when receiving the confirmation “arduino found” message. Can you guys pritty please help me? Thank you in advanced.

PeterH: nope.

Desktop.rar (116 KB)

I haven’t looked at the whole of the C# application, but it looks to me as if you’re opening and closing the serial port for each message. That isn’t good - it would cause the Arduino to reset each time you open the port.