Hi
From APL, I am controlling some servos via commands like:
⎕SH 'echo 17=50% > /dev/servoblaster'
from within Dyalog APL. This is working fine.
(It sends a PWM signal of 50% to pin 17, I think.)
And I would like to use somthing like:
'/dev/servoblaster' ⎕ARBOUT '17=50%'
as this would I expect be VERY much quicker.
First: Should this work?
(And could I read the pins via ⎕ARBIN?)
Second: I tried it but the raspberry pi tells me I don't have permission.
I started up dyalog via
$sudo startx
and then selected Dyalog from the programming languages.
Any body got any ideas why I can write to /dev/servoblaster via "echo" but not ⎕ARBOUT?
(If I run "startx" without the sudo, even the echo process fails!)
Thanks for any suggestions.
Ray
Accessing GPIO pins on Raspberry Pi via ARBOUT
Accessing GPIO pins on Raspberry Pi via ARBOUT
Ray Cannon
Please excuse any smelling pisstakes.
Please excuse any smelling pisstakes.
Re: Accessing GPIO pins on Raspberry Pi via ARBOUT
I can now write to the GPIO pins using ⎕ARBOUT.
The command to send "out" to pin 7 direction
$ echo out > /sys/class/gpio/gpio7/direction
can be sent by APL as
'/sys/class/gpio/gpio7/direction' ⎕ARBOUT (⎕UCS 'out'),10
The command to read pin 7 when "in" direction
$cat /sys/class/gpio/gpio7/direction
can de done in APL via
('' '/sys/class/gpio/gpio7/direction')⎕ARBIN ''
Question: How can I reset the nominal file pointer counter back to the first character after a ARBIN "read"?
(As there are no interrupts triggered by pin changing states, I need to read and reread the "file" in a loop
("lseek" comes to mind).
The command to send "out" to pin 7 direction
$ echo out > /sys/class/gpio/gpio7/direction
can be sent by APL as
'/sys/class/gpio/gpio7/direction' ⎕ARBOUT (⎕UCS 'out'),10
The command to read pin 7 when "in" direction
$cat /sys/class/gpio/gpio7/direction
can de done in APL via
('' '/sys/class/gpio/gpio7/direction')⎕ARBIN ''
Question: How can I reset the nominal file pointer counter back to the first character after a ARBIN "read"?
(As there are no interrupts triggered by pin changing states, I need to read and reread the "file" in a loop
("lseek" comes to mind).
Ray Cannon
Please excuse any smelling pisstakes.
Please excuse any smelling pisstakes.
-
- Posts: 439
- Joined: Wed Oct 01, 2008 9:39 am
Re: Accessing GPIO pins on Raspberry Pi via ARBOUT
Hi Ray,
lseek sounds right if it's a seekable device.
Regards,
Vince
lseek sounds right if it's a seekable device.
Regards,
Vince