I'm going to set up a binary driven serial communications between two Arduinos via the built-in hardware serial library. Since my packets are structured in a binary format, it is very likely that several characters in the packet are null characters for instances of integers with a 0 value. I'm not sure how the Arduinos will handle null characters or if at all. I would certainly like to know before I go any further on my project.
Binary data can be transmitted using the write()
method in the following form:
Serial.write(buf, len)
where...
buf: an array to send as a series of bytes.
len: the number of bytes to be sent from the array.
In this way all the specified characters are transmitted, included the null ones. Otherwise, if just the buffer parameter is passed to the method, it treats the parameter as a string and stops transmitting at the first null character it encounters.
Yes. The Arduino documentation for write()
talks about "binary data" and bytes.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With