serial cache read - part-cw/lambdanative GitHub Wiki
(serial-cache-read dev . hook)
serial-cache-read reads RS232 serial cache data and returns a string.
| Parameter | Description |
|---|---|
| dev | Serial device obtained from rs232-try |
| hook | Optional: Function that is called for all data received |
Example
Example 1: Function, which receives data from a monitor and stores it's content to a data string (minus the two enclosing characters).
(define (monitor:recv dev debug)
(set! monitor:data #f)
(let* ((data (serial-cache-read dev))
(sane? (and data (fx>= (string-length data) 36) (char=? (string-ref data 15) #\:))))
(if (and data sane?) (begin
(if debug (for-each display (list "monitor: " data)))
(set! monitor:data (substring data 1 (- (string-length data) 1)))
))
)