On 12/6/18 8:21 PM, 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.
Can anyone shed some light on a better way of doing this?
Thanks Paul
Hi, I don't know what data exactly you have to send to your device. But, from the above listed sequence it's clear that you try to send one invalid hex value (0xNC is not a hex number). I am guessing that you might want to send NC as two characters in sequence. If so, than you have co represent them in hex: N ---> 0x4E C ---> 0x43 So, instead of 0xNC you might want to send two bytes: byte 0x4E byte 0x43 Regards, Radule N�����r��y隊Z)z{.�ﮞ˛���m�)z{.��+�:�{Zr�az�'z��j)h���Ǿ� ޮ�^�ˬz��