g2core line mode / protocol question

From the original Synthetos forum (2011–2025)

Started by talpa on in TinyG Support. 8 replies, last activity Jul 29, 2017.

#

Hi

I'm having no luck finding an existing application that just works for me for sending G-Code to an Arduino Due running g2core hocked up to a 3040 CNC.
(I'm running an "edge" based firmware on the Due)

I have tried
https://goko.fr/
https://winder.github.io/ugs_website/
https://github.com/synthetos/node-g2core-api

At least on my laptop running Debian unstable the programs goko and ugs have a hard time simply connecting to g2core, I have been unable to run node-g2core-api due to what seems to be a sort of version issue with nodejs.

Also I need the CNC to be running offline so ChiliPeppr is more or less out of the question.

Anyway when connecting to the g2core using minicom (a serial terminal) I can move the CNC around without problems.
I therefor thought that I could simply write a small python script to send g-code to to the g2core. I could then later on perhaps expand it into a small GUI using wxpython.

I have written a script and it sort of works.

The way I understand:
https://github.com/synthetos/g2/wiki/g2core-Communications#linemode-protocol

is that I need to keep track of the acknowledge {'r' responds that should match the number of lines/requests the script sends
(that should generate such responds.)
Additionally I'm apparently allowed to have up to 4 outstanding requests that have yet to be acknowledged before I should sending more lines.

However when I send a "large" g-code file the g2core keeps quickly sending me {'r' responds for each line the script sends.
The script there for keeps sending lines to the g2core... and everyone is happy until the communication fails due to:
{"er":{"fb":100.26,"st":28,"msg":"Failed to get planner buffer - mp_get_write_buffer()"}}
{"er":{"fb":100.26,"st":36,"msg":"Failed to get planner buffer - aline()"}}

Even when I reduce the "sliding window size" to 1 reducing the protocol to:
Send a line, wait for a {'r' before sending another
The g2core still keeps on requesting data until it fails.

The following is some output from the script leading up to the error while sending a dummy file:

<- {"r":{},"f":[1,0,17]}
-> {"gc":"G1 X0"}
<- {"r":{},"f":[1,0,16]}
<- {"sr":{"posx":9.898,"vel":198.33}}
-> {"gc":"G1 X10"}
<- {"r":{},"f":[1,0,17]}
-> {"gc":"G1 X0"}
<- {"r":{},"f":[1,0,16]}
-> {"gc":"G1 X10"}
<- {"r":{},"f":[1,0,17]}
<- {"sr":{"posx":8.129,"vel":1000}}
-> {"gc":"G1 X0"}
<- {"r":{},"f":[1,0,16]}
-> {"gc":"G1 X10"}
<- {"r":{},"f":[1,0,17]}
<- {"sr":{"posx":3.99}}
-> {"gc":"G1 X0"}
<- {"er":{"fb":100.26,"st":28,"msg":"Failed to get planner buffer - mp_get_write_buffer()"}}
<- {"er":{"fb":100.26,"st":36,"msg":"Failed to get planner buffer - aline()"}}
<- {"r":{},"f":[1,36,16]}
-> {"gc":"G1 X10"}
<- {"r":{},"f":[1,206,17]}

I must be overlooking something, but what?
Does the line mode described in the wiki not work with the g2core code in brand "edge"?
Have I misunderstood the protocol in regard to how the g2core is suppoed to halt the transmission of more data?

Any help would be appreciated.

Kind regards Visti Andresen

Staff #

Can I assume you have looked at items over at

https://github.com/synthetos/g2/issues

that might relate here?
You will likely get more help by logging this as an Issue - there is not a lot of experience with line mode as yet, so getting developers attention will help.

#

Yes but I haven't found anything that matches my issue.

I will try to log an issue (and upload my script code to github for easier replication)

However I still assume it is a bug on my part as preventing overflow on the receiving g2core is a critical and probably well tested functionality as it is required for sending "large" files.

Btw. I have also tested branch "master" with my script with the same result.

Staff #

I did not pull down your code.

Any chance the code is (improperly) seeing incoming {sr.... responses as {r... responses and incrementing ?

Just a wild guess......

#

Quite all right I only just finished cleaning up the code and filling an issue on github.

https://github.com/synthetos/g2/issues/287

Unfortunately it does not seem to be as simple as 'sr' being seen as containing 'r'.
I actually considered that some time ago...

So I would call is a good wild guess :)

#

I'm 99% sure it is caused by a bug in g2core's handling of {'gc' where it mistakes them for control lines.
Sending the g-code without json wrapping works just fine :)

Staff #

Interesting, good find. I'll keep an eye on Issue 287

This topic is from the original forum (July 2017). Your reply starts a new discussion linked to it.

Reply

Different problem? Ask a new question

Back to TinyG Support or latest activity.