On 07/12/2018 17.51, Paul Groves wrote:
On 07/12/2018 12:18, Carlos E. R. wrote:
The link he sent has very limited information. It appears to have an USB to RS232 converter, then the rest.
it is a CH341 USB to RS232 converter, then a serial PIC chip which controls the relay switch.
Ok.
The relevant paragraph says:
The next step is to send instructions, the command format is as follows. Control command: (hexadecimal transmission, four bytes) 1. F0 A0 00 53 Disconnect command. In JOG control mode, this function is disabled. 2. F0 A0 01 53 Closed command, in different control mode, the effect is different 3. F0 A0 NC 54 Select the control mode as normal control mode 4. F0 A0 NC 55 Select the control mode for jog control 5. F0 A0 NC 56 Select the control mode for delay control 6. F0 TH TL 57 In normal control mode, set the timer time, delay time is between 1 and 65536 seconds. After the delay time arrives, the current state of the relay is inverted. The timing time is TH * 256 + TL. Timing is a one-time, set up only once.
These codes all work fine when I send them with my script. I am just confused why they have NC there instead of a hex value.
No, they don't work "fine". Look, I created a test program based on yours: #/bin/bash function byte() { printf "\\x$(printf "%x" $1)" } { byte 0xF0 byte 0xA0 byte 0xNC byte 0x54 } > text.bin I then run it: cer@Telcontar:~> cd bin/test cer@Telcontar:~/bin/test> bash echohexttext echohexttext: line 4: printf: 0xNC: invalid hex number cer@Telcontar:~/bin/test> It creates file "text.bin". I now look at it: cer@Telcontar:~/bin/test> hexdump -C text.bin 00000000 f0 a0 00 54 |...T| 00000004 cer@Telcontar:~/bin/test> cer@Telcontar:~/bin/test> l text.bin -rw-r--r-- 1 cer users 4 Dec 7 18:39 text.bin cer@Telcontar:~/bin/test> It contains four (hex) bytes: "f0 a0 00 54". The "NC" has been replaced with a zero. What you appear to be doing is setting control mode zero.
When I pose the mouse over the lines get a popup with text in what appears to be Chinese. So maybe what we get is a translation.
I checked the translations. They all say the same in English as the line which is hovered over.
Ok.
There should be a link to the actual documentation of the module. As it is, it is incomplete and wrong. Maybe "normal control mode" (NC) has to be replaced with a number from a table of values somewhere.
Possibly. I have asked the seller but he does not speak great English.
Well, that explains why the documentation is incorrect/incomplete... -- Cheers / Saludos, Carlos E. R. (from 42.3 x86_64 "Malachite" at Telcontar)