LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Get error code when communicate with RS-232

when I use visa to communicate with rs-232, I get error code sometime.
Before communicate with rs-232, I've  set baud rate, data bits, parity and stop bits. And I'm sure that they're all right.
 
How can I resolve this problem?
Thx All
Download All
0 Kudos
Message 1 of 5
(2,974 Views)
That's the popular "framing error has occurred" error. If you right-click on the error cluster you can select "Explain Error" and it will tell you this. If you do a search on these board you'll see that this topic comes up *a lot*. Typically it's a mismatch in the serial port settings, though you've said you checked this. Does the same thing happen if you communicate with HyperTerminal? Is this the only device you're talking to? How do you have it connected to your PC? Is it a direct connection to your PC's serial port, or is it through one of those USB<-->serial converters? Sometimes this can be caused by faulty connections or faulty cables. Have you tried a different cable? Sometimes this can also be caused if you're communicating too fast and there's noise on the line. Can you communicate to the device at a lower rate to see if the problem goes away?
0 Kudos
Message 2 of 5
(2,958 Views)
thx for smercurio's help
 
first, I do really search in the board. And find some topics like what happen to me. But disappointing, I do not find the way to resolve my problem.
 
second, I connect my RS-232 device directly to my PC. And try to use other cable to communicate.
 
third, I change the baud rate of the device then test.
 
After these, The error still happen.
0 Kudos
Message 3 of 5
(2,937 Views)
I've solved this problem.
What bring on this proble?
In the past, I only close VISA and do not flush buffer before a new read.
0 Kudos
Message 4 of 5
(2,915 Views)
What was the final solution?

I took a look at your VI, and I don't understand why you're setting the I/O Port Buffer size in each iteration of the loop. You shouldn't have to do this in the first place, and even if you did you certainly don't want to do it in each loop iteration. Also, your example VI is likely to run into timing problems if not errors outright. You're forcing a read at each iteration, even though there may not be anything in the serial port buffer. Normally a serial port read is preceded by a call to get the number of bytes available at the serial port so that you know how much to read. Depending on the amount of data that you are transferring you may not even get the whole data packet in one shot and you may need to keep reading until you've read some sort of character that indicates the end of the transmission from the device you're talking to.
0 Kudos
Message 5 of 5
(2,901 Views)