12-04-2018 11:55 AM
I'm sending ASCII strings from a device into LabVIEW using TCP. I'm using the CRLF as a termination (end-of-input) character and trying to use LFCR as a newline (but not end-of-input) but the TCP read vi is adding a CR before the LF which ends the read early. How do I stop that?
12-04-2018 11:59 AM
The detailed help for TCP read describes different modes. Try a different mode and see how it works.
12-04-2018 12:02 PM
the four different read modes include the CRLF terminator, but I haven't seen a way to stop the vi from adding characters. if I go to another mode i probably need to write a new vi to emulate the CRLF mode. possible, but not ideal
12-04-2018 12:18 PM - edited 12-04-2018 12:20 PM
Make sure you're not sending extra characters.
Edit:
Sorry, I don't mean "you" personally; rather something that you're not aware of is doing this.
12-04-2018 12:21 PM
i've messed with it for a while and convinced myself that i'm not actually sending the characters. when i use a simple terminal program like TeraTerm i don't see the extra characters.
12-04-2018 12:32 PM
Can you show us some simplified code that demonstrates the problem?
12-04-2018 12:37 PM
it is pretty simple:
this leaves a lot of data in the buffers. I've added a TCP read using the "standard" termination mode and is get the rest of the data (after the read times out).
the actual code is on a lab computer and is a hassle to get to
12-04-2018 12:58 PM
@ChiliLover wrote:
it is pretty simple:
If we need to write our own test code, most likely nobody will even bother.
TCP is regularly used to transmit binary data where not a single byte pattern is "reserved", so obviously something is wrong in your case if the bytes are edited in some way during transmission. We probably really need to see your code.
12-04-2018 01:42 PM
@ChiliLover wrote:
it is pretty simple:
- TCP open
- TCP write to send the data request
- TCP read to get the data
this leaves a lot of data in the buffers. I've added a TCP read using the "standard" termination mode and is get the rest of the data (after the read times out).
the actual code is on a lab computer and is a hassle to get to
TCP read DOES NOT add characters to the data. You are either sending more than you think you are or you are not reading the data correctly. Use Wireshark to see exactly what data is being sent by the device.
12-04-2018 02:29 PM
I saw an idea in a related post and I tried it successfully. I set up a single character TCP read (standard mode) with a long timeout followed by a while loop containing a single character TCP read (standard mode) with a much shorter timeout. I'm getting complete reads now.
I'm pushing characters to a ethernet chip on my device. it could be that the device is "helping" me out by adding the CRs. the documentation is poor but there is no indication that the calls would be doing that.
anyway, i've got a solution now so thanks.