04-11-2022 12:06 AM - edited 04-11-2022 12:44 AM
Hello All!
I was posting about error 66 but I realized my mistake. If anyone runs into the issue where your server seems to receive a message from your client but only after the client disconnects and generates error code 66, it's possibly due to telling LabVIEW TCP Read to read far more Bytes than the client is actually sending. A common enough standard is to prepend your message with 2 Bytes in "Network-Byte Order" (Big-Endian) that represents the Byte-length of the message to receive. This is large enough for most purposes, since 2 Bytes represents 2^16 possible values, lending to a maximum message length of 65,535 Bytes.
I've included an image of how to read a string, convert it into a Byte-array, reverse it, index the array, use a logical shift to shift the 2nd element by 8 bits, and add the shifted element to the 1st to convert the pair into a usable little-endian integer for the next read. Works well enough for me.
Still new to LabVIEW, if anyone has better methods, I'd be happy to see them!
04-11-2022 01:28 PM - edited 04-11-2022 01:47 PM
Unfortunately, a blurry, truncated picture of very messy code is not suitable to demonstrate anything at all.
Did you ever look at the shipping examples?
(Whatever you are doing here can be done with 20% of the code. And why would you convert to little endian? Pure Rube Goldberg.
Your code is completely wrong and will not work, because shifting a U8 by 8 positions does not leave anything, right?. Index array is also resizable.
Why are you trying to micormanage datatypes. sending 4 bytes I32 ( a much, much more "common standard"!) would be more natural, even if you never use all bits. No coercion dots!)
Here's are two alternative versions to get a big endian U16 out of 2 bytes....
04-11-2022 03:15 PM
Hey Altenbach, thanks for the clarification. No, I haven't seen the shipping examples. I did not find them in the examples folder. Would this be what you are referring to?
Archived: Download NI-DAQmx Shipping Examples for LabVIEW 2012 or Compatible - NI Community
04-11-2022 06:25 PM - edited 04-11-2022 06:27 PM
No, in LabVIEW go to "menu...help...find examples" to open the NI example finder. All these examples come preinstalled with LabVIEW!
Search for "TCP" and open the example project called "Simple TCP.lvproj"