I’m creating blobs to send to a uart.write. I’d like to be able to assign multiple bytes at once, but that generates an error when I use the result with uart.write. Apparently it generates a blob that is not a blob. I tried this:
local mod_blob = blob()
mod_blob = [254,65,0,128,1,16,40,126]
It doesn’t complain until I try to use the result in a uart.write where it complains about bad parameters.
So I have to do this instead:
This doesn’t write to the blob. It changes the mod_blob variable to refer to an array of integer values, instead.
There doesn’t appear to be a constructor that takes an array, or a method that converts from array to blob. I think (but could be wrong) that writen is the best way to do this.
If you’re prepared to take a hit on readability, and you pay attention to byte-ordering (endianness), you can probably write 4 bytes (or even 8, if you’re prepared to monkey around with floats) at a time.