I'm trying to read code from COM 1 which is being sent from another computer (which is running Matlab). I'm using a VISA serial port reader and checking the port every 20ms and it should be receiving just 1s and 2s but occasionally it claims that it is receiving strange numbers like 65 or even -123 and other apparently random numbers. What could be causing this? (I'm almost positive the port is only receiving 1s and 2s.)
So the numbers I have been seeing obey the following binary pattern:
Somehow 1s seem to be inserted where 0s should be in addition to the original signal for 1 and 2.
What could be the cause of this and what are the potential sollutions?
Thanks in advance for any help. This is extremely frustrating!
Double check that you've got the same baud rate, partity, and start and stop bits on both ends... Feels like you're seeing a stop bit or something.
I have found a few documents that may give you some more background regarding serial communication. I think Rob Purser has pointed out good items to check, such as the baud rate, parity bits, and start and stop bits. To give you more information, National Instruments has great documents that offer insight when using serial communication. I have linked one below and it specifically talks about common problems.
Are you implementing any form handshaking? I have found another Developer Zone that touches on this.
Like Rob discussed in his post, your settings could be the primary reason for your difficulties. If you are curious about the default setting for the serial port, I have another documet that indicates this information.