openframeworks / openFrameworks

openFrameworks is a community-developed cross platform toolkit for creative coding in C++.
http://openframeworks.cc
Other
9.88k stars 2.56k forks source link

ofSerial doesn't find devices plugged in after the program has started #6747

Open jo3-tech opened 3 years ago

jo3-tech commented 3 years ago

OF v0.11.0 OF v0.11.2 Visual Studio 2017 Windows 10 Arduino Due

If the Arduino USB cable is unplugged before running the program, and serial.getDeviceList() is used, it assigns a device ID to any available/connected devices in numerical order e.g. if there are 3 devices available, it assigns 0, 1, 2 to the devices. If the Arduino USB cable is now plugged in while the program is running and serial.getDeviceList() is used again, the new device ID list becomes 0, 1, 2, 0. Instead of detecting the newly connected device, it is repeating the first device twice.

An example output from a modified serial example which recreates the issue is as follows:

serial device found: Intel(R) Active Management Technology - SOL (COM3) ID: 0 Port: COM3 serial device found: Standard Serial over Bluetooth link (COM9) ID: 1 Port: COM9 serial device found: Standard Serial over Bluetooth link (COM8) ID: 2 Port: COM8

serial device found: Intel(R) Active Management Technology - SOL (COM3) ID: 0 Port: COM3 serial device found: Standard Serial over Bluetooth link (COM9) ID: 1 Port: COM9 serial device found: Standard Serial over Bluetooth link (COM8) ID: 2 Port: COM8 serial device found: Intel(R) Active Management Technology - SOL (COM3) ID: 0 Port: COM3

I should note that if I run the program with the Arduino connected as follows, everything works fine:

serial device found: Intel(R) Active Management Technology - SOL (COM3) ID: 0 Port: COM3 serial device found: Standard Serial over Bluetooth link (COM9) ID: 1 Port: COM9 serial device found: Standard Serial over Bluetooth link (COM8) ID: 2 Port: COM8 serial device found: Arduino Due (COM7) ID: 3 Port: COM7

The same correct output above is obtained even if Arduino is disconnected and reconnected while the OF program is still running and a key is pressed to detect serial devices.

I have posted the source code that I used to generate the above output here: https://forum.openframeworks.cc/t/ofserial-doesnt-find-devices-plugged-in-after-the-program-has-started/37799

DeqingSun commented 3 years ago

I've not tested with v0.11.0, but I tested with v0.10.1 both on Mac OS and Raspberry pi, the both worked flawlessly with hot plug.

jo3-tech commented 3 years ago

I've not tested with v0.11.0, but I tested with v0.10.1 both on Mac OS and Raspberry pi, the both worked flawlessly with hot plug.

v0.10.1 doesn't work for me. Maybe it's an issue associated with windows? Or something else with my setup.

pierrep commented 3 years ago

I have a feeling this could be a Windows thing...