Sending a Boolean
jmdelahanty opened this issue · 5 comments
Hello glorious PowerBroker!
I'm trying to send along a boolean value in a struct but I'm not sure how to do it with pySerialTransfer! Any advice?
Hey Jeremy!
Bools are 1 byte objects both in Arduino/C++ and Python, so they should be compatible automatically. Bools are also automatically supported in pySerialTransfer.
You're the best! I'll close this for now. If I run into something weird when I'm putting it into the code I'll just comment here.
To double check, this means I don't need to do any val_type_overrides
if what's fed into the tx_buffer
is type bool
? See this line for where I'm doing it.
So I could just add this to the transfer:
metaData_size = link.tx_obj(arduino_metadata['lickContingency'], metaData_size)
lickContingency
is a Boolean value (literally True
or False
)
metaData_size = link.tx_obj(arduino_metadata['lickContingency'], metaData_size)
should be fine because Python will automatically create a value type format for the transmission if the payload object is of a built-in Python type (i.e. bool):
tx_obj():
pySerialTransfer/pySerialTransfer/pySerialTransfer.py
Lines 253 to 274 in 782c4ab
I'd say give it a shot and see if it works
This totally works by the way!