Hi, revisiting this issue. I've got a Numato GPIO device using
/dev/ttyACM0 that shows settings
$ sudo stty -F /dev/ttyACM0
speed 9600 baud; line = 0;
kill = ^H; min = 1; time = 0;
-brkint -icrnl -imaxbel
-opost -onlcr
-isig -icanon -echo -echoe -echok
I can connect to device just fine using "screen", and get expected
input/output interaction:
$ sudo screen /dev/ttyACM0
>ver
00000008
According to the Numato manual:
"...the device echoes every single character sent to
it and so when you read the response, the data that is read will
include the command itself, a carriage return, the response which you
are interested in, a '>' character and another carriage return. You
will need to extract the response from this bunch of data..."
If I try this in picolisp...
(de check-version ()
(let? Dev (open "/dev/ttyACM0")
(out Dev
(prinl "ver") )
(in Dev
(setq Output (line)) )
(close Dev) )
Output )
..I get response...
: (check-version)
-> ("v" "e" "r")
Which would be expected. However, if I run (line) twice in order to try
to capture that second line...
(de check-version ()
(let? Dev (open "/dev/ttyACM0")
(out Dev
(prinl "ver") )
(in Dev
(line) # ADDED LINE
(setq Output (line)) )
(close Dev) )
Output )
..a call to (check-version) will hang, as though waiting for more
output, instead of giving me the second line (the result data).
On 02/18/2017 04:54 AM, Alexander Burger wrote:
> On Sat, Feb 18, 2017 at 09:24:09AM +0100, Alexander Burger wrote:
>> (out "/dev/ttyACM0"
>> ... )
>>
>> (in "/dev/ttyACM0"
>> ... )
>
> Some devices don't like it very much to be opened and closed all the time
> (losing queued data, for example). In that case, you could try:
>
> (let? Dev (open "/dev/ttyACM0")
> (loop
> (in Dev
> ... )
> ...
> (out Dev
> ... ) ) )
>
> ♪♫ Alex
>
--
https://qlfiles.net
--
UNSUBSCRIBE: mailto:[email protected]?subject=Unsubscribe