03-15-2009 01:19 PM
Hi, I have a comunication with 2 radiomodems via RS232 port, and I get data with VISA in my laptop and have a Visual Basic program that controls the frames in the other embbedded PC that sends me frames of an electronic compass and a GPS. The thing is that in the VB application I can see the correct frame of the compass to be sent, but the one that I recive in my laptop is not the correct one, in fact is the one that was sent 30 secs ago so I can't allow that happen and I have no idea what could be the problem cause radiomodems transmit correctly and I made another VI program that only reads the frame and the same thing happened, so I have the thinking that it can be the VISA command that stores the frame or something similar. By the way, the compass samples twice per second, and the radiomodem sends that frame every 400ms. At the beggining, the compass sampled 8 times per second and I thought it could be the problem but it remains altough I changed that. What can be happening?
Thank you
03-15-2009 01:37 PM
The VISA driver itself does not have a buffer. You may be reading the buffer later than you think. However, if that's the case, you should be dropping data (or eventually will).
Can you post your code so that we can see how you have implemented your solution?
R
03-15-2009 02:01 PM
03-15-2009 02:56 PM
03-15-2009 03:33 PM
03-15-2009 03:56 PM
03-15-2009 09:23 PM
Please post your code so that we can have a look at it.
R
03-16-2009 04:48 AM - edited 03-16-2009 04:48 AM
Sorry, I wanted to say LF not LP. I tried that and didn't do nothing, the same problem. The good new is that I finally found what was the problem. I have to put a delay of 400ms in my VI application and in the VB application. That did that somewhere, the frames were stored. Now I have changed the delay and put the VISA read inside a while with a condition of 400ms of time so now I recive the frames correctly. The problem I have now is that if I stop the VI application but not the VB one, and let the radiomodem send data, when then I run the program, I have a crazy frame showing that had been storing while the VI was stopped, and if that was for a long time, I get an error in VB because it recives a strange frame from my laptop. So, where could frames be storing while my VI application is sttoped???? Do I have to close the VISA port? I tried to do that, closing the serial port every time I sttopped reading and writing, but I only recive strange characters on frames, so it can't be the solution.
Thanks.
03-16-2009 09:38 AM
You should implement a graceful shutdown scheme, where a message is passed to / from both PC's to let the software know that communication is about to be cut. After they both acknowledge it, they can stop the communication (read / flush the buffer) and close the port.
R
03-16-2009 09:45 AM
If yours is like the GPS I used it just spwes out data continually as long as it is running, so...
When you stop your application, close the VISA port.
When you re-start it purge the serial port by checking the number of bytes waiting at the port then read and discard all that where waiting.
Ben