Python Documentation

9 years 2 months ago #29529021 by Guy
Python Documentation was created by Guy
Hi,

Just wanted to ask if there is any detailed information yet regarding the Python implementation for the RIO. Any help or exampleswould be appreciated.

Many Thanks

Guy Halligan
The following user(s) said Thank You: joyabraham

Please Log in or Create an account to join the conversation.

9 years 2 months ago #29529024 by opal
Replied by opal on topic Python Documentation
Hello Guy,

Please take a look at file rioboard_test.py and RioBoard.h provided along with the rest of RIO software.

The first one is an example of how to call Python bundle functions from RIO library. The second one (C-header file) contains definitions for all functions the library provides, with some comments.

If this information was not enough don't hesitate to drop another messages here with more detailed question, like describing what exactly are you having trouble to find.

Regards

Please Log in or Create an account to join the conversation.

9 years 1 month ago #29529117 by QuiXXotic
Replied by QuiXXotic on topic Python Documentation
Ive only worked with c sofar but am interested in trying out python. But im unsure of how to install the module "rioboard" you need to import without a setup.py or having a zip/tar for the module.

Please Log in or Create an account to join the conversation.

9 years 1 month ago #29529121 by opal
Replied by opal on topic Python Documentation
It should be installed by default. It is a part of Rio Board software bundle.

Just try:
#import rioboard
from your Python console.

Please Log in or Create an account to join the conversation.

9 years 1 month ago - 9 years 1 month ago #29529122 by QuiXXotic
Replied by QuiXXotic on topic Python Documentation
Well i might be completly wrong here but doesnt
#import rioboard

do nothing? Is it not just a comment with that hashtag?
import rioboard

Returns:
Traceback (most recent call last) :
   File "<pyshell#1>, line 1, in <module>
      import rioboard
ImportError: No module named rioboard

Running the rioboard_test.py gives an syntax error calling the first function (rioboard.Init()) but it doesnt complain on the module import.

This is done on e fresh install with your recommended files ive got from you in recent discussion. All ive done before trying this is running the rioboard_test

Also ive tried in both Python 2.7.3 and Python 3.2.3

Please Log in or Create an account to join the conversation.

9 years 1 month ago - 9 years 1 month ago #29529127 by opal
Replied by opal on topic Python Documentation

QuiXXotic wrote: Well i might be completly wrong here but doesnt

#import rioboard

do nothing? Is it not just a comment with that hashtag?

You are right, sorry for the typo.

import rioboard

Returns:
Traceback (most recent call last) :
   File "<pyshell#1>, line 1, in <module>
      import rioboard
ImportError: No module named rioboard

Running the rioboard_test.py gives an syntax error calling the first function (rioboard.Init()) but it doesnt complain on the module import.

This is done on e fresh install with your recommended files ive got from you in recent discussion. All ive done before trying this is running the rioboard_test

Also ive tried in both Python 2.7.3 and Python 3.2.3

Please try starting the Python shell from the "/riofiles" directory to find out if it is the reason.

Alternatively modify sys.path for your Python installation adding "/riofiles" to it:
export PYTHONPATH=$PYTHONPATH:/riofiles
After this import should work from any directory.

We will add this to future versions of RIO Board software update script.

Please Log in or Create an account to join the conversation.

9 years 1 month ago #29529132 by QuiXXotic
Replied by QuiXXotic on topic Python Documentation
Ok! that made it work kind of. Can i put that export command into the startup script since now i have to type it in everytime ive rebooted?

After second reboot since rioboard installation the daemon now starts to mess up again it seems. I see the starting script during bootup but when i start the C rioboard_test it complains about the shared memory. So i move into
/etc/init.d
and start the script
./rioboard_d start

Then i start the C rioboard_test and it seems to work. Then i stop it and start the python rioboard_test.py
python /riofiles/raspio-src/rioboard_test.py
and get some errors.
Test_CallEachFn: Calling init() ...
DBG: RioBoard Shared Memory ID=32769; Run "ipcs -m" command to verify
DBG: RioBoard Shared Memory segment attached to process at [0xb6f67000]
Test_CallEachFn: Calling SetPWMChannel() ...
Traceback (most recent call last):
   File "/riofiles/raspio-src/rioboard_test.py", line 29, in <module>
      Test_CallEachFn()
   File "/riofiles/raspio-src/rioboard_test.py", line 7, in Test_CallEachFn
      rioboard.SetPWMChannel(0,1)
AttributeError: ´module´object has no attribute ´SetPWMChanell`

I removed SetPWMChannel from the test program just to see what happened:
Test_CallEachFn: Calling init() ...
DBG: RioBoard Shared Memory ID=32769; Run "ipcs -m" command to verify
DBG: RioBoard Shared Memory segment attached to process at [0xb6f66000]
Test_CallEachFn: Calling ResetDigitalOutput() ...
Test_CallEachFn: Calling SetDigitalOutput() ...
Test_CallEachFn: Calling WriteDigitalInput() ...
Traceback (most recent call last):
   File "/riofiles/raspio-src/rioboard_test.py", line 29, in <module>
      Test_CallEachFn()
   File "/riofiles/raspio-src/rioboard_test.py", line 13, in Test_CallEachFn
      rioboard.WriteDigitalInput(0,1)
AttributeError: ´module´object has no attribute ´WriteDigitalInput`


Do i mess up with the sudo rights or why doesnt anything work as it should? :S

Please Log in or Create an account to join the conversation.

9 years 1 month ago - 9 years 1 month ago #29529141 by opal
Replied by opal on topic Python Documentation

QuiXXotic wrote: Ok! that made it work kind of. Can i put that export command into the startup script since now i have to type it in everytime ive rebooted?

Yes - keep it in startup script.

QuiXXotic wrote: After second reboot since rioboard installation the daemon now starts to mess up again it seems. I see the starting script during bootup but when i start the C rioboard_test it complains about the shared memory. So i move into

/etc/init.d
and start the script
./rioboard_d start

Then i start the C rioboard_test and it seems to work. Then i stop it and start the python rioboard_test.py
python /riofiles/raspio-src/rioboard_test.py
and get some errors.
Test_CallEachFn: Calling init() ...
DBG: RioBoard Shared Memory ID=32769; Run "ipcs -m" command to verify
DBG: RioBoard Shared Memory segment attached to process at [0xb6f67000]
Test_CallEachFn: Calling SetPWMChannel() ...
Traceback (most recent call last):
   File "/riofiles/raspio-src/rioboard_test.py", line 29, in <module>
      Test_CallEachFn()
   File "/riofiles/raspio-src/rioboard_test.py", line 7, in Test_CallEachFn
      rioboard.SetPWMChannel(0,1)
AttributeError: ´module´object has no attribute ´SetPWMChanell`

You seem to have an obsolete Python test file. Please try the attached one:

File Attachment:

File Name: rioboard_test.zip
File Size:0 KB


Sorry for the confusion - we are working hard to bring update scripts, documentation and tests up to date. Please let us know if the attached script worked for you.
Attachments:

Please Log in or Create an account to join the conversation.

9 years 1 month ago #29529143 by QuiXXotic
Replied by QuiXXotic on topic Python Documentation
Yes it called each function and it reached called each function: Done!

Im not 100% sure how and where to add that
export PYTHONPATH=$PYTHONPATH./riofiles
too happen during bootup. Seems to be alot of different ways. Ive added it in rc.local and in the daemon_d script in /etc/init.d but it doesnt seem to cut it. I might not using the right location for export command (since we are root) Well the daemon_d script doesnt start the daemon either since i always have to start it manually after login.

this is what wish to do since the daemon isnt starting as it should and the pythonpath arent permanently added.
1)autologin
2)export pythonpath
3)start rioboard daemon
4)start a.py script

I hoped to only need to solve the autologin and start a script problem.

Looking forward to updated files and documentation. Really want to get this to work. We would like to use this product for a serialproduced product.

Please Log in or Create an account to join the conversation.

9 years 1 month ago #29529146 by opal
Replied by opal on topic Python Documentation
For "autostart" please specify the exact Linux distributive you are using. There are several ways to do that. Most of them depend on "startup manager" your distributive employs.

To figure out the distributive details please execute:
cat /etc/*-release
and provide the returned result.

About your intention to use Rio Board in your product - this is an exciting news. From our side we will do our best to simplify/speedup your work.

Please Log in or Create an account to join the conversation.

Moderators: opal
Time to create page: 0.088 seconds