I am trying to read strings from the serial buffer. As I don’t have the actual data outputting hardware (a PBX) I am now testing with a terminal application, pasting the strings there… I hope that is not what’s causing my troubles…
So the first thing I notice is that the received string is always cut down. Why does it not get all the bytes ? it is a string of 664 bytes (if I am not mistaken)
The second thing I notice is that the string is always cut down in different places ! I am always pasting the same string in HyperTerminal, exactly the same string, and the “available bytes” property in my serial control comes out always different… how come ?
It would really help if you would post your code you are using to read the serial buffer, etc. Without knowing this it could be anything. IF you are reading this in the DataAvailable event you should know that event fires when there is data available. If you read all on that event you may be only reading a portion of what is available as it streams in. There are ways around this but we have no idea how your code is handling this.
Post some code, lots of people here will review it and help.
The DataAvailable event doesn’t mean ALL of it’s there. There are a bunch of things to do to ensure you actually have it all, or you might have a partial message, or that you might have 2 messages. Like Joseph said, you should post your code from the DataAvailable event as a start so we can help you.
Problem is I don’t know what are the termination characters I should look for… SO I thought “get all the data in this burst, and once it has stopped recieving, parse it”. The PBX should not stop sending data before it is done, and if it does, that will be an exception…
I know it’s not the best approach but not knowing the terminaton chars… I didn’t know any other way around it…
which, is simply EndOfLine.Windows. Take a look at the end of your serial message, I bet there will be a termination of some sort even if you can’t see it. Look at the entire string in binary, not as text, and I bet you’ll see a terminator.