Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Want support for transferring bytes() #52

Open
PaulBouchier opened this issue Feb 21, 2022 · 1 comment
Open

Want support for transferring bytes() #52

PaulBouchier opened this issue Feb 21, 2022 · 1 comment

Comments

@PaulBouchier
Copy link

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.

@RonanCostello
Copy link

RonanCostello commented Jun 9, 2022

+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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants