johnlauer / serial-port-json-server

A serial port JSON websocket server 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
355 stars 174 forks source link

Buffer using LIFO ? #43

Closed mzi1sk closed 8 years ago

mzi1sk commented 8 years ago

Hello, i am getting problems with command order. If I understand correctly buffer works LIFO(last in first out) method. I would need to process it FIFO or if you can give me any hit for workaround. Thank you

this is the log

{"Cmd":"Queued","QCnt":1,"Ids":[""],"D":["Bufala \r\n"],"Port":"COM3"} {"Cmd":"Queued","QCnt":2,"Ids":[""],"D":[" 1 Ks 9.5 \u001b1 9,50 EUR \r\n"],"Port":"COM3"} {"Cmd":"Queued","QCnt":3,"Ids":[""],"D":["Risotto ai funghi porcini \r\n"],"Port":"COM3"} {"Cmd":"Queued","QCnt":4,"Ids":[""],"D":[" 1 Ks 10.0 \u001b1 10,00 EUR \r\n"],"Port":"COM3"} {"Cmd":"Queued","QCnt":5,"Ids":[""],"D":["Risotto ai funghi porcini \r\n"],"Port":"COM3"} {"Cmd":"Queued","QCnt":6,"Ids":[""],"D":[" 1 Ks 11.0 \u001b1 11,00 EUR \r\n"],"Port":"COM3"} {"Cmd":"Queued","QCnt":7,"Ids":[""],"D":["Risotto ai funghi porcini \r\n"],"Port":"COM3"} {"Cmd":"Queued","QCnt":8,"Ids":[""],"D":[" 1 Ks 12.0 \u001b1 12,00 EUR \r\n"],"Port":"COM3"} {"Cmd":"Queued","QCnt":9,"Ids":[""],"D":["Risotto ai funghi porcini \r\n"],"Port":"COM3"} {"Cmd":"Queued","QCnt":10,"Ids":[""],"D":[" 1 Ks 13.0 \u001b1 13,00 EUR \r\n"],"Port":"COM3"} {"Cmd":"Queued","QCnt":11,"Ids":[""],"D":["\u001bk 55,50 \r\n"],"Port":"COM3"} {"Cmd":"Queued","QCnt":12,"Ids":[""],"D":["\u001bP1 55,50 EUR \r\n"],"Port":"COM3"} {"Cmd":"Queued","QCnt":13,"Ids":[""],"D":["\u001be \r\n"],"Port":"COM3"} {"Cmd":"Write","QCnt":12,"Id":"","P":"COM3"} {"Cmd":"CompleteFake","Id":"","P":"COM3"} {"Cmd":"Write","QCnt":11,"Id":"","P":"COM3"} {"Cmd":"CompleteFake","Id":"","P":"COM3"} {"Cmd":"Write","QCnt":10,"Id":"","P":"COM3"} {"Cmd":"CompleteFake","Id":"","P":"COM3"} {"Cmd":"Write","QCnt":9,"Id":"","P":"COM3"} {"Cmd":"CompleteFake","Id":"","P":"COM3"} {"Cmd":"Write","QCnt":8,"Id":"","P":"COM3"} {"Cmd":"CompleteFake","Id":"","P":"COM3"} {"Cmd":"Write","QCnt":7,"Id":"","P":"COM3"} {"Cmd":"CompleteFake","Id":"","P":"COM3"} {"Cmd":"Write","QCnt":6,"Id":"","P":"COM3"} {"Cmd":"CompleteFake","Id":"","P":"COM3"} {"Cmd":"Write","QCnt":5,"Id":"","P":"COM3"} {"Cmd":"CompleteFake","Id":"","P":"COM3"} {"Cmd":"Write","QCnt":4,"Id":"","P":"COM3"} {"Cmd":"CompleteFake","Id":"","P":"COM3"} {"Cmd":"Write","QCnt":3,"Id":"","P":"COM3"} {"Cmd":"CompleteFake","Id":"","P":"COM3"} {"Cmd":"Write","QCnt":2,"Id":"","P":"COM3"} {"Cmd":"CompleteFake","Id":"","P":"COM3"} {"Cmd":"Write","QCnt":1,"Id":"","P":"COM3"} {"Cmd":"CompleteFake","Id":"","P":"COM3"} {"Cmd":"Write","QCnt":0,"Id":"","P":"COM3"} {"Cmd":"CompleteFake","Id":"","P":"COM3"}

chilipeppr commented 8 years ago

No, it's a FIFO queue. It definitely does not jumble order as this is used heavily by thousands of users on CNC jobs. Can you explain better how/what you're seeing with things getting out of order? It is more likely you are sending stuff out of order.

On Thu, Feb 25, 2016 at 8:52 AM, mzi1sk notifications@github.com wrote:

Hello, i am getting problems with command order. If I understand correctly buffer works LIFO(last in first out) method. I would need to process it FIFO or if you can give me any hit for workaround. Thank you

this is the log

{"Cmd":"Queued","QCnt":1,"Ids":[""],"D":["Bufala \r\n"],"Port":"COM3"} {"Cmd":"Queued","QCnt":2,"Ids":[""],"D":[" 1 Ks 9.5 \u001b1 9,50 EUR \r\n"],"Port":"COM3"} {"Cmd":"Queued","QCnt":3,"Ids":[""],"D":["Risotto ai funghi porcini \r\n"],"Port":"COM3"} {"Cmd":"Queued","QCnt":4,"Ids":[""],"D":[" 1 Ks 10.0 \u001b1 10,00 EUR \r\n"],"Port":"COM3"} {"Cmd":"Queued","QCnt":5,"Ids":[""],"D":["Risotto ai funghi porcini \r\n"],"Port":"COM3"} {"Cmd":"Queued","QCnt":6,"Ids":[""],"D":[" 1 Ks 11.0 \u001b1 11,00 EUR \r\n"],"Port":"COM3"} {"Cmd":"Queued","QCnt":7,"Ids":[""],"D":["Risotto ai funghi porcini \r\n"],"Port":"COM3"} {"Cmd":"Queued","QCnt":8,"Ids":[""],"D":[" 1 Ks 12.0 \u001b1 12,00 EUR \r\n"],"Port":"COM3"} {"Cmd":"Queued","QCnt":9,"Ids":[""],"D":["Risotto ai funghi porcini \r\n"],"Port":"COM3"} {"Cmd":"Queued","QCnt":10,"Ids":[""],"D":[" 1 Ks 13.0 \u001b1 13,00 EUR \r\n"],"Port":"COM3"} {"Cmd":"Queued","QCnt":11,"Ids":[""],"D":["\u001bk 55,50 \r\n"],"Port":"COM3"} {"Cmd":"Queued","QCnt":12,"Ids":[""],"D":["\u001bP1 55,50 EUR \r\n"],"Port":"COM3"} {"Cmd":"Queued","QCnt":13,"Ids":[""],"D":["\u001be \r\n"],"Port":"COM3"} {"Cmd":"Write","QCnt":12,"Id":"","P":"COM3"} {"Cmd":"CompleteFake","Id":"","P":"COM3"} {"Cmd":"Write","QCnt":11,"Id":"","P":"COM3"} {"Cmd":"CompleteFake","Id":"","P":"COM3"} {"Cmd":"Write","QCnt":10,"Id":"","P":"COM3"} {"Cmd":"CompleteFake","Id":"","P":"COM3"} {"Cmd":"Write","QCnt":9,"Id":"","P":"COM3"} {"Cmd":"CompleteFake","Id":"","P":"COM3"} {"Cmd":"Write","QCnt":8,"Id":"","P":"COM3"} {"Cmd":"CompleteFake","Id":"","P":"COM3"} {"Cmd":"Write","QCnt":7,"Id":"","P":"COM3"} {"Cmd":"CompleteFake","Id":"","P":"COM3"} {"Cmd":"Write","QCnt":6,"Id":"","P":"COM3"} {"Cmd":"CompleteFake","Id":"","P":"COM3"} {"Cmd":"Write","QCnt":5,"Id":"","P":"COM3"} {"Cmd":"CompleteFake","Id":"","P":"COM3"} {"Cmd":"Write","QCnt":4,"Id":"","P":"COM3"} {"Cmd":"CompleteFake","Id":"","P":"COM3"} {"Cmd":"Write","QCnt":3,"Id":"","P":"COM3"} {"Cmd":"CompleteFake","Id":"","P":"COM3"} {"Cmd":"Write","QCnt":2,"Id":"","P":"COM3"} {"Cmd":"CompleteFake","Id":"","P":"COM3"} {"Cmd":"Write","QCnt":1,"Id":"","P":"COM3"} {"Cmd":"CompleteFake","Id":"","P":"COM3"} {"Cmd":"Write","QCnt":0,"Id":"","P":"COM3"} {"Cmd":"CompleteFake","Id":"","P":"COM3"}

— Reply to this email directly or view it on GitHub https://github.com/johnlauer/serial-port-json-server/issues/43.

mzi1sk commented 8 years ago

Ok thank you for fast responce. I will investigate more, why it gets mixed. Thank you for now.

JEROME4095 commented 8 years ago

Hello all. John is it possible that we receive the packages in the wrong order I have had a similar problem seems to be network related as the packet flow had latency? I was definitely processing out of order. Not sure of the cause-and-effect analysis... FYI I have found its useful to send coordinate system or otherwise set up file to the tiny G in my case almost every job this in a batch file right now I execute it manually but would like to automate this process

This really seems to streamline the process always have a successful run no velocity problems And stepper issues!

Thanks again John for all your support to the community

Jerry

Sent from my iPhone

On Feb 25, 2016, at 11:56, mzi1sk notifications@github.com wrote:

Ok thank you for fast responce. I will investigate more, why it gets mixed. Thank you for now.

— Reply to this email directly or view it on GitHub.

chilipeppr commented 8 years ago

I'm not really sure I understand your question On Feb 25, 2016 2:30 PM, "jerome welch" notifications@github.com wrote:

Hello all. John is it possible that we receive the packages in the wrong order I have had a similar problem seems to be network related as the packet flow had latency? I was definitely processing out of order. Not sure of the cause-and-effect analysis... FYI I have found its useful to send coordinate system or otherwise set up file to the tiny G in my case almost every job this in a batch file right now I execute it manually but would like to automate this process

This really seems to streamline the process always have a successful run no velocity problems And stepper issues!

Thanks again John for all your support to the community

Jerry

Sent from my iPhone

On Feb 25, 2016, at 11:56, mzi1sk notifications@github.com wrote:

Ok thank you for fast responce. I will investigate more, why it gets mixed. Thank you for now.

— Reply to this email directly or view it on GitHub.

— Reply to this email directly or view it on GitHub https://github.com/johnlauer/serial-port-json-server/issues/43#issuecomment-189013566 .

mzi1sk commented 8 years ago

solution for me was using parameter Pause:100

messages gets mixed during json-server processing them on COM3 port How I monitored it : 1) checked the order of ws messages on chrome using dev tools - network - ws ; order was OK 2) checking on http://localhost:8989/. I see order of messages going to que is OK , I used ID's to identify them , and they were also processed OK.
3) using free serial monitor soft. I see messages got mixed order here. It must be caused by speed of my device (accept only 9600Baud) as I said solution was using pause parameter.