You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Error when a motor is left unused after program containing a function definition terminates #195
A very weird observation. I get the impression that if I have a program that includes a function definition AND the program does not use all the motors that have been declared then I get an error. If the function definition is not there: no error. If the motor(s) gets used: no error. What's going on? Simple (and pointless) example:
gives me no error:
from time import sleep
import ev3dev.ev3 as ev3
#m = ev3.LargeMotor('outB')
def myfunc():
sleep(2)
sleep(1)
gives me an error:
from time import sleep
import ev3dev.ev3 as ev3
m = ev3.LargeMotor('outB')
def myfunc():
sleep(2)
sleep(1)
no error:
from time import sleep
import ev3dev.ev3 as ev3
m = ev3.LargeMotor('outB')
def myfunc():
sleep(2)
sleep(1)
m.run_timed(duty_cycle_sp=-50, time_sp=1500)
sleep(5)
no error
from time import sleep
import ev3dev.ev3 as ev3
m = ev3.LargeMotor('outB')
sleep(1)
What is the error that is printed? I suspect that I know what is going on, so I should be able to take a look in half an hour. Also, can you use the "edit" button next to the title to give this issue a more descriptive name (e.g. "Error when a motor is left unused after program terminates")?
from time import sleep
import ev3dev.ev3 as ev3
m = ev3.LargeMotor('outB')
def myfunc():
sleep(2)
sleep(1)
I get
File "/usr/local/lib/python3.4/dist-packages/python_ev3dev-0.6.0-py3.4.egg/ev3dev/core.py", line 281, in del
File "/usr/local/lib/python3.4/dist-packages/python_ev3dev-0.6.0-py3.4.egg/ev3dev/core.py", line 730, in stop
File "/usr/local/lib/python3.4/dist-packages/python_ev3dev-0.6.0-py3.4.egg/ev3dev/core.py", line 295, in command
File "/usr/local/lib/python3.4/dist-packages/python_ev3dev-0.6.0-py3.4.egg/ev3dev/core.py", line 216, in set_attr_string
File "/usr/local/lib/python3.4/dist-packages/python_ev3dev-0.6.0-py3.4.egg/ev3dev/core.py", line 204, in _set_attribute
File "/usr/local/lib/python3.4/dist-packages/python_ev3dev-0.6.0-py3.4.egg/ev3dev/core.py", line 88, in write
File "/usr/local/lib/python3.4/dist-packages/python_ev3dev-0.6.0-py3.4.egg/ev3dev/core.py", line 74, in file_handle
NameError: name 'open' is not defined
Actually, this has already been fixed as it turns out. The problem is that the version of this library is a pretty old one, which was published before the changes were made to migrate to Python 3.
Can you check what ev3dev version you are running by looking under "About" in Brickman? If the "Kernel version" ends in -10-ev3dev-ev3, -11-ev3dev-ev3, -12-ev3dev-ev3, -13-ev3dev-ev3 or -14-ev3dev-ev3, you can get my changes (and all the others since the version of ev3dev-lang-python that you are using) by running sudo apt-get install python3-ev3dev. Then just make sure you are running your code with python3 instead of python.
If you are running an older version, this will be harder. Tell me if that's the case and we can figure it out.
Brickman About says I am using Brickman v0.7.2 and Kernel ...-9-ev3dev... so I am running sudo apt-get install python3-ev3dev and expecting many of my problems to disappear. I'm surprised my setup is so outdated because I only started using ev3dev a month ago. I assume I should run sudo apt-get install python3-ev3dev regularly so as to be sure of having the latest version?
Oops. I get an error when I run your sudo code (I tried thrice):
robot@ev3dev:$ sudo apt-get install python3-ev3dev
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following NEW packages will be installed:
python3-ev3dev
0 upgraded, 1 newly installed, 0 to remove and 108 not upgraded.
Need to get 27.1 kB of archives.
After this operation, 186 kB of additional disk space will be used.
Err http://ev3dev.org/debian/ jessie/main python3-ev3dev all 0.7.0rc1
Temporary failure resolving 'ev3dev.org'
E: Failed to fetch http://ev3dev.org/debian/pool/main/p/python-ev3dev/python3-ev3dev_0.7.0~rc1_all.deb Temporary failure resolving 'ev3dev.org'
E: Unable to fetch some archives, maybe run apt-get update or try with --fix-missing?
1.You need to be connected to the Internet and you need to run sudo apt-get update first.
2 python3-ev3dev will not work with -9-ev3dev kernel. Well, at least motors won't work right.
3. We have more up-to-date image files that have the most recent version of everything pre-installed here. We haven't been advertising them as the recommended image because of some serious issues. However, the 2016-09-04 image we just published yesterday is pretty good, I think - obviously it hasn't been widely tested yet.
I am sure that I have an SSH connection brick to PC and a working connection between the PC and internet. Is it possible to have both of these and yet not have a connection from the brick to the internet? I've restarted my SSH program (MobaXTerm) but still have the same problem. Can I assume that an easy way to check whether I have an internet connection to the brick is to runping "www.google.com" ? This gives me an error ping: unknown host www.google.com
Yes your test is valid. You can also goto "Wireless and Networks" on the brick itself. If it says Status: Online, then you have an Internet connection. If it just says Status: Connected, then you don't have an Internet connection.
Try restarting Internet Connection Sharing in Windows and reconnecting.
If it says 'Connected' it means I am NOT connected to the internet? This could be clearer!!!
Because I was having these problems while using a WiFi connection I re-established a USB connection. Right now my brick says I am Online via WiFi and Connected via USB. And the ping test does not work. What happens when one has more than one connection simultaneously? Bad idea?
I will try restarting Internet Connection Sharing in Windows and reconnecting.
Multiple connections at one time should be OK, however you will never get two connections "Online" at the same time. Disconnect the Wi-Fi if you want to try to get "Online" via USB.
I turned off internet sharing in the Windows control panel, then turned it back on again. Then I disconnected and reconnected on the brick and retrieved my internet connection at last. I ran
and everything went fine but About still says I have Kernel ...-9-ev3dev... as before. I rebooted the brick but still I have Kernel ...-9-ev3dev... Is there something I'm still missing?
Those commands upgraded the Python library, but ev3dev itself is still at the older version. To get a newer kernel, you can either re-flash your SD card with a recent nightly image as @dlech linked to (choose the one from yesterday here) or upgrade it in-place as follows:
sudo apt-get upgrade
sudo apt-get dist-upgrade
Warning: the latter option will preserve all your files, but it takes much longer (it could be 30 minutes to an hour). Re-flashing the card is the easiest.
You'll need to run sudo apt-get update before those. update downloads a list of the available packages so it knows what you can install.
Additionally, running sudo apt-get upgrade will upgrade all packages including python3-ev3dev, so you don't need the second line unless it is a new installation.
There's a "Subscribe via Atom" button at the top of our news page that you can use to get a link to our Atom feed (an Atom feed is very similar to an RSS feed, and supported by most RSS readers). If you have a news feed reader, that's a good way to keep track of when we do a new release, and by extension when you might want to upgrade. The news posts always include any warnings about breaking changes as well.
If you are the kind of person that doesn't mind reporting bugs every time something breaks, then yes upgrade everything. Otherwise, my suggestion would be to only upgrade if something is not working and you think that upgrading should fix it.
sudo apt-get upgrade upgrades all packages, whereas sudo apt-get install <package> will only install/upgrade a single package. So, for example to only upgrade the kernel, run sudo apt-get install linux-image-ev3dev-ev3. Also, you shouldn't upgrade without reading the announcements in the news section of the website. For example, by doing this you will find that you also need to upgrade the flash-kernel package when upgrading the kernel1.
Activity
WasabiFan commentedon Sep 4, 2016
What is the error that is printed? I suspect that I know what is going on, so I should be able to take a look in half an hour. Also, can you use the "edit" button next to the title to give this issue a more descriptive name (e.g. "Error when a motor is left unused after program terminates")?
Thanks for the bug report!
[-]Weird[/-][+]Error when a motor is left unused after program containing a function definition terminates[/+]ndward commentedon Sep 4, 2016
When I run this:
from time import sleep
import ev3dev.ev3 as ev3
m = ev3.LargeMotor('outB')
def myfunc():
sleep(2)
sleep(1)
I get
File "/usr/local/lib/python3.4/dist-packages/python_ev3dev-0.6.0-py3.4.egg/ev3dev/core.py", line 281, in del
File "/usr/local/lib/python3.4/dist-packages/python_ev3dev-0.6.0-py3.4.egg/ev3dev/core.py", line 730, in stop
File "/usr/local/lib/python3.4/dist-packages/python_ev3dev-0.6.0-py3.4.egg/ev3dev/core.py", line 295, in command
File "/usr/local/lib/python3.4/dist-packages/python_ev3dev-0.6.0-py3.4.egg/ev3dev/core.py", line 216, in set_attr_string
File "/usr/local/lib/python3.4/dist-packages/python_ev3dev-0.6.0-py3.4.egg/ev3dev/core.py", line 204, in _set_attribute
File "/usr/local/lib/python3.4/dist-packages/python_ev3dev-0.6.0-py3.4.egg/ev3dev/core.py", line 88, in write
File "/usr/local/lib/python3.4/dist-packages/python_ev3dev-0.6.0-py3.4.egg/ev3dev/core.py", line 74, in file_handle
NameError: name 'open' is not defined
WasabiFan commentedon Sep 4, 2016
Ah, yes; this is an easy fix. I'll fix it up now.
ndward commentedon Sep 4, 2016
Thanks! What do I have to do to benefit from your fix?
WasabiFan commentedon Sep 5, 2016
Actually, this has already been fixed as it turns out. The problem is that the version of this library is a pretty old one, which was published before the changes were made to migrate to Python 3.
Can you check what ev3dev version you are running by looking under "About" in Brickman? If the "Kernel version" ends in
-10-ev3dev-ev3,-11-ev3dev-ev3,-12-ev3dev-ev3,-13-ev3dev-ev3or-14-ev3dev-ev3, you can get my changes (and all the others since the version of ev3dev-lang-python that you are using) by runningsudo apt-get install python3-ev3dev. Then just make sure you are running your code withpython3instead ofpython.If you are running an older version, this will be harder. Tell me if that's the case and we can figure it out.
ndward commentedon Sep 5, 2016
Brickman About says I am using Brickman v0.7.2 and Kernel ...-9-ev3dev... so I am running
sudo apt-get install python3-ev3devand expecting many of my problems to disappear. I'm surprised my setup is so outdated because I only started using ev3dev a month ago. I assume I should runsudo apt-get install python3-ev3devregularly so as to be sure of having the latest version?Oops. I get an error when I run your sudo code (I tried thrice):
robot@ev3dev:
$ sudo apt-get install python3-ev3devrc1Reading package lists... Done
Building dependency tree
Reading state information... Done
The following NEW packages will be installed:
python3-ev3dev
0 upgraded, 1 newly installed, 0 to remove and 108 not upgraded.
Need to get 27.1 kB of archives.
After this operation, 186 kB of additional disk space will be used.
Err http://ev3dev.org/debian/ jessie/main python3-ev3dev all 0.7.0
Temporary failure resolving 'ev3dev.org'
E: Failed to fetch http://ev3dev.org/debian/pool/main/p/python-ev3dev/python3-ev3dev_0.7.0~rc1_all.deb Temporary failure resolving 'ev3dev.org'
E: Unable to fetch some archives, maybe run apt-get update or try with --fix-missing?
dlech commentedon Sep 5, 2016
1.You need to be connected to the Internet and you need to run
sudo apt-get updatefirst.2
python3-ev3devwill not work with-9-ev3devkernel. Well, at least motors won't work right.3. We have more up-to-date image files that have the most recent version of everything pre-installed here. We haven't been advertising them as the recommended image because of some serious issues. However, the
2016-09-04image we just published yesterday is pretty good, I think - obviously it hasn't been widely tested yet.ndward commentedon Sep 5, 2016
I am sure that I have an SSH connection brick to PC and a working connection between the PC and internet. Is it possible to have both of these and yet not have a connection from the brick to the internet? I've restarted my SSH program (MobaXTerm) but still have the same problem. Can I assume that an easy way to check whether I have an internet connection to the brick is to run
ping "www.google.com"? This gives me an errorping: unknown host www.google.comdlech commentedon Sep 5, 2016
Yes your test is valid. You can also goto "Wireless and Networks" on the brick itself. If it says
Status: Online, then you have an Internet connection. If it just saysStatus: Connected, then you don't have an Internet connection.Try restarting Internet Connection Sharing in Windows and reconnecting.
ndward commentedon Sep 5, 2016
If it says 'Connected' it means I am NOT connected to the internet? This could be clearer!!!
Because I was having these problems while using a WiFi connection I re-established a USB connection. Right now my brick says I am Online via WiFi and Connected via USB. And the ping test does not work. What happens when one has more than one connection simultaneously? Bad idea?
I will try restarting Internet Connection Sharing in Windows and reconnecting.
dlech commentedon Sep 5, 2016
File a new issue if you think it should be changed. (at https://github.com/ev3dev/ev3dev/issues)
dlech commentedon Sep 5, 2016
Multiple connections at one time should be OK, however you will never get two connections "Online" at the same time. Disconnect the Wi-Fi if you want to try to get "Online" via USB.
ndward commentedon Sep 5, 2016
I turned off internet sharing in the Windows control panel, then turned it back on again. Then I disconnected and reconnected on the brick and retrieved my internet connection at last. I ran
and everything went fine but About still says I have Kernel ...-9-ev3dev... as before. I rebooted the brick but still I have Kernel ...-9-ev3dev... Is there something I'm still missing?
WasabiFan commentedon Sep 5, 2016
Those commands upgraded the Python library, but ev3dev itself is still at the older version. To get a newer kernel, you can either re-flash your SD card with a recent nightly image as @dlech linked to (choose the one from yesterday here) or upgrade it in-place as follows:
Warning: the latter option will preserve all your files, but it takes much longer (it could be 30 minutes to an hour). Re-flashing the card is the easiest.
ndward commentedon Sep 5, 2016
Should I assume that to stay up to date I should regularly (monthly?) run those three commands (in this order)?
WasabiFan commentedon Sep 5, 2016
You'll need to run
sudo apt-get updatebefore those.updatedownloads a list of the available packages so it knows what you can install.Additionally, running
sudo apt-get upgradewill upgrade all packages includingpython3-ev3dev, so you don't need the second line unless it is a new installation.There's a "Subscribe via Atom" button at the top of our news page that you can use to get a link to our Atom feed (an Atom feed is very similar to an RSS feed, and supported by most RSS readers). If you have a news feed reader, that's a good way to keep track of when we do a new release, and by extension when you might want to upgrade. The news posts always include any warnings about breaking changes as well.
dlech commentedon Sep 5, 2016
If you are the kind of person that doesn't mind reporting bugs every time something breaks, then yes upgrade everything. Otherwise, my suggestion would be to only upgrade if something is not working and you think that upgrading should fix it.
sudo apt-get upgradeupgrades all packages, whereassudo apt-get install <package>will only install/upgrade a single package. So, for example to only upgrade the kernel, runsudo apt-get install linux-image-ev3dev-ev3. Also, you shouldn't upgrade without reading the announcements in the news section of the website. For example, by doing this you will find that you also need to upgrade theflash-kernelpackage when upgrading the kernel1.