I don't understand why my code doesn't work. I have a vector, this vector contains input-ports
on certain locations and 0
on other locations. When there is an input port
, I want to check if there is data available. If there is data available, read it and enqueue it. If there isn't, move on.
Here's my code:
;The name of the vector is 'in'.
(define (read-ports)
(let loop
((idx 0))
(if (not (= idx (vector-length in)))
(let ((port (vector-ref in idx)))
(if (not (eq? port 0))
(if (char-ready? port)
(let ((data (read port)))
(sendm buffer 'enqueue! data)) ;my own queue
(loop (+ idx 1)))
(loop (+ idx 1))))
'done)))
My problem is, char-ready
returns true
, but the read
operation still blocks! I'm sure the data is being send, but then why does it block? The data I am trying to send are vectors
, but these contain values between 0 en 255. So actually they are vectors
of bytes
.
Thanks in advance