diff options
author | Tom Willemse | 2023-07-12 15:08:31 -0700 |
---|---|---|
committer | Tom Willemse | 2023-07-12 15:08:31 -0700 |
commit | b86754cb92cf0c43ed6a34831517e46b8c60f290 (patch) | |
tree | 33543ffb7e603b0f7d57abaaf2137879fe960975 | |
parent | 17e45127e137ff5c96596ae35b1913deb77f0d83 (diff) | |
download | guile-inkplate-b86754cb92cf0c43ed6a34831517e46b8c60f290.tar.gz guile-inkplate-b86754cb92cf0c43ed6a34831517e46b8c60f290.zip |
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.
-rw-r--r-- | configure.ac | 2 | ||||
-rw-r--r-- | guix.scm | 3 | ||||
-rw-r--r-- | hall.scm | 2 | ||||
-rw-r--r-- | inkplate.scm | 16 |
4 files changed, 18 insertions, 5 deletions
diff --git a/configure.ac b/configure.ac index e28d343..ee4e2a4 100644 --- a/configure.ac +++ b/configure.ac @@ -23,7 +23,7 @@ if test "x$GUILD" = "x"; then fi dnl Hall auto-generated guile-module dependencies - +GUILE_MODULE_REQUIRED([termios]) dnl Installation directories for .scm and .go files. guilemoduledir="${datarootdir}/guile/site/$GUILE_EFFECTIVE_VERSION" @@ -23,7 +23,8 @@ ("pkg-config" ,pkg-config) ("texinfo" ,texinfo))) (inputs `(("guile" ,guile-3.0))) - (propagated-inputs `()) + (propagated-inputs + `(("guile-termios" ,guile-termios))) (synopsis "") (description "") (home-page "") @@ -8,7 +8,7 @@ (description "") (home-page "") (license gpl3+) - (dependencies `()) + (dependencies `(("guile-termios" (termios) ,guile-termios))) (skip ()) (files (libraries ((scheme-file "inkplate"))) (tests ((directory "tests" ((scheme-file "inkplate"))))) diff --git a/inkplate.scm b/inkplate.scm index d068455..2774293 100644 --- a/inkplate.scm +++ b/inkplate.scm @@ -1,6 +1,13 @@ (define-module (inkplate) #:use-module ((ice-9 format) #:select (format)) #: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> make-inkplate @@ -62,8 +69,13 @@ (define (open device-path) "Open a connection to an Inkplate on the named DEVICE-PATH." - (let ((port (open-file device-path "r+"))) - (make-inkplate port port))) + (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))) (define (close device) "Close a connection to an Inkplate in DEVICE." |