Hi Romily
I have used ⎕ARBIN and ⎕ARBOUT to "talk" to the GPIO pins on the Raspberry Pi.
I no longer use ⎕ARBIN as I found that ⎕NREAD can be used instead.
Using ⎕ARBOUT has changed since Dyalog 14.0(?).
It used to take a file name (such as '/sys/class/gpio/gpio2/direction'
and '/sys/class/gpio/gpio2/value' when talking to GPIO pin 2.
With Dyalog 14.1, ⎕ARBOUT now takes a file tie number.
So my code uses this cover function:
Code: Select all
fid ARBOUT data;names;bos;tie
⍝ Cover function for ⎕ARBOUT
names←(↓⎕NNAMES)~¨' '
bos←names∊⊂fid
:If ~∨/bos
tie←fid ⎕NTIE 0
:Else
tie←⊃bos/⎕NNUMS
:End
tie ⎕ARBOUT data
I use ⎕UCS to convert the "text" into bytes suitable for ⎕ARBOUT.
An example of it in use:
Code: Select all
∇ pin Move_servo pcent
⍝ Writes to one of the pins controlling the servers
⍝ This code is approximately equivalent to:
⍝ ⎕SH'echo ',pin,'=',(⍕pcent),'% > /dev/servoblaster'
'/dev/servoblaster'ARBOUT pin,61,(⎕UCS⍕pcent),37 10
⍝ where '='≡61 '0'≡48 '1'≡49...'%'≡37 '10'≡<Linefeed>
∇
I hope this is of some help.
Ray