cserial-port icon indicating copy to clipboard operation
cserial-port copied to clipboard

trying read data from arduino hang the process forever

Open cage2 opened this issue 7 years ago • 0 comments

Hello!

Thank you for your library, it is very useful! :)

I am using cserial-port with an arduino mega, i do not know if the problem is arduino-specific or not, though.

Anyway this simple example:

  (cserial-port:with-serial (rs "/dev/ttyACM0" ;; this is the arduino on my system
                                :baud-rate 9600
                                :data-bits 8
                                :stop-bits 1
                                :parity    :none)
    (sleep 1) ;; <- note this call to 'sleep' added
    (cserial-port:write-serial-byte-vector (babel:string-to-octets (format nil "H~%"))
                                           rs)
    (format nil "~a~a"
            (cserial-port:read-serial-byte rs)
            (cserial-port:read-serial-byte rs))))

does not works without calling the sleep; the data is written to the device on the other end of the serial cable (the arduino in my case) but the first read-serial-byte never returns.

With the sleep everything works just fine, the bytes can be fetched and the expression is executed. Hope this could help to improve this good library.

Thank you for your work! :) C.

cage2 avatar Sep 10 '18 16:09 cage2