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

can't set serial port #20

Open
titimoby opened this issue Oct 26, 2017 · 10 comments
Open

can't set serial port #20

titimoby opened this issue Oct 26, 2017 · 10 comments

Comments

@titimoby
Copy link

titimoby commented Oct 26, 2017

(Ubuntu 17.04, user added to dialout group)
After flashing bitio.hex I launched counter.py but it loops through a cycle:

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...
warning:Could not open the serial port that was remembered from last time
Scanning for serial ports
remove micro:bit, then press ENTER
scanning...
found 98 micro:bit(s)
plug in micro:bit, then press ENTER
scanning...
found 99 micro:bit(s)
found 1 new micro:bit
selected:/dev/ttyACM0
Do you want this micro:bit to be remembered? (Y/N)Y
warning:Could not open the serial port that was remembered from last time
Scanning for serial ports
remove micro:bit, then press ENTER
scanning...
found 98 micro:bit(s)
plug in micro:bit, then press ENTER
scanning...
found 99 micro:bit(s)
found 1 new micro:bit
selected:/dev/ttyACM0
Do you want this micro:bit to be remembered? (Y/N)Y
warning:Could not open the serial port that was remembered from last time
Scanning for serial ports
remove micro:bit, then press ENTER

@whaleygeek
Copy link
Owner

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

@whaleygeek
Copy link
Owner

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

@titimoby
Copy link
Author

titimoby commented Oct 26, 2017

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

@titimoby
Copy link
Author

titimoby commented Oct 26, 2017

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

@titimoby
Copy link
Author

titimoby commented Oct 26, 2017

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

@titimoby
Copy link
Author

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...

@whaleygeek
Copy link
Owner

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?

@zeth
Copy link

zeth commented Sep 16, 2018

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

@DavidWhaleMEF
Copy link

Super, thanks @zeth this is great detective work!

@thebotmakes
Copy link

Thanks Zeth, had the same issue and this sorted it right out. Cheers!

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

5 participants