On Thu, 6 Dec 2018 20:59:47 +0100 "Carlos E. R." <robin.listas@telefonica.net> wrote:
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.
In connection with switch contacts NC means 'Normally Closed', and for the other sort of contact NO means normally open. So I'd guess you're supposed to substitute some value there to indicate whether you want the switch to open or close. But you'll need some more documentation to tell you the correct values, or a lucky guess :) Maybe 0x00 and 0x01 ? or 0x00 and 0xFF ? Who knows! -- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org To contact the owner, e-mail: opensuse+owner@opensuse.org