On 06/12/2018 20.21, Paul Groves wrote:
Hi everyone.
I bought one of these relay switches from ebay so that I can turn on and off the tape drive in the server room:
https://www.ebay.co.uk/itm/Intelligent-USB-Control-Switch-With-MCU-Microcont...
If you scroll to the item description it gives you the data to send to the switch to control it. I wrote the below little bash script. To change what the relay does I simply change the 4 data values.
#!/bin/bash
function byte() { printf "\\x$(printf "%x" $1)" }
{ byte 0xF0 byte 0xA0 byte 0xNC byte 0x54 } > "/dev/ttyUSB0"
However some of the values are 0xNC as you can see by my above example. Now when I run the script it works but I get the following output:
paul@paul-pc:~$ bash relay2.sh relay2.sh: line 4: printf: 0xNC: invalid hex number
Of course the data is obviously hexadecimal and NC is not a hex number. But seeing as there is an error this must not in my opinion be the correct method.
The method is correct AFAICS; the data is not. -- Cheers / Saludos, Carlos E. R. (from oS Leap 15.0 x86_64 (Minas Tirith))