s-light / CircuitPython_nonblocking_serialinput

CircuitPython helper library to handle serial user input in an nonblocking way.
MIT License
7 stars 0 forks source link

Requesting support for 'data' serial console #3

Open DeviousFusion opened 2 years ago

DeviousFusion commented 2 years ago

Hey @s-light ! Thank you for this library. I have been using with Rpi pico and it works great. I was hoping you could add support for the second serial console that usb_cdc provides: usb_cdc.data. This allows me to send serial commands on data console, while keep the default console for debugging. Currently I am using this as a workaround:

import usb_cdc
import nonblocking_serialinput as nb_serialin

my_input = nb_serialin.NonBlockingSerialInput(serial=usb_cdc.data)

But the above requires me to import usb_cdc. If this is the way you envisioned then we can close the issue request, but I feel the user shouldn't have to re-import usb_cdc

s-light commented 2 years ago

Hello @DeviousFusion great its working for you. and thanks for this request!

yeah that is the way i thought about this...

and the only reason i have to import usb_cdc in the library is to have a default serial to use...

i could add a second class that just defaults to the data channel.. and maybe later refactor both defaults out of the main into a extra file - this way it would be possible to use the library with other implementations.. (Blinka?!) - as long as the connected, in_waiting and read functions are available..


i think i will do this refactor next week - feel free to ping if i forget about it.. ;-)

DeviousFusion commented 2 years ago

I like the idea of the refactor such that both consoles have their own classes. Limits cross-chatter and allows for better integration with other libraries as you mentioned. Again no rush.

s-light commented 2 years ago

i just did the refactoring - untested on the quick ....

fell free to test and report if it is working or i have done something stupid in the hurry... ;-)