Add ‘guile-termios’ dependency to set the speed of the inkplate TTY

There seems to be magic going on here. Once the speed has been set for the
device once the OS (at least GNU/Linux) remembers the setting and it doesn't
have to happen again after. Since I was porting from my Emacs module, I kept
running Emacs and it kept setting the speed, which meant that my tests with
Guile kept working.

After a reboot, it stopped.

This change makes sure that the speed is set. I'm not sure if the raw is
necessary, but it's in the example, and it seems to work for now, so I'll keep
it around.
This commit is contained in:
Tom Willemse 2023-07-12 15:08:31 -07:00
parent 17e45127e1
commit b86754cb92
4 changed files with 18 additions and 5 deletions

View file

@ -23,7 +23,7 @@ if test "x$GUILD" = "x"; then
fi fi
dnl Hall auto-generated guile-module dependencies dnl Hall auto-generated guile-module dependencies
GUILE_MODULE_REQUIRED([termios])
dnl Installation directories for .scm and .go files. dnl Installation directories for .scm and .go files.
guilemoduledir="${datarootdir}/guile/site/$GUILE_EFFECTIVE_VERSION" guilemoduledir="${datarootdir}/guile/site/$GUILE_EFFECTIVE_VERSION"

View file

@ -23,7 +23,8 @@
("pkg-config" ,pkg-config) ("pkg-config" ,pkg-config)
("texinfo" ,texinfo))) ("texinfo" ,texinfo)))
(inputs `(("guile" ,guile-3.0))) (inputs `(("guile" ,guile-3.0)))
(propagated-inputs `()) (propagated-inputs
`(("guile-termios" ,guile-termios)))
(synopsis "") (synopsis "")
(description "") (description "")
(home-page "") (home-page "")

View file

@ -8,7 +8,7 @@
(description "") (description "")
(home-page "") (home-page "")
(license gpl3+) (license gpl3+)
(dependencies `()) (dependencies `(("guile-termios" (termios) ,guile-termios)))
(skip ()) (skip ())
(files (libraries ((scheme-file "inkplate"))) (files (libraries ((scheme-file "inkplate")))
(tests ((directory "tests" ((scheme-file "inkplate"))))) (tests ((directory "tests" ((scheme-file "inkplate")))))

View file

@ -1,6 +1,13 @@
(define-module (inkplate) (define-module (inkplate)
#:use-module ((ice-9 format) #:select (format)) #:use-module ((ice-9 format) #:select (format))
#:use-module ((srfi srfi-9) #:select (define-record-type)) #:use-module ((srfi srfi-9) #:select (define-record-type))
#:use-module ((termios system) #:select (termios-B115200))
#:use-module ((termios with-exceptions)
#:select (make-termios-struct
tc-get-attr!
tc-set-attr
cf-make-raw!
cf-set-speed!))
#:export (<inkplate> #:export (<inkplate>
make-inkplate make-inkplate
@ -62,7 +69,12 @@
(define (open device-path) (define (open device-path)
"Open a connection to an Inkplate on the named DEVICE-PATH." "Open a connection to an Inkplate on the named DEVICE-PATH."
(let ((port (open-file device-path "r+"))) (let ((port (open-file device-path "r+"))
(termios (make-termios-struct)))
(tc-get-attr! port termios)
(cf-make-raw! termios)
(cf-set-speed! termios termios-B115200)
(tc-set-attr port termios)
(make-inkplate port port))) (make-inkplate port port)))
(define (close device) (define (close device)