I'm about to link a Raspberry Pi and a BBC micro:bit using serial comms. I'd like to use APL and ⎕arbin on the Pi end but can't find any sample code. Any suggestions?
I'll eventually need two-way serial comms but one-way would do to start with.
⎕ARBIN for serial comms (Pi to Beeb micro:bit)
Forum rules
This forum is for general chit-chat, not necessarily APL-related. However, it's not for spam or for offensive or illegal comments.
This forum is for general chit-chat, not necessarily APL-related. However, it's not for spam or for offensive or illegal comments.
Re: ⎕ARBIN for serial comms (Pi to Beeb micro:bit)
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:
I use ⎕UCS to convert the "text" into bytes suitable for ⎕ARBOUT.
An example of it in use:
I hope this is of some help.
Ray
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
Ray Cannon
Please excuse any smelling pisstakes.
Please excuse any smelling pisstakes.