I have some Fusion boards with Ethernet and find that I am able to turn relays on and off via Netcat without any problem:
echo -en ‘\xAA\x03\xFE\x6C\x01\x18’ | nc 10.1.0.164 2101 | hd -v -e ‘256/1 "%02X " “\n”’ |sed ‘2q;d’
echo -en ‘\xAA\x03\xFE\x64\x01\x10’ | nc 10.1.0.164 2101 | hd -v -e ‘256/1 "%02X " “\n”’ |sed ‘2q;d’
Note, the hd and sed commands are just for formatting and I don’t get a response either, if they are removed. In all cases, when I send a command the Busy light flashes.
However, there is no response, and when I try the 2-way communications test I also get no response:
echo -en ‘\xAA\x02\xFE\x21\xCB’ | nc -C 10.1.0.164 2101 | hd -v -e ‘256/1 "%02X " “\n”’ |sed ‘2q;d’
The actual objective is to detect contact closure on the GPIO pins, however I don’t get a response to:
echo -en ‘\xAA\x03\xFE\xAF\x01\x5B’ | nc 10.1.0.164 2101 | hd -v -e ‘256/1 "%02X " “\n”’ |sed ‘2q;d’
And in fact, when I run NCD Base Station, UXP SCAN contact closure input, I get all zeros back even though UXP2, IN2 is grounded. If I run AD8 8-channel analog input, I get 0V for IN2 and 5V (pulled high) for all the others which is correct.
What do I need to do differently to get a response back from the Fusion with Netcat? Note, I also tried creating a RAW virtual com port with: socat pty,link=/dev/vcom0,raw tcp:10.1.0.164:2101 &
But when I echo a command to /dev/vcom0 it doesn’t even flash the busy light.
Why doesn’t UXP SCAN contact closure input in NCD Base station give me a 1 for the contact that is in fact closed?
NCD Base Station should be used to make sure everything is working correctly, make sure the jumper is set to UXP only if you are using a UXP expansion. The GPIO on Fusion can read Analog, Digital, or an Expansion input board. If you can get it working in Base Station, click the “More” button to see the communications and convert for NetCat. Be sure to use GPIO control panels if you get want to read digital inputs, only use UXP control panels if working with a contact closure expansion.
Hope this helps.
Thanks Ryan, I just got back to this now. In NCD Base Station, I needed to use the Digital IO panel rather than UXP.
With netcat, the issue seems to be that it does not wait for a response. The trick is to add -q 1 as follows:
echo -en ‘\xAA\x02\xEC\x01\x99’ |nc -q 1 10.1.0.164 2101 |hd -v -e ‘256/1 "%02X " “\n”’ |sed ‘2q;d’
Produces the expected response showing that IN8 is high:
AA 01 80 2B
It works as one would expect with the jumper in either position, pulled high or pulled low.
Actually I had futher difficulties with netcat, it would only work with one specific device (which happened to be the gateway for the NCD5500 ethernet module). After chasing things down I saw comments that netcat is buggy and I got the following to work nicely:
echo -en '\xAA\x03\xFE\x81\x01\x2D' | socat stdio tcp:10.1.0.164:2101,shut-none | hd -v -e '256/1 "%02X " "\n"' | sed '2q;d' | sed 's/ *$//'
If there is a lot of network latency, socat might need
-t 1 (seconds) or more, the default is that it keeps the socket open 1/2 second to receive incoming data after the outgoing data has been sent and then closes both directions.
Thanks for posting, this is very helpful!