Comments (20)
@fordsfords, thanks! I need to add pretty much exactly that same get_err_msg() code to my py_softpwm.c file. That would have made @yorklai's problem much more easily identifiable. I'll try to commit that sometime today.
from chip_io.
Will try to test your hotfix when I can, might not be able to get to it tonight though.
from chip_io.
this is just recently fixed problem: #14
from chip_io.
Well, I didn't verify in my spwmtest.py script of changing the duty cycle that way, so there could still be an issue. Will try to look this over tonight.
from chip_io.
Let me know what you find if you check it out tonight, @xtacocorex. I didn't retest that case either, but it can look at it tomorrow morning if it is indeed a legit bug.
from chip_io.
@yorklai, what version of CHIP_IO are you using?
What happens if you do the following from the Python shell:
import CHIP_IO.GPIO as GPIO
print GPIO.VERSION
I'm running 0.2.1 and this isn't an issue. I believe @aninternetof fixed it yesterday for Issue#14.
from chip_io.
I try Pocketchip (4.3 firmware):
Python 2.7.9 (default, Mar 1 2015, 13:48:22)
[GCC 4.9.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
import CHIP_IO.GPIO as GPIO
print GPIO.VERSION
0.2.1
try SOFTPWM sample code:
Python 2.7.9 (default, Mar 1 2015, 13:48:22)
[GCC 4.9.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
import CHIP_IO.SOFTPWM as SPWM
SPWM.start("XIO-P7", 50)
SPWM.set_duty_cycle("XIO-P7", 25.5)Traceback (most recent call last):
File "", line 1, in
RuntimeError: You must start() the PWM channel first
2016-07-27 9:52 GMT+08:00 Robert Wolterman [email protected]:
@yorklai https://github.com/yorklai, what version of CHIP_IO are you
using?What happens if you do the following from the Python shell:
import CHIP_IO.GPIO as GPIO
print GPIO.VERSIONI'm running 0.2.1 and this isn't an issue. I believe @aninternetof
https://github.com/aninternetof fixed it yesterday for Issue#14.—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
#16 (comment),
or mute the thread
https://github.com/notifications/unsubscribe-auth/ALzCrr-aENS8kpSbocFt7b0GENKl9zNCks5qZrnXgaJpZM4JVRnM
.
from chip_io.
The C.H.I.P 4.4 firmware (any) have bug:
Pocketchip(4.3 firmware):
chip@chip:/sys/class/pwm/pwmchip0$ lsdevice export npwm power
subsystem uevent unexport
chip@chip:/sys/class/pwm/pwmchip0$
C.H.I.P (4.4 Gui no limit firmware):
chip@chip:~$ cd /sys
chip@chip:/sys$ cd class
chip@chip:/sys/class$ cd pwm
chip@chip:/sys/class/pwm$ ls
chip@chip:/sys/class/pwm$ ls -l
total 0
chip@chip:/sys/class/pwm$
2016-07-27 19:54 GMT+08:00 York Lai [email protected]:
I try Pocketchip (4.3 firmware):
Python 2.7.9 (default, Mar 1 2015, 13:48:22)
[GCC 4.9.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.import CHIP_IO.GPIO as GPIO
print GPIO.VERSION
0.2.1try SOFTPWM sample code:
Python 2.7.9 (default, Mar 1 2015, 13:48:22)
[GCC 4.9.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.import CHIP_IO.SOFTPWM as SPWM
SPWM.start("XIO-P7", 50)
SPWM.set_duty_cycle("XIO-P7", 25.5)Traceback (most recent call last):
File "", line 1, in
RuntimeError: You must start() the PWM channel first2016-07-27 9:52 GMT+08:00 Robert Wolterman [email protected]:
@yorklai https://github.com/yorklai, what version of CHIP_IO are you
using?What happens if you do the following from the Python shell:
import CHIP_IO.GPIO as GPIO
print GPIO.VERSIONI'm running 0.2.1 and this isn't an issue. I believe @aninternetof
https://github.com/aninternetof fixed it yesterday for Issue#14.—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
#16 (comment),
or mute the thread
https://github.com/notifications/unsubscribe-auth/ALzCrr-aENS8kpSbocFt7b0GENKl9zNCks5qZrnXgaJpZM4JVRnM
.
from chip_io.
@yorklai, regarding the "RuntimeError: You must start() the PWM channel first", I think I've figured out what is going on.
If you first tried with the old version of CHIP_IO (v0.1.1), then you hit a bug and the code exited. When it did this, it left the GPIO exported, because SPWM.cleanup() was never called.
So now when you try to run with the fixed code, the command SPWM.start("XIO-P7", 50)
seems like it is running successfully, but it is failing to add XIO-P7 to the list of running PWMs because the gpio has already been exported. Then when SPWM looks for it on the list of running PWMS, it can't find it and throws the RuntimeError.
I'll work on a commit that makes SPWM.start() throw an error instead of failing silently if the gpio has already been exported. To fix your problem you'll need to:
sudo echo 415 > /sys/class/gpio/unexport
- Try your code again. Make sure to add SPWM.cleanup() to the end of your test script.
from chip_io.
Ok, if the GPIO is already exported, it looks like it fails here, as it should.
@xtacocorex, I'm not super familiar with the error system. Does that add_error_msg
print or log to somewhere?
from chip_io.
I can answer that one. It adds text to a global string buffer (error_msg_buff). It is a way that a descriptive error message can be passed back up to the python layer. So some utility function several layers down can detect a problem and add some text to that buffer. It returns an error, and its caller might add some more text to give it context (i.e. what it was trying to do when it call the lower-level function which detected the error), and that caller returns an error. And so on, until it makes it to the C code which interfaces with python. At that point, a final error message string is formatted and passed back to Python, using get_error_msg(). For example, in py_gpio.c the function "static PyObject *py_setup_channel(..." contains the code:
if (gpio_export(gpio) < 0) { char err[2000]; snprintf(err, sizeof(err), "Error setting up channel %s, maybe already exported? (%s)", channel, get_error_msg()); PyErr_SetString(PyExc_RuntimeError, err); return NULL; }
The built-up error message is included in parentheses.
from chip_io.
Dear Sir,
I boot pocket (4.3 firmware) then try:
chip@chip:/etc/NetworkManager/system-connections$ sudo echo 415 >
/sys/class/gpio/unexport
-bash: /sys/class/gpio/unexport: Permission denied
chip@chip:/etc/NetworkManager/system-connections$
chip@chip:/etc/NetworkManager/system-connections$ sudo su
root@chip:/etc/NetworkManager/system-connections# sudo echo 415 >
/sys/class/gpio/unexportecho: write error: Invalid argument
2016-07-28 2:35 GMT+08:00 Brady Hurlburt [email protected]:
@yorklai https://github.com/yorklai, regarding the "RuntimeError: You
must start() the PWM channel first", I think I've figured out what is going
on.If you first tried with the old version of CHIP_IO (v0.1.1), then you hit
a bug and the code exited. When it did this, it left the GPIO exported,
because SPWM.cleanup() was never called.So now when you try to run with the fixed code, the command SPWM.start("XIO-P7",
50) seems like it is running successfully, but it is failing to add
XIO-P7 to the list of running PWMs because the gpio has already been
exported. Then when SPWM looks for it on the list of running PWMS, it can't
find it and throws the RuntimeError.I'll work on a commit that makes SPWM.start() throw an error instead of
failing silently if the gpio has already been exported. To fix your problem
you'll need to:
- sudo echo 415 > /sys/class/gpio/unexport
- Try your code again. Make sure to add SPWM.cleanup() to the end of
your test script.—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
#16 (comment),
or mute the thread
https://github.com/notifications/unsubscribe-auth/ALzCrkXKRF_B1vWBxMLDD_czymsyUVSbks5qZ6UBgaJpZM4JVRnM
.
from chip_io.
When you did the sudo su, you got root access. sudo doesn't work when you're root.
Have you tried rebooting since you pulled the latest CHIP_IO code?
What happens if you do run spwmtest.py from within the test directory? You need a test wire hooked between XIO-P7 and CSID0 for that to run.
If that script runs correctly, you should be good to go.
from chip_io.
Ok, I think I've got it. Would sometime mind looking over my commit in hotfix/SPWM_Issue_16?
from chip_io.
For this kind of situation, have we considered having a cleanup_all() function to unexport all GPIO, instead of just the ones registered in CHIP_IO's currently exported list?
It would be a somewhat powerful/dangerous function, but during development it's not uncommon to exit your script before reaching the cleanup(), and then you're left with stranded GPIO that you have to manually unexport before trying your script again.
from chip_io.
Can I reply to this email?
I just wrote a simple shell script to close everything. I don't think a close all in the GPIO library is a good idea. But I won't object if I am out-voted. :-)
On Jul 28, 2016, at 7:58 AM, Brady Hurlburt [email protected] wrote:
For this kind of situation, have we considered having a cleanup_all() function to unexport all GPIO, instead of just the ones registered in CHIP_IO's currently exported list?
It would be a somewhat powerful/dangerous function, but during development it's not uncommon to exit your script before reaching the cleanup(), and then you're left with stranded GPIO that you have to manually unexport before trying your script again.—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub, or mute the thread.
from chip_io.
Oh, I guess I already added that script to the repo. Named "unexport_all.sh", it is in the parent directory.
from chip_io.
A script like that works for me! It's probably a good middle-ground.
from chip_io.
Just tested with by exporting a GPIO and then trying to start SPWM on it. Error messages are displayed. I updated the spwmtest.py to check for this issue. Will commit spwmtest.py, update the version/changelog stuff, then merge to master.
from chip_io.
Very Thanks! I try last version is no any error message!
chip@chip:~$ sudo python
Python 2.7.9 (default, Mar 1 2015, 13:48:22)
[GCC 4.9.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
import CHIP_IO.SOFTPWM as SPWM
print SPWM.VERSION
0.2.2
SPWM.start("XIO-P7", 50)
SPWM.set_duty_cycle("XIO-P7", 25.5)
SPWM.set_frequency("XIO-P7", 10)
SPWM.stop("XIO-P7")
SPWM.cleanup()
SPWM.start("XIO-P7", 50, 2000, 1)
from chip_io.
Related Issues (20)
- adding callback functions on any pin that supports edge detection not work HOT 8
- setup doesn't work twice HOT 6
- Per PWM Cleanup
- Think about ability to specify GPIO number for all functions
- Investigate SBC determination using model number in the device tree HOT 2
- CHIP_IO low-level library for using in other scripting languages HOT 1
- Allow callback functionality for PWM1, I2S-MCLK, and I2S-DI on the CHIP Pro
- Edge/Interrupt detection on the C.H.I.P. Pro HOT 9
- bounce time HOT 1
- Could not open GPIO 1015 value file HOT 2
- Verify module level documentation
- Create API Documentation HOT 1
- wait_for_edge() timeout
- Adding error catching for pins in event_gpio.c that are being used by the system while in debug mode
- binary wheel pypi package? HOT 2
- gpio_export: something went wrong: No such file or directory HOT 5
- Cleanup Servo code to leverage SoftPWM as a basis HOT 1
- Intermittent GPIO RuntimeError
- Segmentation fault HOT 2
- No signs of life with Servo
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from chip_io.