Closed kulka-ig closed 5 years ago
Nice find.
I added the bufsize = 8;
line to test. Now the setSystemTime line I have in vito.xml returns OK, and sets the time to what I have in the Pi.
While reading through unit.c I was surprised by the comment about "n" at the end of the file, in "procSetUnit"
if (n >= MAXBUF - 3) {
// FN: Where is 'n' initialized?!
break;
}
It seems to be an oversight (cut & paste) from "procGetUnit". "n" is declared and initialised at 0 but never used in the code. I commented the block out, and have not yet seen any negative impact.
hi, is that the reason, why I get this:
unit off:
DEBUG:Tue Apr 30 13:53:00 2019 : Command: unit off
setSystemTime 20 19 04 30 02 13 53 00:
DEBUG:Tue Apr 30 13:53:00 2019 : Command: setSystemTime 20 19 04 30 02 13 53 00
DEBUG:Tue Apr 30 13:53:00 2019 : Error in length of the hex string (8) != send length of the command (1), terminating
DEBUG:Tue Apr 30 13:53:00 2019 : Error executing setSystemTime 20 19 04 30 02 13 53 00
ERR: Error in length of the hex string (8) != send length of the command (1), terminating
Error executing setSystemTime 20 19 04 30 02 13 53 00
unit on:
DEBUG:Tue Apr 30 13:53:00 2019 : Command: unit on
Fixed in current release thanks to @nexx512
setSysTime (unit.c) does currently not allow any parameter but creates the string itself.
However, calling fails with only one byte of the string transmitted. 'bufsitze' would normally give the length of the entered command line, but is zero in this forced case. Now string2chr gets an incorrect number (zero) of bytes to convert. (string2char always returns a single byte and count 1, even on bufsize zero ...)
Setting bufsize to 8 mitigates the issue:
or
Pull #49 opened on 25 Nov 2018 by nexx512 "Implemented setSystemTime " also correctly calls with '8', so whatever comes first ... :-)
Best regards, Igor