For issue #13 I made some major changes to the code.
I used serial.tools.list_ports.comports() in the function getMiniSerial() to retrieve a list of serial ports from the OS. The serial port for the Calliope Mini is identified by "Calliope mini - CDC". This way, the port of the Calliope Mini can be reliable determined.
The pySerial instance ser is no longer a global variable. The serialConnect() routine will return the instance in the case, the connection is successful.
The function programmMini() no longer contains the connection to the Calliope Mini. Instead, the connection is triggered from main() via calling the function connectSerial().
I found out, that the serial port of the Calliope Mini shows up very early after programming. On can also connect very soon. But reading/writing too soon will cause an I/O error. The best work around was to wait 10 seconds after the serial port could be found in the system before connecting and making any read/write operations.
I tested the code on my Raspbery Pi. The scripts executes as expected with and without Calliope Mini.
I just saw, that the dependency to package glob is no longer needed, because the script now uses serial.tools.list_ports.comports() to retrieve a list of serial ports from the OS. We can delete import glob. I added a dedicated commit.
Fixes issues #5 and #13
For issue #13 I made some major changes to the code.
serial.tools.list_ports.comports()
in the functiongetMiniSerial()
to retrieve a list of serial ports from the OS. The serial port for the Calliope Mini is identified by "Calliope mini - CDC". This way, the port of the Calliope Mini can be reliable determined.ser
is no longer a global variable. TheserialConnect()
routine will return the instance in the case, the connection is successful.programmMini()
no longer contains the connection to the Calliope Mini. Instead, the connection is triggered frommain()
via calling the functionconnectSerial()
.I tested the code on my Raspbery Pi. The scripts executes as expected with and without Calliope Mini.