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
ev3dev2.sound does not support micropython. This is an issue because audio keys are useful while testing. For now I can use the following to make the robot beep.
import os
os.system("/usr/bin/beep")
However it would be nice to have support. I found that what is breaking the module is from subprocess import check_output, Popen, PIPE.
It sounds like you should be able to replace the subprocess calls with os.fork() or os.system() calls. If you want to work on it assign this issue to yourself (or if you can't let me know and I can assign it to you).
I had an experiment project, to improve ev3dev2 support in Micropython.
You guys can try it if you are interested. I am not familiar with the Debian Packaging stuff, so this would require some hands on compiling.
@JunOllyLi wow you have made a lot of progress!! Have you thought about submitting pull requests for the changes you have made to the various repos? It would be nice to pull your work in and have sound, buttons and LEDs all working in micropython for ev3dev-lang-python.
Yeah, @JunOllyLi we'd love to accept these changes into the official repos if you're interested. I haven't looked through it in depth, but I expect we'd be open to merging pretty much all of it. We'd really love the help for improved uPy support!
Would love to, but if you looked at my changes, mostly they are in micropyton-lib and evdev. There only two very small quick hacks in ev3dev2, which I am not even satisfied although they work. At lease one of the changes should be fixed later with better PCRE implementation in Micropython-lib.
The change in evdev is a total re-written C code in Micropython module style, not going to be compatible with CPython code at all. Not sure if evdev guys would like to take it.
Some of the changes in Micropython-lib probably makes sense to get merged back. But I would need more time to make them better. I am not a Python programmer, and the changes I made was just to "make ev3dev2 work", and not totally compliant with the CPython API definitions. I know I have skipped a lot of potential parameters in those functions.
I only looked over your changes briefly, so I can't say for sure what parts are doable and what aren't. We do ship our own fork of micropython-lib with ev3dev, so that could probably be updated. Or, just include them in our own library source.
The evdev library is a bit of a different story, but I'd be interested in looking at the options there... Depending on the changes you made we might be able to emulate them via Python or ship the native code in some reasonable container, maybe as a separate package.
Once a few PRs go in the main feature we will be missing that is in @JunOllyLi 's library is Button support. dlech had that working here so I don't think we are too far off from having pretty good micropython support without have to touch ev3dev, micropython-lib, or micropython.
I only looked over your changes briefly, so I can't say for sure what parts are doable and what aren't. We do ship our own fork of micropython-lib with ev3dev, so that could probably be updated. Or, just include them in our own library source.
The evdev library is a bit of a different story, but I'd be interested in looking at the options there... Depending on the changes you made we might be able to emulate them via Python or ship the native code in some reasonable container, maybe as a separate package.
Yes, I don't see any problem to implement that in Python. I was just too lazy to do that. It requires a couple of IOCTLs, and what needed is to get the bit definition of the IOCTL numbers ported from C to Python, and pack/unpack the C structures used in those IOCTLs. I just took the shortcut and used what already defined in C. As I said, I am not a Python programmer, C is more my type. :)
@staadecker we'd love some help testing! The easiest way to test it is to clone the repository and add it to your PATH so that it overrides the system-installed version. This should do it:
$ cd ~/
$ git clone https://github.com/ev3dev/ev3dev-lang-python.git
$ export PATH=~/ev3dev-lang-python/
The last line only applies within your current terminal session; if you'd like it to be permanent you can add the line to your ~/.bashrc. But you should test it once first to make sure I didn't mess up the commands.
If you confirm, I'll update #611 and merge that, then probably do a release soon. If you're up for it, you can also test out other things we've recently added tagged "micropython".
@WasabiFan I am pretty close on being done with #571 , I have it working (I pulled in dlech's code) it just needs some cleanup of some duplicated code between the Button classes for python3 vs the Button classes for micropython. I would like to get that one one before we do a release. We have so much working in micropython now I am using it more and more.
@staadecker we'd love some help testing! The easiest way to test it is to clone the repository and add it to your PATH so that it overrides the system-installed version. This should do it:
$ cd ~/
$ git clone https://github.com/ev3dev/ev3dev-lang-python.git
$ export PATH=~/ev3dev-lang-python/
The last line only applies within your current terminal session; if you'd like it to be permanent you can add the line to your ~/.bashrc. But you should test it once first to make sure I didn't mess up the commands.
If you confirm, I'll update #611 and merge that, then probably do a release soon. If you're up for it, you can also test out other things we've recently added tagged "micropython".
@WasabiFan. I tried testing it today. I was able to clone the repo into the home folder. I can use the repo in python3 no problem using export PYTHONPATH=~/ev3dev-lang-python/. However, micropython is unable to find the package and using PATH` doesn't work either.
Activity
dwalton76 commentedon May 10, 2019
yeah the issue is with Sound.py using subprocess...I was reading this:
https://forum.micropython.org/viewtopic.php?t=5055
It sounds like you should be able to replace the subprocess calls with
os.fork()oros.system()calls. If you want to work on it assign this issue to yourself (or if you can't let me know and I can assign it to you).staadecker commentedon May 11, 2019
Unfortunately, this is really not my area of expertise. I'm confused when looking at the code. For now I will use
os.system("/usr/bin/beep")JunOllyLi commentedon May 12, 2019
I had an experiment project, to improve ev3dev2 support in Micropython.
You guys can try it if you are interested. I am not familiar with the Debian Packaging stuff, so this would require some hands on compiling.
https://github.com/robosaurus-ev3dev2-upy/upy-ev3dev2
So far I tested LEDs, sound, buttons and they work. And of course the motors and external sensors were already supported.
dwalton76 commentedon May 12, 2019
I'll take a stab at it
dwalton76 commentedon May 12, 2019
@JunOllyLi wow you have made a lot of progress!! Have you thought about submitting pull requests for the changes you have made to the various repos? It would be nice to pull your work in and have sound, buttons and LEDs all working in micropython for ev3dev-lang-python.
WasabiFan commentedon May 13, 2019
Yeah, @JunOllyLi we'd love to accept these changes into the official repos if you're interested. I haven't looked through it in depth, but I expect we'd be open to merging pretty much all of it. We'd really love the help for improved uPy support!
JunOllyLi commentedon May 13, 2019
Would love to, but if you looked at my changes, mostly they are in micropyton-lib and evdev. There only two very small quick hacks in ev3dev2, which I am not even satisfied although they work. At lease one of the changes should be fixed later with better PCRE implementation in Micropython-lib.
The change in evdev is a total re-written C code in Micropython module style, not going to be compatible with CPython code at all. Not sure if evdev guys would like to take it.
Some of the changes in Micropython-lib probably makes sense to get merged back. But I would need more time to make them better. I am not a Python programmer, and the changes I made was just to "make ev3dev2 work", and not totally compliant with the CPython API definitions. I know I have skipped a lot of potential parameters in those functions.
WasabiFan commentedon May 13, 2019
I only looked over your changes briefly, so I can't say for sure what parts are doable and what aren't. We do ship our own fork of micropython-lib with ev3dev, so that could probably be updated. Or, just include them in our own library source.
The evdev library is a bit of a different story, but I'd be interested in looking at the options there... Depending on the changes you made we might be able to emulate them via Python or ship the native code in some reasonable container, maybe as a separate package.
dwalton76 commentedon May 13, 2019
Once a few PRs go in the main feature we will be missing that is in @JunOllyLi 's library is Button support. dlech had that working here so I don't think we are too far off from having pretty good micropython support without have to touch ev3dev, micropython-lib, or micropython.
JunOllyLi commentedon May 14, 2019
Yes, I don't see any problem to implement that in Python. I was just too lazy to do that. It requires a couple of IOCTLs, and what needed is to get the bit definition of the IOCTL numbers ported from C to Python, and pack/unpack the C structures used in those IOCTLs. I just took the shortcut and used what already defined in C. As I said, I am not a Python programmer, C is more my type. :)
dwalton76 commentedon May 19, 2019
@staadecker FYI Sound will work with micropython now
staadecker commentedon May 19, 2019
@dwalton76 thank you! How can I use the latest unreleased code on the EV3. Is the repo already cloned and I just need to pull to get the updates?
WasabiFan commentedon May 20, 2019
@staadecker we'd love some help testing! The easiest way to test it is to clone the repository and add it to your PATH so that it overrides the system-installed version. This should do it:
The last line only applies within your current terminal session; if you'd like it to be permanent you can add the line to your
~/.bashrc. But you should test it once first to make sure I didn't mess up the commands.If you confirm, I'll update #611 and merge that, then probably do a release soon. If you're up for it, you can also test out other things we've recently added tagged "micropython".
dwalton76 commentedon May 20, 2019
@WasabiFan I am pretty close on being done with #571 , I have it working (I pulled in dlech's code) it just needs some cleanup of some duplicated code between the Button classes for python3 vs the Button classes for micropython. I would like to get that one one before we do a release. We have so much working in micropython now I am using it more and more.
WasabiFan commentedon May 20, 2019
Damn, nice! I wasn't expecting buttons to get working that fast. This sounds good to me; I'll wait until the buttons are merged.
staadecker commentedon May 30, 2019
@WasabiFan. I tried testing it today. I was able to clone the repo into the home folder. I can use the repo in python3 no problem using
export PYTHONPATH=~/ev3dev-lang-python/. However, micropython is unable to find the package and usingPATH` doesn't work either.micropython support for Sound (ev3dev#632)