jgphilpott / polyslice

An FDM slicer designed specifically for three.js
https://jgphilpott.github.io/polyslice/serial/browser/sender.html
MIT License
4 stars 0 forks source link

Response data comes in small/short chunks making it hard to read #1

Closed jgphilpott closed 4 months ago

jgphilpott commented 5 months ago

Description:

With some machines, the response data comes in small/short chunks making it hard to read in the output log. See this comment by @moof-moof for more detail.

Reproduction:

The ability to reproduce this issue will depend on what machine you are using but in general, follow these steps:

Expected Behavior:

The output contains longer more readable text.

Screenshots:

See here.

Environment:

Please include the following information:

Extra:

Add any other information about the problem here.

jgphilpott commented 5 months ago

@moof-moof my best guess is that it has something to do with the connection settings, most likely the buffer size. The docs I linked to should provide more detail on each of the settings. You should be able to edit each of the settings using the inputs at the top of the page (see screenshot 1). Modifying any of the settings will automatically disconnect you from the machine so be sure to reconnect afterwards.

Perhaps try Googling the recommended connection settings for your machine? I've noticed that I occasionally get broken response data from my printer but not all the time and the messages are always longer than 4 characters (see screenshot 2). Without having access to your device it's a little hard to debug, how about you try fiddling with your connection settings and if it's still not working I will take a closer look over the weekend when I have more time.

If you want to see the raw response data in the console try adding console.log(decoder.decode(value)) to line 147 of serial/browser/sender.js.

Screenshot 1

Screenshot 2024-04-24 at 3 08 07 PM

Screenshot 2

Screenshot 2024-04-24 at 3 16 31 PM
moof-moof commented 4 months ago

@jgphilpott Okay, today I had the opportunity to spend some time fiddling with the different connection settings combinations, as you suggested.

I should perhaps mention that my 2D CNC machine is my own design, and that it is controled with a version of the GRBL firmware which is "officially" expected to use a serial speed of 9600. I have previously tested 115200 bauds from the command line, and even though it does seem to work well enough then, I suspect it isn't always as stable at that communication speed. The microcontroler is an Arduino Uno. Not that it should influence the performance of a web app, but my OS is Linux Ubuntu 20.04 with the Mate WM. Browser is Chrome version 124.0.6367.60 (64 bit).

Anyway, during the latest testing using two different Arduinos boards I firstly noticed that when setting very low baud rates, like 4800 and 2400, the output lines got even shorter than previously. On average about two characters as compared to four before.

On the other hand, going to the other "extreme" (baud rates of 115200) did lead to increased line lengths, with 230400 bauds perhaps being marginally better. However the output result was still far from the actual lengths, which contains up to 36 characters per line in my test example text. Increasing the baudrate even more had no additional (discernible) positive effect on the output, while evidently making the controler unresponsive to serial input instead.

I also varied the Data and Stop bit values (7-2 instead of 8-1), and even the flow control and parity settings. Surprisingly to me, this did not seem to influence the overall output for better or worse.

Concerning buffer size, I could not find anything correlated to hat variable either, I'm afraid.

I attach some more screenshots: 1) 115200baud 256buff 2) 115200baud 1024buff 3) 230400baud 1024buff 4) 230400baud 8192buff 5) Chrome console (230400baud 1024buff)

and more examples of expected output: 6) Arduino monitor baud range 4800--230400 7) VS Code tested baud range 9600--230400 1) 115200baud 256buff 2) 115200baud 1024buff 3) 230400baud 1024buff 4) 230400baud 8192buff 5) Chrome console 230400baud 1024buff 6) Arduino monitor baud range 4800--230400 7) VS Code tested baud range 9600--230400

jgphilpott commented 4 months ago

FYI @moof-moof I think I've got a solution for this, I'm working on it and will update you shortly.

jgphilpott commented 4 months ago

Hey @moof-moof I believe I have a solution that should work regardless of the connection settings. If you could checkout the bug/1/response-data-comes-in-small-chunks-making-it-hard-to-read branch and let me know if it is working for you that would be awesome! The branch also contains a few other small changes I made so if you want to see the fix for just this issue take a look at this commit. Once you can confirm it's working (or not) I will merge the changes into the main branch.

moof-moof commented 4 months ago

Hey-hey-hey! @jgphilpott
"S-U-C-C-E-S-S" -- That is how we spell success! Thank you for your help.

jgphilpott commented 4 months ago

@moof-moof that's fantastic, I have just merged the branch now, the changes should be live within a few minutes! I'm also working on the upload feature you requested and should have it done shortly.