{"issue":{"title":"Error when streaming G-Code","user":{"login":"cody82","id":363688,"url":"https://api.github.com/users/cody82","avatar_url":"https://secure.gravatar.com/avatar/0a22fe2af081088d1699f8b60d7565e8?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-140.png","gravatar_id":"0a22fe2af081088d1699f8b60d7565e8"},"created_at":"2011-12-28T15:37:41Z","milestone":null,"labels":[],"state":"open","updated_at":"2011-12-29T15:11:36Z","id":2672086,"closed_at":null,"html_url":"https://github.com/chamnit/grbl/issues/7","pull_request":{"patch_url":null,"html_url":null,"diff_url":null},"body":"With version 0.8a i get the following error when streaming G-code with stream.rb:\r\n(I think it worked with version 0.6)\r\n\r\nG0Z20.000\r\nGrbl >> ok\r\nG0X0.000Y0.000S1500\r\nGrbl >> ok\r\nG0X-18.525Y45.387Z6.000\r\nGrbl >> ok\r\nG1Z-2.000F200.0\r\nGrbl >> ok\r\nG1X-27.064F800.0\r\nGrbl >> ok\r\nX-27.143Y45.390\r\nGrbl >> ok\r\nX-27.225Y45.400\r\nGrbl >> ok\r\nX-27.308Y45.417\r\nGrbl >> ok\r\nX-27.391Y45.442\r\nGrbl >> ok\r\nX-27.473Y45.474\r\nGrbl >> ok\r\nX-27.553Y45.515\r\nGrbl >> ok\r\nX-27.630Y45.563\r\nGrbl >> ok\r\nX-27.703Y45.618\r\nGrbl >> ok\r\nX-27.771Y45.680\r\nGrbl >> ok\r\nX-27.833Y45.748\r\nGrbl >> ok\r\nX-27.888Y45.821\r\nGrbl >> ok\r\nX-27.936Y45.898\r\nGrbl >> ok\r\nX-27.976Y45.978\r\nGrbl >> ok\r\nX-28.009Y46.060\r\nGrbl >> ok\r\nX-28.033Y46.143\r\nGrbl >> ok\r\nX-28.051Y46.226\r\nGrbl >> ok\r\nX-28.061Y46.307\r\nGrbl >> ok\r\nX-28.064Y46.387\r\nGrbl >> ok\r\nY61.387\r\nGrbl >> ok\r\nX-28.061Y61.467\r\nGrbl >> ok\r\nX-28.051Y61.548\r\nGrbl >> ok\r\nX-28.033Y61.631\r\nGrbl >> ok\r\nX-28.009Y61.714\r\nGrbl >> ok\r\nX-27.976Y61.796\r\nGrbl >> ok\r\nX-27.936Y61.876\r\nGrbl >> ok\r\nX-27.888Y61.953\r\nGrbl >> ok\r\nX-27.833Y62.026\r\nGrbl >> ok\r\nX-27.771Y62.094\r\nGrbl >> ok\r\nX-27.703Y62.156\r\nGrbl >> ok\r\nX-27.630Y62.211\r\nGrbl >> ok\r\nX-27.553Y62.259\r\nGrbl >> ok\r\nX-27.473Y62.300\r\nGrbl >> ok\r\nX-27.391Y62.332\r\nGrbl >> ok\r\nX-27.308Y62.357\r\nGrbl >> ok\r\nX-27.225Y62.374\r\nGrbl >> ok\r\nX-27.143Y62.384\r\nGrbl >> ok\r\nX-27.064Y62.387\r\nGrbl >> ok\r\nX-18.525\r\nGrbl >> ok\r\nX-18.445Y62.384\r\nGrbl >> ok\r\nX-18.364Y62.374\r\nGrbl >> ok\r\nX-18.281Y62.357\r\nGrbl >> ok\r\nX-18.198Y62.332\r\nGrbl >> ok\r\nX-18.116Y62.300\r\nGrbl >> ok\r\nX-18.036Y62.259\r\nGrbl >> ok\r\nX-17.959Y62.211\r\nGrbl >> ok\r\nX-17.886Y62.156\r\nGrbl >> ok\r\nX-17.818Y62.094\r\nGrbl >> ok\r\nX-17.756Y62.026\r\nGrbl >> ok\r\nX-17.701Y61.953\r\nGrbl >> ok\r\nX-17.653Y61.876\r\nGrbl >> ok\r\nX-17.613Y61.796\r\nGrbl >> ok\r\nX-17.580Y61.714\r\nGrbl >> ok\r\nX-17.555Y61.631\r\nGrbl >> ok\r\nX-17.538Y61.548\r\nGrbl >> ok\r\nX-17.528Y61.467\r\nGrbl >> ok\r\nX-17.525Y61.387\r\nGrbl >> error: Bad number format\r\n\r\n","number":7,"url":"https://api.github.com/repos/chamnit/grbl/issues/7","comments":6,"assignee":null},"comment":{"user":{"login":"chamnit","id":948029,"url":"https://api.github.com/users/chamnit","avatar_url":"https://secure.gravatar.com/avatar/c6211c5530a0f0f269beaafd07ccb0c8?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-140.png","gravatar_id":"c6211c5530a0f0f269beaafd07ccb0c8"},"created_at":"2011-12-29T15:11:36Z","updated_at":"2011-12-29T15:11:36Z","id":3301402,"body":"Interesting. Still not exactly sure what would be causing this issue, although we have narrowed down that the Ruby script may no longer be compatible (hasn't been updated in a while and has a newly discovered bug with prebuffering arcs). I attached the Python script I have been using. Sorry, still hardcoded filename. I've been meaning to work on this and include into the release, but haven't had the time. \r\n\r\nGrbl can hold and plan for up to 18-20 blocks (depending on the build version) in memory. Prebuffering ensures that these blocks are put into memory as fast as grbl can process them, while the steppers are moving. You generally want to keep the buffer full, since the planner will always plan to bring everything to a stop with the last block in memory. It will make grbl run faster and smoother.\r\n\r\nIf you have some time, could you test the v0.7c build as well? I have a hunch that a variable type 'correction' that I had made on v0.7d and v0.8a might be causing this problem. Hopefully it's that.\r\n\r\n\r\n```python\r\n#!/usr/bin/env python\r\n\"\"\"\\\r\nStream g-code to grbl controller\r\n\"\"\"\r\n\r\nimport serial\r\nimport re\r\nimport glob\r\nimport time\r\nimport sys\r\n# import getopt\r\n\r\ndevice_str = '/dev/tty.usbmodem*'  # Serial port device string. Wildcards OK.\r\nfilename = 'grbl.gcode'\r\nRX_BUFFER_SIZE = 127\r\nverbose = True\r\n# TODO: Single block mode\r\n# TODO: Complete command line interface\r\n\r\n# Search for serial device and returns name(s).\r\ndef scan():\r\n    return glob.glob(device_str)\r\n\r\n# Search for and open Arduino port based on search string\r\nportscan = scan()\r\nif len(portscan) != 1 :\r\n    print \"No port or multiple ports found:\",portscan\r\n    sys.exit()\r\nprint \"Grbl port found: \",\r\ns = serial.Serial(portscan[0],9600)\r\n\r\n# Open g-code file\r\nf = open(filename,'r');\r\n\r\n# Wake up grbl\r\nprint \"Initializing grbl...\"\r\ns.write(\"\\r\\n\\r\\n\")\r\n\r\n# Wait for grbl to initialize and flush startup text in serial input\r\ntime.sleep(2)\r\ns.flushInput()\r\n\r\n# Stream g-code to grbl\r\nprint \"Streaming [\",filename,\"] to grbl...\"\r\nl_count = 0\r\ng_count = 0\r\nc_line = []\r\nfor line in f:\r\n    l_count += 1 # Iterate line counter\r\n#     l_block = re.sub('\\s|\\(.*?\\)','',line).upper() # Strip comments/spaces/new line and capitalize\r\n    l_block = line.strip()\r\n    c_line.append(len(l_block))\r\n    grbl_out = '' \r\n    while sum(c_line) > RX_BUFFER_SIZE | s.inWaiting() :\r\n        out_temp = s.readline().strip() # Wait for grbl response\r\n        if out_temp not in ['ok','error'] :\r\n            print \"  Debug: \",out_temp # Debug response\r\n        else :\r\n            grbl_out += out_temp;\r\n            g_count += 1 # Iterate g-code counter\r\n            grbl_out += str(g_count); # Add line finished indicator\r\n            del c_line[0]\r\n    if verbose: print \"SND: \" + str(l_count) + \" : \" + l_block,\r\n    s.write(l_block + '\\n') # Send block to grbl\r\n    if verbose : print \"BUF:\",str(sum(c_line)),\"REC:\",grbl_out\r\n\r\n# Wait for user input after streaming is completed\r\nprint \"G-code streaming finished!\\n\"\r\nprint \"WARNING: Wait until grbl completes buffered g-code blocks before exiting.\"\r\nraw_input(\"  Press <Enter> to exit and disable grbl.\") \r\n\r\n# Close file and serial port\r\nf.close()\r\ns.close()    \r\n```","url":"https://api.github.com/repos/chamnit/grbl/issues/comments/3301402"},"action":"created"}