Help With Serial
-
Hello, I'm trying to stream data from a microcontroller and I think I have found problem. The data does not stream consistently so it will sometimes send a bunch of packets(5 byte packet) at once and then sometimes send them individual. When the speed at which they come in changes the data seems to become corrupted as only a couple of packets are wrong and then the data continues streaming properly again. I have no idea of what is going wrong here. I'm using the CSerial library and using the CSerialMFC for the notifications, and just a simply read on event received. Any idea of what could be going wrong here would be great. Thanks Simon
-
Hello, I'm trying to stream data from a microcontroller and I think I have found problem. The data does not stream consistently so it will sometimes send a bunch of packets(5 byte packet) at once and then sometimes send them individual. When the speed at which they come in changes the data seems to become corrupted as only a couple of packets are wrong and then the data continues streaming properly again. I have no idea of what is going wrong here. I'm using the CSerial library and using the CSerialMFC for the notifications, and just a simply read on event received. Any idea of what could be going wrong here would be great. Thanks Simon
-
Hello, I'm trying to stream data from a microcontroller and I think I have found problem. The data does not stream consistently so it will sometimes send a bunch of packets(5 byte packet) at once and then sometimes send them individual. When the speed at which they come in changes the data seems to become corrupted as only a couple of packets are wrong and then the data continues streaming properly again. I have no idea of what is going wrong here. I'm using the CSerial library and using the CSerialMFC for the notifications, and just a simply read on event received. Any idea of what could be going wrong here would be great. Thanks Simon
Well yes and no. Serial anything, especially low level serial port, can be problematic, but data corruption is highly unusual. I can only tell you what I would do. I would write a small test program (or use the current program - easier) that creates/opens a file during start up and then add code that writes to it every time you receive any data at the lowest level. If there is corruption at that level then you have a major problem, which only the current programmer (you) can solve, usually by writing your own version of that unknown piece of code. If there is no corruption at that level (normal), then you need to start working you way up, adding new code to write to the file, until you see corruption. At that point you can limit the file writing code to what shows good data and bad data. Keep adding file writing code until you have the offending code in sight and then add file writing code to each line of the offending function (if you do not see the problem). I suspect that you know all that already, but it is the best I can do without the code. P.S. Remember to delete the temporary file after you have found the problem and post the results (to the author of CSerial or what ever).
INTP "Program testing can be used to show the presence of bugs, but never to show their absence."Edsger Dijkstra
-
Well yes and no. Serial anything, especially low level serial port, can be problematic, but data corruption is highly unusual. I can only tell you what I would do. I would write a small test program (or use the current program - easier) that creates/opens a file during start up and then add code that writes to it every time you receive any data at the lowest level. If there is corruption at that level then you have a major problem, which only the current programmer (you) can solve, usually by writing your own version of that unknown piece of code. If there is no corruption at that level (normal), then you need to start working you way up, adding new code to write to the file, until you see corruption. At that point you can limit the file writing code to what shows good data and bad data. Keep adding file writing code until you have the offending code in sight and then add file writing code to each line of the offending function (if you do not see the problem). I suspect that you know all that already, but it is the best I can do without the code. P.S. Remember to delete the temporary file after you have found the problem and post the results (to the author of CSerial or what ever).
INTP "Program testing can be used to show the presence of bugs, but never to show their absence."Edsger Dijkstra
do{
SerialLib.Read(recvbuf, 5, &BytesRead);
if(BytesRead == 0)
return 0;
for(i=0; i 0);This is the code that I'm using to read the data, and the problem is being caused in here as we have another program written in TCL that recieves that date from the controller just fine so we know it's not a hardware issue. Any help would be great thanks.