Good day,
This is going to be long. I'm trying to communicate with the "SainSmart iMatic with RJ45" board, which is used together with the "SainSmart 16-Channel 12V Relay Module".
Basically, I'm able to send hex commands to the board, successfully, but can't receive a response from the board when required. What do I mean with this?
I have a laptop with Ubuntu 14.04.4 LTS connected directly to the board via an Ethernet Straight through cable (no longer crossover type needed). I have a configuration for this type of network (only two devices). The IP of the imatic board is fixed, 192.168.1.4 with port 3000. My laptop IP has a fixed IP of 192.168.1.2, with netmask 255.255.255.0, and no gateway.
I'm using netcat (in TCP protocol mode) in my laptop to send commands to the board in this format in terminal : echo '580112000000016C' | xxd -r -p | nc 192.168.1.4 3000 How do I know it works? Well, basically the relays from a secondary board are turned on successfully ("SainSmart 16-Channel 12V Relay Module").
There's a list of hex commands to turn on and off each relay. In the previous instruction, I'm telling the board to turn on the relay number 1, leaving the other 15 off. The string '580112000000016C' is converted from hex into binary with xxd, and then sent into the netcat. This part works.
The only instruction that doesn't work is this one: echo '580113000000006C' | xxd -r -p | nc 192.168.1.4 3000 This instruction only asks the board which relays are off an on at the moment, expecting a response in this format: 28 01 00 00 00 XX XX HH (XX XX 16 bit, each bit represents one relay state, "1" indicates on, "0" indicates OFF; HH is the sum of all previous data together, meaning it works as a checksum)
I've already tested and proved that, this is NOT an issue from the board. I wrote a code in visual basic, and windows was able to receive the response from the board, but something has to be wrong in my ubuntu configuration. I've already disabled my firewall, ufw. This is NOT a problem with the Ethernet cable. I've already tried other command representations such as: echo -n '5801100000000069' | xxd -r -p | nc -v -n -w3 192.168.1.4 3000 | xxd I've already used netcat to scan all available ports in the board, and only the 3000 port is shown as available, as stated from the manufacturer. This seems to be a network configuration problem though, but in windows, I specified the same IP, and netmask as in ubuntu.
What am I mising here?