I don’t see anything on the entire NCD site about Labview communicating via TCP/IP. I have Base station running and it turns relays on/off and I can see the API command that is being sent, but I can’t get my Labview program to work with these API commands. I have tried sending the commands straight from a TCP/IP Labview program and with a VISA style Labview program. It seems like I’m missing something simple.
Usually if you’re sending the same commands as base station and the device is not responding as expected it is due to the commands being sent over TCP/Serial as a string instead of raw bytes or a bytearray.
Unfortunately I don’t have any experience specifically with labview, but in most languages it would look something like this which creates a byte array:
my_byte_array = [0xaa, 0x03, 0xfe, 0x64, 0x00, 0x0f];
Some languages TCP libraries expect a string so you may have to convert the above byte array into a string to pass it into the tcp socket’s write method.
I think this is one the right path, when I hit enter to submit a command I see the lights on the relay module start blinking, so it’s like the command isn’t understood. Does the NCD Relay board expect a termination code like carriage return or line feed?
The NCD devices don’t expect a carriage return or line feed, but looking at NI’s documentation their TCP Write may: Product Documentation - NI
Honestly this section of their documentation sounds like they may just be giving general advice on how to format a TCP message between two LabView scripts. I’m not sure it’s actual documentation on what the TCP Write expects.
Does the bytes written section of the code work and if so does it display 6?
I also found this QA while looking for the doc which describes how to change your inputs to raw hex which will at the very least tell LabView that these are binary values and not integers or strings of any kind: TCP Comm send the Hex data - eehelp.com
Yes, the bytes written section works and returns a 6 and I can open/close relays now, but the code above returns an error at the TCP Read. After the timeout is gives a error at TCP read. In the NCD Base Station software it said 85 bytes are being read back, but it the example above I was getting “NCD.IO\AA\01U\00”, which in hex is 4E43 442E 494F AA01 5500 (10 bytes), so I changed my TCP Read to 10 bytes and it seems to all work now without errors.