I have a node.js based server running on Raspberry that performs as relay between TCP clients and USB devices. Here what it does:
A. It listens for commands on TCP port and relays data to connected USB device (DMX controller).
B. It recieves continously telemetry data from serial port (115200) baud and needs to stream it to a single TCP client who connects to the server over another TCP port.
I'm struggling to understand how do I maintain realtime performance for both tasks. The part A of the server works fine. However how do I write a code for part B, which doesn't block everything, but streams data at the same time in real-time ?
If I create while(1) { socket.write(encoderData) } loop in my server.on('connection') it works, but blocks the server. If I insert timers, then I introduce a delay into the system and the data is no longer realtime. Is there a way to stream data intelligently ?
Thanks
M
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…