Open titimoby opened 7 years ago
Can you see if you can open the serial port with a terminal program logged in as the same user? e.g. miniterm, using /dev/ttyACM0
Also can you paste the contents here of your portscan.cache file that is in the same directory as counter.py
Finally, can you run it in debug mode like this:
python3 counter.py debug
and paste the output here
Thanks
P.S. debug is triggered from this line, so just put the word 'debug' on the command line and it will output more verbose debug info to the console.
https://github.com/whaleygeek/bitio/blob/master/src/microbit/__init__.py#L28
# Allow user to set debug flag on command line
if 'debug' in sys.argv:
DEBUG = True
I could connect using "screen" but I didn't see anything outgoing (but I imagine I need to push commands before)
thierry-laptop% python3 counter.py debug
Using path:/home/thierry/Dropbox/MixTeen/SoftShake2017/code/additional/microbit
Yay, I loaded the BITIO packaged pyserial
will reuse cache or scan for new port
No micro:bit has previously been detected
Scanning for serial ports
remove device, then press ENTER
scanning...
found 98 device(s)
plug in device, then press ENTER
scanning...
found 99 device(s)
found 1 new device
selected:/dev/ttyACM0
Do you want this device to be remembered? (Y/N)Y
connecting...
getting active serial port connection to micro:bit
warning:Could not open the serial port that was remembered from last time
Scanning for serial ports
remove micro:bit, then press ENTER
I have no portscan.cache file, nowhere...
I tried to add one with a simple touch portscan.cache
but after running counter.py, the file has been deleted
I wanted to understand what was wrong and I tried to launch counter.py from PyCharm and put a breakpoint in getSerial in init ... and it worked...
guess I need to learn pdb or other command line debugger to see what's different when I launch from my shell
Edit: arglll, you're hard with my novice skills : step into or put breakpoint in init of a module that is triggered at import... It's a bit too high for me :) Edit2: ok, I found usage of pdb.set_trace() inserted in init.py let's see
Woooooow, that is weird. I successfully used a breakpoint inside init.py and the program went smooth then. The problem is only when I run it in a normal way...
Perhaps you don't have create access to the folder where it is trying to store portscan.cache?
That file would normally be created in the same folder as the script (counter.py), although that does assume that the current working directory is there too.
I usually open a terminal and cd to the folder where counter.py is, and run it from there, to be sure that cwd is where you expect it to be.
What was the output from adding debug to the command line, in the failing case? Can you paste that here?
I managed to get it to work on Ubuntu 18.04 by adding a print statement telling me what the exceptions were.
First I had error 13 (PermissionError), which was fixed with:
sudo adduser zethg dialout
Then I had 16 (device or resource busy). This was because the built in dial up modem support was claiming the device. This was fixed with:
sudo apt-get purge modemmanager
(Note, don't do this if you need to use a real dial up modem.)
Hope that helps anyone that gets to this issue on Google as I did.
xx
Super, thanks @zeth this is great detective work!
Thanks Zeth, had the same issue and this sorted it right out. Cheers!
(Ubuntu 17.04, user added to dialout group) After flashing bitio.hex I launched counter.py but it loops through a cycle: