From 04:00 PM CDT – 08:00 PM CDT (09:00 PM UTC – 01:00 AM UTC) Tuesday, April 16, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Sending a message over serial does not working sometimes

I am using a simple read/write vi to send and receive messages over RS232 (VI along with its screenshot is attached). The target is a linux based system. Most of the time, the messages which are sent to the target are received correctly (based on the response from the target). However, sometimes the target responds that the format in which the message was sent is not correct. The messages which are sent can be very long and have to be sent in a certain format (an extra . or / or a space can cause an error). i have used port mon to sniff the messages which are being sent and i cannot tell the difference between the correct one or the instance where it fails.

 

i do not see this problem while using the hyperterminal. i have tried to match the 'configuration' settings for the vi serial to the hyper terminal also.

 

Can you see any problem with my vi? Can i make it more robust? i am trying to narrow this down to it being an issue with the target, vi or a limitation from serial.

 

 

P.S. the xxx in the vi you noticed are there to avoid mentioning any product specific terms.

 

 

Also attached are the following logs:

 

SerialLV.txt: Portmon log from LabVIEW

 

Download All
0 Kudos
Message 1 of 25
(3,482 Views)
SerialHyperTerminal.txt: Portmon log from Hyper Terminal
0 Kudos
Message 2 of 25
(3,479 Views)
Check you flow control for the RS232 port. If I am interpreting the hyperterminal information correctly it is using XON/XOFF flow control. Your VI is using no flow control.


Mark Yedinak
Certified LabVIEW Architect
LabVIEW Champion

"Does anyone know where the love of God goes when the waves turn the minutes to hours?"
Wreck of the Edmund Fitzgerald - Gordon Lightfoot
0 Kudos
Message 3 of 25
(3,464 Views)
okay so i turned the flow control on to XON/XOFF but still see the same issue. What bugs me is that it does not happen everytime. If i set the vi to run continuously with wait time of around 2seconds, it occurs ~2 out of 14 times...i initially thought that there could be a problem with the buffer so i added a flush at the start and end of the vi but that did not really help.
Message Edited by USar on 02-19-2010 09:30 AM
0 Kudos
Message 4 of 25
(3,439 Views)

What is the length of the wire run?

 

Ben

Retired Senior Automation Systems Architect with Data Science Automation LabVIEW Champion Knight of NI and Prepper LinkedIn Profile YouTube Channel
0 Kudos
Message 5 of 25
(3,431 Views)
^good thinking Ben...i was not even thinking about that. it is around 8 feet. :------) Are there any specs which say that the serial communication might lose data or is not going to be reliable if the wire is of x length? or is this going to be based more on experience?
0 Kudos
Message 6 of 25
(3,423 Views)

The number I carry around in my head for RS-232 (probably a spec somewhere) is 2500 pF cable capacitance which is ultimately what gets you.  For a normal cable that is at least a hundred feet.  If you are willing to deal with slower communication you can use hundreds of feet.

 

Most problems I have encountered with cables have been at the ends, and even those are rare. 

0 Kudos
Message 7 of 25
(3,415 Views)

yeah i found this online:

 

These are the standards for length.

DTE stands for Data Terminal Equipment, any sending or receiving device attached to the end of the cable.

Serial Cable Length Limits (RS-232, V.35, RS-530, RS-422/449)

Table below lists the maximum permissible cable lengths for various protocols at various representative data rates. These lengths are as specified in the EIA RS232C, CCITT V.55 and RS422 interface standards.

Material requirements:

* Conductor size and type: 24 AWG, twisted pair.
* Nominal capacitance: 15.5 picofarads per foot (between conductors of each pair);
27.5 picofarads per foot (from each conductor to shield).
* Nominal DC resistance (each conductor): 24.0 ohms per 1000 feet.

* Nominal DC resistance (shield): 2.35 ohms per 1000 feet.
* Shield type: Overall braided with drain wire.
* Approval: Underwriters Laboratories (UL).


DTE Data Rate [kb/s]---Maximum DTE Cable Lengths [ft]

-----------------------RS232C---V.35----RS449/422---RS530/42 2
56 or 64-----------10----------4000---------4000-----------4000
224 or 256-------N/A---------3500---------1700-----------1700
896 or 1024-----N/A---------1700-----------350-------------350

N/A - not applicable (these rates cannot be used for RS232C interface)

NOTE on RS-232 Serial Cables

At lower peripheral speeds of up to 9600 baud, serial interfaces can usually operate over cables up to 50 feet long. Use of special high quality cable may in some cases allow this limit to be extended to as much as 150 feet.

0 Kudos
Message 8 of 25
(3,412 Views)
i do not know what the capacitance is of the cable that i am using but it looks like your regular cable. nothing is mentioned on the cable itself. baud rate i am using is at 115k. i will see if i can find a 'better looking' cable or one which is shorter in length.i have not really had an issue in the past but then again i have been using the RS232 8 port serial card from NI and probably not this extensively to send/receive messages over RS232.
Message Edited by USar on 02-19-2010 10:14 AM
0 Kudos
Message 9 of 25
(3,405 Views)

If dropping your baud rate reduces the occurence of errors you may be onto something.

 

Another thought from years ago (17 maybe)...

 

Serial ports on Unix systems resrved some characters for waking up the OS and starting a login, so... are there any odd characters being passed?

 

Ben

Retired Senior Automation Systems Architect with Data Science Automation LabVIEW Champion Knight of NI and Prepper LinkedIn Profile YouTube Channel
0 Kudos
Message 10 of 25
(3,396 Views)