-
Notifications
You must be signed in to change notification settings - Fork 174
Home
Welcome to the serial-port-json-server wiki!
Proposed changes for upcoming release.
Have SPJS support a "sendjson" command so multiple lines or serial port data can be sent in at once, but each line can have an ID attached to it so SPJS can send that ID back once the serial port device has executed the command, as well as still allowing buffered and non-buffered send commands.
If you send in a command like this today to SPJS:
send COM22 G91 G0 Z1 F200\nG90\n
You get back: {"Cmd":"Queued","QCnt":2,"Type":["Buf","Buf"],"D":["G91 G0 Z1 F200\n","G90\n"],"Port":"COM22"}
Then when each line is executed you get back: {"Cmd":"Write","QCnt":1,"D":"G91 G0 Z1 F200\n","Port":"COM22"} {"Cmd":"Write","QCnt":0,"D":"G90\n","Port":"COM22"}
As seen above, SPJS is already keeping track of each line and sending a final response. However, it is hard to line up which line is which in a UI. To solve this an ID will be allowed to be passed in per command. This would mean that commands can't just be sent in as one long string with a newline delimiter. Instead each line should be sent in as a structured object.
It is proposed to send in the line above as:
sendjson { "P": "COM22", "Data": [ { "D": "G91 G0 Z1 F200\n", "Id": "222" }, { "D:" "G90\n", "Id": "223" } ] }
Then when SPJS buffers those lines, it will send back:
{"Cmd":"Queued","QCnt":2,"Data": [ { "D": "G91 G0 Z1 F200\n", "Id": "222", "Buf": true }, { "D": "G90\n", "Id": "223", "Buf": true } ],"P":"COM22"}
Then when SPJS sees those lines executed from the serial device, it will send back: {"Cmd": "Write", "QCnt":1, "D": "G91 G0 Z1 F200\n", "Id": "222", "P" :"COM22"} {"Cmd": "Write", "QCnt":0, "D": "G90\n", "Id": "223", "P": "COM22"}