Closed peteruithoven closed 10 years ago
I was reading through the Gcode and Serial Port Console code on JSFiddle. But I can't find something that would remove spaces. In the Gcode panel I only found code to filter out comments to display them differently. Could you give me a pointer on where I could look. One thing I find very odd is that I inputted gcode with spaces but looking at the Serial Port Console they seemed to have been filtered away.
Not sure whether this happens in Chilipeppr or in the serial port json server, but I couldn't find anything relevant with "\s" or "space" or "trim" there either.
Hi Peter,
I'm guessing you're using the Grbl workspace. I do know the Grbl workspace filters out spaces and comments to compress the Gcode to fit more into the serial buffer at once. I will say that’s not a bad idea since serial buffers are small. Grbl is only 128, while TinyG is 254.
I cc'ed Jarret Luft on this because it seems he would have to tweak his algorithm for semi-colons because I bet that's what's messing up.
BTW, those spaces are being removed inside the Grbl widget. That widget intercepts all /send pubsub signals. Rewrites the Gcode and then resends it through pubsub on the /send channel again for the Serial Port widget to get it. It's not obvious that's happening, but it's one of the cooler aspects of how slick ChiliPeppr is that a new widget can be added that injects itself into the flow of pubsub signals since you can subscribe to a signal with a higher priority.
BTW, the Serial Port Console shows Gcode looped back from Serial Port JSON Server.
-John
On Thu, Sep 11, 2014 at 3:05 PM, Peter Uithoven notifications@github.com wrote:
I was reading through the Gcode and Serial Port Console code on JSFiddle. But I can't find something that would remove spaces. In the Gcode panel I only found code to filter out comments to display them differently. Could you give me a pointer on where I could look. One thing I find very odd is that I inputted gcode with spaces but looking at the Serial Port Console they seemed to have been filtered away.
Not sure whether this happens in Chilipeppr or in the serial port json server, but I couldn't find anything relevant with "\s" or "space" or "trim" there either.
— Reply to this email directly or view it on GitHub https://github.com/chilipeppr/tinyg/issues/5#issuecomment-55335967.
Hi Peter, If you are using a grbl controller and the grbl workspace, I have attempted to fix this issue. Please try again and let me know if it helped.
Thanks guys, that's very insightful!
I'm indeed using the GRBL workspace and GRBL, I'll mention it next time.
It seems to go a lot better, no more error: Expected command letter
. The comments seem to be removed correctly, the console now reports:
G21
G90
G1Z5F2540
G1X50.2603Y39.7175F2540
Looking at the verbose logs of the serial port json server I also see the comments are filtered out. I tested this with a separate Arduino and my laptop. I'll test it tomorrow on our mill (http://youtu.be/zjcJz5nvOys).
Trying it with a actual cnc mill I'm afraid I'm still noticing it isn't going to the safety height and there is probably still something going wrong with these inline comments. When I remove the comments from the first lines everything goes fine.
The logs from the Serial Port Console:
Grbl 0.9g ['$' for help]
$$
... all the settings
ok
G21
G90G1Z5F2540
G1X27.0960Y18.7465F2540
error: Invalid gcode ID:24
G1Z0.0000
error: Undefined feed rate
G1X27.0779Y18.6558Z-0.0114F1016.0000
ok
The logs from the serial port json server:
2014/09/13 11:44:16 hub.go:105: send /dev/ttyACM0 G21
2014/09/13 11:44:16 serial.go:514: Inside spWrite arg: send /dev/ttyACM0 G21
2014/09/13 11:44:16 serial.go:245: Got write to id:, port:/dev/ttyACM0, buffer:true, data:G21
2014/09/13 11:44:16 serial.go:376: itemsInBuffer:1
2014/09/13 11:44:16 serial.go:227: Send was normal send, so sending to wr.p.sendBuffered
2014/09/13 11:44:16 hub.go:82: Got a system broadcast: {"Cmd":"Queued","QCnt":1,"Type":["Buf"],"Ids":[""],"D":["G21"],"Port":"/dev/ttyACM0"}
2014/09/13 11:44:16 serialport.go:190: Got p.sendBuffered. data:G21, id:
2014/09/13 11:44:16 serialport.go:202: About to send to p.sendNoBuf channel
2014/09/13 11:44:16 serialport.go:219: Got p.sendNoBuf. data:G21, id:
2014/09/13 11:44:16 serialport.go:226: itemsInBuffer:0
2014/09/13 11:44:16 hub.go:82: Got a system broadcast: {"Cmd":"Write","QCnt":0,"Id":"","Buf":"Buf","P":"/dev/ttyACM0"}
2014/09/13 11:44:16 hub.go:82: Got a system broadcast: {"Cmd":"CompleteFake","Id":"","P":"/dev/ttyACM0","BufSize":-1}
2014/09/13 11:44:16 serialport.go:260: Just wrote 3 bytes to serial: G21
2014/09/13 11:44:16 hub.go:105: send /dev/ttyACM0 G90G1Z5F2540
2014/09/13 11:44:16 serial.go:514: Inside spWrite arg: send /dev/ttyACM0 G90G1Z5F2540
2014/09/13 11:44:16 serial.go:245: Got write to id:, port:/dev/ttyACM0, buffer:true, data:G90G1Z5F2540
2014/09/13 11:44:16 serial.go:376: itemsInBuffer:1
2014/09/13 11:44:16 serial.go:227: Send was normal send, so sending to wr.p.sendBuffered
2014/09/13 11:44:16 hub.go:82: Got a system broadcast: {"Cmd":"Queued","QCnt":1,"Type":["Buf"],"Ids":[""],"D":["G90G1Z5F2540"],"Port":"/dev/ttyACM0"}
2014/09/13 11:44:16 serialport.go:190: Got p.sendBuffered. data:G90G1Z5F2540, id:
2014/09/13 11:44:16 serialport.go:202: About to send to p.sendNoBuf channel
2014/09/13 11:44:16 serialport.go:219: Got p.sendNoBuf. data:G90G1Z5F2540, id:
2014/09/13 11:44:16 serialport.go:226: itemsInBuffer:0
2014/09/13 11:44:16 hub.go:82: Got a system broadcast: {"Cmd":"Write","QCnt":0,"Id":"","Buf":"Buf","P":"/dev/ttyACM0"}
2014/09/13 11:44:16 hub.go:82: Got a system broadcast: {"Cmd":"CompleteFake","Id":"","P":"/dev/ttyACM0","BufSize":-1}
2014/09/13 11:44:16 serialport.go:260: Just wrote 12 bytes to serial: G90G1Z5F2540
2014/09/13 11:44:17 hub.go:105: send /dev/ttyACM0 G1X27.0960Y18.7465F2540
2014/09/13 11:44:17 serial.go:514: Inside spWrite arg: send /dev/ttyACM0 G1X27.0960Y18.7465F2540
2014/09/13 11:44:17 serial.go:245: Got write to id:, port:/dev/ttyACM0, buffer:true, data:G1X27.0960Y18.7465F2540
2014/09/13 11:44:17 serial.go:376: itemsInBuffer:1
2014/09/13 11:44:17 serial.go:227: Send was normal send, so sending to wr.p.sendBuffered
2014/09/13 11:44:17 hub.go:82: Got a system broadcast: {"Cmd":"Queued","QCnt":1,"Type":["Buf"],"Ids":[""],"D":["G1X27.0960Y18.7465F2540\n"],"Port":"/dev/ttyACM0"}
2014/09/13 11:44:17 serialport.go:190: Got p.sendBuffered. data:G1X27.0960Y18.7465F2540
, id:
2014/09/13 11:44:17 serialport.go:202: About to send to p.sendNoBuf channel
2014/09/13 11:44:17 serialport.go:219: Got p.sendNoBuf. data:G1X27.0960Y18.7465F2540
, id:
2014/09/13 11:44:17 serialport.go:226: itemsInBuffer:0
2014/09/13 11:44:17 hub.go:82: Got a system broadcast: {"Cmd":"Write","QCnt":0,"Id":"","Buf":"Buf","P":"/dev/ttyACM0"}
2014/09/13 11:44:17 hub.go:82: Got a system broadcast: {"Cmd":"CompleteFake","Id":"","P":"/dev/ttyACM0","BufSize":-1}
2014/09/13 11:44:17 hub.go:105: send /dev/ttyACM0 G1Z0.0000
2014/09/13 11:44:17 hub.go:82: Got a system broadcast: {"P":"/dev/ttyACM0","D":"error: Invalid gcode ID:24\r\n"}
2014/09/13 11:44:17 serialport.go:260: Just wrote 24 bytes to serial: G1X27.0960Y18.7465F2540
2014/09/13 11:44:17 serial.go:514: Inside spWrite arg: send /dev/ttyACM0 G1Z0.0000
2014/09/13 11:44:17 serial.go:245: Got write to id:, port:/dev/ttyACM0, buffer:true, data:G1Z0.0000
2014/09/13 11:44:17 serial.go:376: itemsInBuffer:1
2014/09/13 11:44:17 serial.go:227: Send was normal send, so sending to wr.p.sendBuffered
2014/09/13 11:44:17 hub.go:82: Got a system broadcast: {"Cmd":"Queued","QCnt":1,"Type":["Buf"],"Ids":[""],"D":["G1Z0.0000\n"],"Port":"/dev/ttyACM0"}
2014/09/13 11:44:17 serialport.go:190: Got p.sendBuffered. data:G1Z0.0000
, id:
2014/09/13 11:44:17 serialport.go:202: About to send to p.sendNoBuf channel
2014/09/13 11:44:17 serialport.go:219: Got p.sendNoBuf. data:G1Z0.0000
, id:
2014/09/13 11:44:17 serialport.go:226: itemsInBuffer:0
2014/09/13 11:44:17 hub.go:82: Got a system broadcast: {"Cmd":"Write","QCnt":0,"Id":"","Buf":"Buf","P":"/dev/ttyACM0"}
2014/09/13 11:44:17 serialport.go:260: Just wrote 10 bytes to serial: G1Z0.0000
2014/09/13 11:44:17 hub.go:82: Got a system broadcast: {"Cmd":"CompleteFake","Id":"","P":"/dev/ttyACM0","BufSize":-1}
2014/09/13 11:44:17 hub.go:105: send /dev/ttyACM0 G1X27.0779Y18.6558Z-0.0114F1016.0000
2014/09/13 11:44:17 hub.go:82: Got a system broadcast: {"P":"/dev/ttyACM0","D":"error"}
2014/09/13 11:44:17 hub.go:82: Got a system broadcast: {"P":"/dev/ttyACM0","D":": Undefined feed rate\r\n"}
2014/09/13 11:44:17 serial.go:514: Inside spWrite arg: send /dev/ttyACM0 G1X27.0779Y18.6558Z-0.0114F1016.0000
2014/09/13 11:44:17 serial.go:245: Got write to id:, port:/dev/ttyACM0, buffer:true, data:G1X27.0779Y18.6558Z-0.0114F1016.0000
2014/09/13 11:44:17 serial.go:376: itemsInBuffer:1
2014/09/13 11:44:17 serial.go:227: Send was normal send, so sending to wr.p.sendBuffered
2014/09/13 11:44:17 hub.go:82: Got a system broadcast: {"Cmd":"Queued","QCnt":1,"Type":["Buf"],"Ids":[""],"D":["G1X27.0779Y18.6558Z-0.0114F1016.0000\n"],"Port":"/dev/ttyACM0"}
2014/09/13 11:44:17 serialport.go:190: Got p.sendBuffered. data:G1X27.0779Y18.6558Z-0.0114F1016.0000
, id:
2014/09/13 11:44:17 serialport.go:202: About to send to p.sendNoBuf channel
2014/09/13 11:44:17 serialport.go:219: Got p.sendNoBuf. data:G1X27.0779Y18.6558Z-0.0114F1016.0000
, id:
2014/09/13 11:44:17 serialport.go:226: itemsInBuffer:0
2014/09/13 11:44:17 hub.go:82: Got a system broadcast: {"Cmd":"Write","QCnt":0,"Id":"","Buf":"Buf","P":"/dev/ttyACM0"}
2014/09/13 11:44:17 hub.go:82: Got a system broadcast: {"Cmd":"CompleteFake","Id":"","P":"/dev/ttyACM0","BufSize":-1}
2014/09/13 11:44:17 serialport.go:260: Just wrote 37 bytes to serial: G1X27.0779Y18.6558Z-0.0114F1016.0000
2014/09/13 11:44:17 hub.go:82: Got a system broadcast: {"P":"/dev/ttyACM0","D":"ok\r\n"}
I did download and installed the latest version of the serial port json server on my raspberry pi.
When I just remove the inline comments there are no errors, like error: Invalid gcode ID:24
and error: Undefined feed rate
.
ok
G21
ok
G90
G1Z5F2540
ok
ok
G1X27.0960Y18.7465F2540
ok
G1Z0.0000
ok
G1X27.0779Y18.6558Z-0.0114F1016.0000
ok
The logs from the serial port json server:
2014/09/13 12:04:41 hub.go:105: send /dev/ttyACM0 G21
2014/09/13 12:04:41 serial.go:514: Inside spWrite arg: send /dev/ttyACM0 G21
2014/09/13 12:04:41 serial.go:245: Got write to id:, port:/dev/ttyACM0, buffer:true, data:G21
2014/09/13 12:04:41 serial.go:376: itemsInBuffer:1
2014/09/13 12:04:41 serial.go:227: Send was normal send, so sending to wr.p.sendBuffered
2014/09/13 12:04:41 hub.go:82: Got a system broadcast: {"Cmd":"Queued","QCnt":1,"Type":["Buf"],"Ids":[""],"D":["G21\n"],"Port":"/dev/ttyACM0"}
2014/09/13 12:04:41 serialport.go:190: Got p.sendBuffered. data:G21
, id:
2014/09/13 12:04:41 serialport.go:202: About to send to p.sendNoBuf channel
2014/09/13 12:04:41 serialport.go:219: Got p.sendNoBuf. data:G21
, id:
2014/09/13 12:04:41 serialport.go:226: itemsInBuffer:0
2014/09/13 12:04:41 hub.go:82: Got a system broadcast: {"Cmd":"Write","QCnt":0,"Id":"","Buf":"Buf","P":"/dev/ttyACM0"}
2014/09/13 12:04:41 hub.go:82: Got a system broadcast: {"Cmd":"CompleteFake","Id":"","P":"/dev/ttyACM0","BufSize":-1}
2014/09/13 12:04:41 serialport.go:260: Just wrote 4 bytes to serial: G21
2014/09/13 12:04:41 hub.go:82: Got a system broadcast: {"P":"/dev/ttyACM0","D":"ok\r\n"}
2014/09/13 12:04:41 hub.go:105: send /dev/ttyACM0 G90
G1Z5F2540
2014/09/13 12:04:41 serial.go:514: Inside spWrite arg: send /dev/ttyACM0 G90
G1Z5F2540
2014/09/13 12:04:41 serial.go:245: Got write to id:, port:/dev/ttyACM0, buffer:true, data:G90
G1Z5F2540
2014/09/13 12:04:41 serial.go:376: itemsInBuffer:1
2014/09/13 12:04:41 serial.go:227: Send was normal send, so sending to wr.p.sendBuffered
2014/09/13 12:04:41 hub.go:82: Got a system broadcast: {"Cmd":"Queued","QCnt":1,"Type":["Buf"],"Ids":[""],"D":["G90\nG1Z5F2540\n"],"Port":"/dev/ttyACM0"}
2014/09/13 12:04:41 serialport.go:190: Got p.sendBuffered. data:G90
G1Z5F2540
, id:
2014/09/13 12:04:41 serialport.go:202: About to send to p.sendNoBuf channel
2014/09/13 12:04:41 serialport.go:219: Got p.sendNoBuf. data:G90
G1Z5F2540
, id:
2014/09/13 12:04:41 serialport.go:226: itemsInBuffer:0
2014/09/13 12:04:41 hub.go:82: Got a system broadcast: {"Cmd":"Write","QCnt":0,"Id":"","Buf":"Buf","P":"/dev/ttyACM0"}
2014/09/13 12:04:41 hub.go:82: Got a system broadcast: {"Cmd":"CompleteFake","Id":"","P":"/dev/ttyACM0","BufSize":-1}
2014/09/13 12:04:41 hub.go:82: Got a system broadcast: {"P":"/dev/ttyACM0","D":"ok\r\nok\r\n"}
2014/09/13 12:04:41 serialport.go:260: Just wrote 14 bytes to serial: G90
G1Z5F2540
2014/09/13 12:04:42 hub.go:105: send /dev/ttyACM0 G1X27.0960Y18.7465F2540
2014/09/13 12:04:42 serial.go:514: Inside spWrite arg: send /dev/ttyACM0 G1X27.0960Y18.7465F2540
2014/09/13 12:04:42 serial.go:245: Got write to id:, port:/dev/ttyACM0, buffer:true, data:G1X27.0960Y18.7465F2540
2014/09/13 12:04:42 serial.go:376: itemsInBuffer:1
2014/09/13 12:04:42 serial.go:227: Send was normal send, so sending to wr.p.sendBuffered
2014/09/13 12:04:42 hub.go:82: Got a system broadcast: {"Cmd":"Queued","QCnt":1,"Type":["Buf"],"Ids":[""],"D":["G1X27.0960Y18.7465F2540\n"],"Port":"/dev/ttyACM0"}
2014/09/13 12:04:42 serialport.go:190: Got p.sendBuffered. data:G1X27.0960Y18.7465F2540
, id:
2014/09/13 12:04:42 serialport.go:202: About to send to p.sendNoBuf channel
2014/09/13 12:04:42 serialport.go:219: Got p.sendNoBuf. data:G1X27.0960Y18.7465F2540
, id:
2014/09/13 12:04:42 serialport.go:226: itemsInBuffer:0
2014/09/13 12:04:42 hub.go:82: Got a system broadcast: {"Cmd":"Write","QCnt":0,"Id":"","Buf":"Buf","P":"/dev/ttyACM0"}
2014/09/13 12:04:42 hub.go:105: send /dev/ttyACM0 G1Z0.0000
2014/09/13 12:04:42 hub.go:82: Got a system broadcast: {"Cmd":"CompleteFake","Id":"","P":"/dev/ttyACM0","BufSize":-1}
2014/09/13 12:04:42 hub.go:82: Got a system broadcast: {"P":"/dev/ttyACM0","D":"ok"}
2014/09/13 12:04:42 serial.go:514: Inside spWrite arg: send /dev/ttyACM0 G1Z0.0000
2014/09/13 12:04:42 hub.go:82: Got a system broadcast: {"P":"/dev/ttyACM0","D":"\r\n"}
2014/09/13 12:04:42 serialport.go:260: Just wrote 24 bytes to serial: G1X27.0960Y18.7465F2540
Ah, I see that when there where inline comments 2 lines where combined:
G90G1Z5F2540
Where the filtered gcode send:
G90 G1Z5F2540
Just found the interesting bit, indeed in the GRBL widget
http://jsfiddle.net/jarret/T6Bz5/ > line 370 below //remove whitespace & cut off comments
.
This seems to works fine on a per line basis:
http://jsfiddle.net/tq045jm6/1/
Thanks Peter, I think the problem is that I was truncating the comments but not adding the line feeds back in to signal to the SPJS buffer that each of those lines needed to be queued separately. I have added back the line feed to each line where the comments get removed: if(l_block.indexOf("(") >= 0) l_block = l_block.substring(0,l_block.indexOf("(")) + "\n"; if(l_block.indexOf(";") >= 0) l_block = l_block.substring(0,l_block.indexOf(";")) + "\n"; and this now works both in single line send mode and multi-line/pre-upload modes that are buffering the code on the server side.
Hope that is the same issue you were describing! :)
Ah makes sense, great! If now sends the commands without errors:
G21
ok
G90
ok
G1Z2.54F2540
ok
G1X27.0960Y18.7465F2540
ok
In serial port json server I see that they are send correctly:
hub.go:105: send /dev/tty.usbmodemfd131 G21
hub.go:105: send /dev/tty.usbmodemfd131 G90
hub.go:105: send /dev/tty.usbmodemfd131 G1Z2.54F2540
hub.go:105: send /dev/tty.usbmodemfd131 G1X27.0960Y18.7465F2540
I need to test this again on our actual cnc mill, but I'll close it for now.
When sending a file (generated by jscut) I noticed that it didn't go to the clearance height at start.
When I changed this to the following it did go to the clearance height.
In the Serial Port Console I saw the following relevant messages: