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

Rewrite port handler to support software-controlled disconnect & reconnect #14

Open
FilipDominec opened this issue Apr 6, 2024 · 0 comments
Assignees

Comments

@FilipDominec
Copy link
Owner

FilipDominec commented Apr 6, 2024

Double initialization of one device must be blocked.

The 2nd call somehow manages to connect to already connected device, but the identify callback
gets redirected to the first Rp2daq object:

In [2]: rp2daq.Rp2daq()                                                                                                                                       
2024-04-06 11:54:19,091 (MainThread) connected to rp2daq device with manufacturer ID = E66138935F6F8E28
Out[2]: <rp2daq.Rp2daq at 0x7f8dfee52c70>

In [3]: rp2daq.Rp2daq()                                                                                                                                       
2024-04-06 11:54:23,229 (Thread-273) Warning: Got callback that was not asked for
		Debug info: {'report_code': 0, '_data_count': 30, '_data_bitwidth': 8, 'data': b'rp2daq_231005_E66138935F6F8E28'}
2024-04-06 11:54:23,373 (MainThread)    port open, but device does not identify itself as rp2daq: b''
2024-04-06 11:54:23,374 (MainThread) Error: could not find any matching rp2daq device

So on line "[3]" we should have detected the device was not available, and reported an error instead.

Related to this: the port handler process must stop once we have sw-disconnect, then don't report hw disconnect and allow for clear reconnect.

In [4]: rp.quit()                                                                                                                                             
 In [5]: 2024-04-05 11:16:13,790 (MainThread) Device disconnected, check your cabling or possible short-circuits  

Also related: rp.quit() should release COM port on Win10, so that one can run it again.

And if there is a long command (like synchronous stepper_move) when the device gets physically disconnected, it hangs forever - because it ignores the disconnect event, and waits for the report over USB which never comes.

And when a device is still actively reporting some data (infinite ADC, gpio edge events etc.) and a script is re-started, it randomly won't initialize, because initialize immediately expects a specific short report. Maybe the device should be somehow reserved to stop any other reports (?), then port flushed, then called the init.

@FilipDominec FilipDominec self-assigned this Apr 6, 2024
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

1 participant