PowerBroker2/pySerialTransfer

Want support for transferring bytes()

PaulBouchier opened this issue · 1 comments

bytes() is its own type in python3, and is common enough IMHO that pySerialTransfer should support it. Since bytes() do not need packing with struct.pack(), the proposed solution is to change the logic in txObj to check for type(val) == bytes and not attempt to pack it.

Currently, byte strings must be unpacked into ints then passed in with one call to txObj per byte, giving val_type_override as:
send_size = link.tx_obj(self.left_drive_pct, val_type_override='b')

The alternative - to send values as ints and convert them to bytes on the Arduino side, would consume 4X the bandwidth on the serial link.

Thoughts? I am willing to contribute this fix in a pull request if you support the idea.

+1 for this. should be able to send a byte array. It is the natural lowest level format for handling in a microcontroller so should be supported.

Note: to adopt the work around suggested by @PaulBouchier val_type_override='B' (rather than 'b') is needed.