I had been trying to find out why I was losing characters when reading an RS232 serial port:
I had this line at the beginning of the DataAvailable event handler for the serial port (note: B1 is global):
'DataAvailable event handler 1
B1=B1+Serial1.ReadAll //Add new data in the serial buffer to pre-received data
'... process B1
This results in characters being lost. (It varies, but typically a string of 10 characters lost in every 1500 characters received)
After much hair pulling and trying different things, I changed it to this, and characters are no longer lost
'DataAvailable event handler 2
SR1 = Serial1.ReadAll
B1=B1+SR1 //Add new data in the serial buffer to pre-received data
'...process B1
Programatically they should be the same, but characters are sometimes lost in the assignment of version 1.
Any comments please about why this happens…?