chilipeppr / serial-port-json-server

Serial Port JSON Server is a websocket server for your serial devices. It compiles to a binary for Windows, Mac, Linux, Raspberry Pi, or BeagleBone Black that lets you communicate with your serial port from a web application. This enables web apps to be written that can communicate with your local serial device such as an Arduino, CNC controller, or any device that communicates over the serial port.
http://chilipeppr.com
GNU General Public License v2.0
321 stars 101 forks source link

multiply connection to one grbl #25

Closed tggo closed 7 years ago

tggo commented 7 years ago

if make two connection to one ttyUSB0, then status loop be called two times, and we receive mixed response like

<Idle|WPos:0.000,0.000,-0.020|Bf:15,128|FS:0,0|Ov:100<Idl|FS:0,0>\n

or

"<Idle|WPos:0.000"
",0.000,-0.020|Bf:15"
",128|FS:0,0>\n"
"<Idle|WP"
"20|Bf:15,128|FS:0,0>\r\n"
"<Idle"
"|WPos:0.000,0.00"
"0,-0.020|Bf:15,128"
"os:0.000,0.000,-0.0|FS:0,0>\n"
"<Idle|WPo"
"s:0.000,0.000,-0"
",0>\r\n"
"<Id"
"le|WPos:0.000,0.00"
"0,-0.020|Bf:15,"
".020|Bf:15,128|FS:0128|FS:0,0>\n"
"<Idle|"
"WPos:0.000,0.000"
",-0.020|Bf:15,128|"

I need 2 connection for my setup:

use: serial-port-json-server 1.94 on RaspberryPi grbl 1.1f

debug log: https://gist.github.com/tggo/262a2a3c0d575e961ae99db57116f80e

tggo commented 7 years ago

I seem to find the problem. every client send command on start:

open /dev/ttyUSB0 115200 grbl

And there is a problem. Twice opens the port and the data is read random? need check SerialPorts[0]["IsOpen"] in my clients Ok, is simple. But if i run my client (Jog Pendant client) first, then open web-client i receive twice opened port, and random data.

Maybe need add checking before open port in serial-port-json-server ?