Welcome to Our Community

Some features disabled for guests. Register Today.

Python Serial Communication with Blackbox

Discussion in 'General Talk' started by Micah Beckman, Oct 11, 2021.

  1. Micah Beckman

    Builder

    Joined:
    Aug 19, 2021
    Messages:
    2
    Likes Received:
    0
    I'm getting different responses from the Blackbox (using pyserial) depending on whether or not the OpenBuilds CONTROL software is connected to the Blackbox. I know there are conflicts when you have more than one program connected to the same device over serial. I've been able to send commands to the Blackbox using python3.9 with the following code:

    import serial

    ser = serial.Serial(port='/dev/ttyUSB0', baudrate=115200)
    ser.write('\r\n\r\n'.encode('ascii')) # initialize Grbl
    ser.write('?\r\n'.encode('ascii')) # get status
    ser.readline().strip().decode('utf-8')

    Here's what's odd.

    When the OpenBuilds CONTROL software is connected, I get the following output when I send the '?' command:

    '<Idle|WPos:0.000,-12.998,-43.998|Bf:15,128|FS:0,0>'

    When the OpenBuilds CONTROL software is not connected, I get the following output when I send the '?' command:

    'ok'

    I'm curious as to why this is. I'd like to get the Blackbox status when the CONTROL software is not connected. Does anyone know what might be the reason for this? Thank you in advance.
     
  2. Peter Van Der Walt

    Peter Van Der Walt OpenBuilds Team
    Staff Member Moderator Builder Resident Builder

    Joined:
    Mar 1, 2017
    Messages:
    15,046
    Likes Received:
    4,313
    Getting status feedback: see Grbl v1.1 Interface · gnea/grbl Wiki (no newline... The newline is seperately into the buffer and thus gets the ok)

    Only send "?"
     
  3. Micah Beckman

    Builder

    Joined:
    Aug 19, 2021
    Messages:
    2
    Likes Received:
    0
    Nailed it. Thank you.
     

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice