aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHugo Hörnquist <hugo@lysator.liu.se>2020-07-20 04:18:27 +0200
committerHugo Hörnquist <hugo@lysator.liu.se>2020-07-20 04:19:03 +0200
commit1345ea96a75246d4ffc3a95f7459f2aab14bf11b (patch)
treef7d55dbecb9c4ae1e91341eab40db40f9307c170
parentResolve TODO for with-ptr. (diff)
downloadcalp-1345ea96a75246d4ffc3a95f7459f2aab14bf11b.tar.gz
calp-1345ea96a75246d4ffc3a95f7459f2aab14bf11b.tar.xz
Resolve {i,o}speed TODO in termios.
-rw-r--r--module/vulgar/termios.scm27
1 files changed, 25 insertions, 2 deletions
diff --git a/module/vulgar/termios.scm b/module/vulgar/termios.scm
index 414dc986..bf92eb6d 100644
--- a/module/vulgar/termios.scm
+++ b/module/vulgar/termios.scm
@@ -65,13 +65,36 @@
((record-modifier <termios> 'list) t v)
((record-modifier <termios> 'ptr) t (make-c-struct struct-termios v)))
-;; TODO {i,o}speed should be looked up in a table.
+(define (resolve-baud-speed n)
+ (case* n
+ ((B0) 0)
+ ((B50) 50)
+ ((B75) 75)
+ ((B110) 110)
+ ((B134) 134)
+ ((B150) 150)
+ ((B200) 200)
+ ((B300) 300)
+ ((B600) 600)
+ ((B1200) 1200)
+ ((B1800) 1800)
+ ((B2400) 2400)
+ ((B4800) 4800)
+ ((B9600) 9600)
+ ((B19200) 19200)
+ ((B38400) 38400)
+ ((B57600) 57600)
+ ((B115200) 115200)
+ ((B230400) 230400)))
+
;; TODO bit fields should display what their fields mean
((@ (srfi srfi-9 gnu) set-record-type-printer!)
<termios>
(lambda (t p)
(format p "#<termios iflag=~b oflag=~b cflag=~b lflag=~b line=~d ispeed=~d ospeed=~d cc=~s>"
- (iflag t) (oflag t) (cflag t) (lflag t) (line t) (ispeed t) (ospeed t)
+ (iflag t) (oflag t) (cflag t) (lflag t) (line t)
+ (resolve-baud-speed (ispeed t))
+ (resolve-baud-speed (ospeed t))
(map integer->char (filter (negate zero?) (cc t))))))