I am using WiringPi-Python to send data over serial and trying to send a char array. My problem is; I cannot send the data if the array includes a 0 (NULL char).
bytes = [112, 52, 0, 18]
send = "".join(map(chr, bytes))
wiringpi.serialPuts(serial, send)
How can I pass a NULL contained char array to serialPuts
?
IMHO the problem is in bindings.i
of the library:
serialPuts()
is defined as
extern void serialPuts (const int fd, const char *s) ;
and in C, strings (char*
) are terminated by the \0
character. I consider that a bug of the library. It should be
extern void serialPuts (const int fd, const char *s, int strlen) ;
Try wiringpi.serialPutchar()
in a loop.