Writing to serial port?

30 views
Skip to first unread message

Zeta Convex

unread,
Sep 23, 2021, 1:31:53 PM9/23/21
to Racket Users

How do I write to a serial port? I'm on Linux, and want a baud rate of 115200.

I'm new to Scheme. I can't seem to find a library to do what I want.

Zeta Convex

unread,
Sep 23, 2021, 1:55:53 PM9/23/21
to Racket Users
Ah, OK. It seems fairly straightforward:

(system "stty -F /dev/ttyACM0 115200 crtscts")

(define out 0)
(set! out (open-output-file "/dev/ttyACM0" #:mode 'binary #:exists 'append))
;(set! in  (open-input-file  port-name #:mode 'binary))
(file-stream-buffer-mode out 'none)
(write-byte whatever out)

(close-output-port out)
Reply all
Reply to author
Forward
0 new messages