Is it to possible to wait for a serialPort component to complete it's response?
I have a device connected to the serial port of my PC. I use the serialPort component in order to communicate with the device. I have to send 2 different strings of data to the serial port but the trick is that after sending the first string of data I have
to wait for the serial port to respond. Then I have to check the response and decide whether I must send the second string or not. Also after sending the second string, I have to check also the response of the serial port.
I tried to use an arbitrary amount of wait time between the sending of the two strings. Something like
SerialPort.Write(...) ; Thread.Sleep(2000); SerialPort.Write(...);
But the software failed when I tried it in a slower PC. So is there a way to replace the Thread.Sleep(2000) with a command that will wait until the serial port complete its response?
Although, the response of the serial port is different between the two sending strings, I do know that the first response is only one byte and I know the ending byte of the second response. Also, the second response is no more than 30 bytes in length.
View Complete Post