tino / pyFirmata

Python interface for the Firmata (http://firmata.org/) protocol. It is compliant with Firmata 2.1. Any help with updating to 2.2 is welcome. The Capability Query is implemented, but the Pin State Query feature not yet.
MIT License
575 stars 193 forks source link

Check for ports already in use before connecting to serial port #101

Open 01baftb opened 3 years ago

01baftb commented 3 years ago

Hi, I would like to a propose a possible solution to the previously posted issue https://github.com/tino/pyFirmata/issues/100. I am excited for contributing to an open source project for the first time. Please forgive me if proposed solution is incorrect.

Summary of issue and solution: If a user tries to open a port that is already in use, then serial.serialutil.SerialException error will occur. To minimize occurrence of this issue, every time a Board() object is created, we should check to see if the port was already opened by pyFirmata previously by using a class attribute, _boards_in_use that keeps track of all serial ports opened by pyFirmata.

Abhi011999 commented 3 years ago

I second this PR. Please check and merge.

YmClash commented 4 months ago

me too pls