clj-serial
clj-serial copied to clipboard
Inefficient?
Opening one port in a new REPL and adding just one simple listener that does nothing but printing the received character makes the REPL process use way too much CPU (oscillating between 95 and 150% according to top
) and the fan revving up after a few seconds. Is this normal?
(use 'serial.core)
(def port (open "/dev/tty.usbserial-143320"))
(listen! port (fn [input-stream]
(loop [c (.read input-stream)]
(if (not= c -1)
(do
(print (char c))
(recur (.read input-stream)))))))
This is on a 2019 MacBook Pro with a 2.6GHz 6-core i7 running MacOS 11.1, connected to this USB ADC using the built-in driver.
Reading the same serial port using screen
takes ~0.1% CPU.