Prev: How to use dblquad command
Next: Real-time Workshop for serial communication: clear input buffer needed
From: Jose on 7 Aug 2010 03:26 Dear all, I am having a problem using the packet input function on real-time. I am able to read the 17 bytes of data I am sending through the serial port in a good way BUT sometimes I end up having an extra byte in the frame which is making my buffer shifting one position every time this happens. E.g. byte 1 ... byte 17 = 17 bytes byte 1 ... Garbage = 17 bytes byte 17 (old) byte 1 ... byte 16 = 17 bytes So basically after some time I start only seeing the last bytes in the next frame, which is really bad. What I can do to fix this, in MATLAB code (http://www.mathworks.com/support/solutions/en/data/1-30N8YX/index.html?product=ML&solution=1-30N8YX) and in Labview is to Flush and Discard the Buffer (Purgecomm function in C). The thing is that I needed to use real-time simulink for this but Packet output doesnt do this automatically. Do you have any suggestions on how to do this? We have tried to do a C function S function to read the serial port in real-time, but first we used the windows.h to do this and it doesnt work as it is explained in the matlab help, and after that we built a C function based on the conio.h function which also doesnt work since it is made for pure RS232 serial communications (PORT1 to PORT4) and we are using USB (PORT5 to PORT9). Thank you! Jose |