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
pwm problem #16
Comments
this is just recently fixed problem: #14 |
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. |
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. |
@yorklai, what version of CHIP_IO are you using? What happens if you do the following from the Python shell: I'm running 0.2.1 and this isn't an issue. I believe @aninternetof fixed it yesterday for Issue#14. |
I try Pocketchip (4.3 firmware): Python 2.7.9 (default, Mar 1 2015, 13:48:22)
try SOFTPWM sample code: Python 2.7.9 (default, Mar 1 2015, 13:48:22)
2016-07-27 9:52 GMT+08:00 Robert Wolterman notifications@github.com:
|
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 C.H.I.P (4.4 Gui no limit firmware): chip@chip:~$ cd /sys 2016-07-27 19:54 GMT+08:00 York Lai york.star@gmail.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 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:
|
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 |
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. |
Dear Sir,
chip@chip:/etc/NetworkManager/system-connections$ sudo echo 415 > 2016-07-28 2:35 GMT+08:00 Brady Hurlburt notifications@github.com:
|
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? If that script runs correctly, you should be good to go. |
@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. |
Ok, I think I've got it. Would sometime mind looking over my commit in hotfix/SPWM_Issue_16? |
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? |
Will try to test your hotfix when I can, might not be able to get to it tonight though. |
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. :-)
|
Oh, I guess I already added that script to the repo. Named "unexport_all.sh", it is in the parent directory. |
A script like that works for me! It's probably a good middle-ground. |
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. |
Very Thanks! I try last version is no any error message! chip@chip:~$ sudo python
|
i use 4.4 or 4.3 firmware:
I follow your sample will found error:
The text was updated successfully, but these errors were encountered: