Skip to content

Commit

Permalink
bugfix: file-select replies with empty list on some hosts
Browse files Browse the repository at this point in the history
(file-select (list fd) …) can reply with either '() or #f upon
timeout. we only know there is data available when it's a pair _with_
our file-descriptior in it.

OBS: this patch makes everything slower. see TODO
  • Loading branch information
kristianlm committed Jan 2, 2024
1 parent d550004 commit 2856c19
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions avr-updi.scm
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,12 @@
;; ======================================== UPDI<-->UART interface

(define (tty-data-available? fd)
(receive (rs ws) (file-select (list fd) (list) 0)
(if (pair? rs) #t #f)))
(receive (rs ws) (file-select (list fd) (list) 1) ;; <-- TODO: make timeout 250ms
(if (pair? rs)
(if (equal? (car rs) fd)
#t
(error "unexpected read fd ≠ " (car rs) fd))
#f)))

;; handle partial reads produced by file-read.
;;
Expand Down

0 comments on commit 2856c19

Please sign in to comment.