Grbl Api
GRBL API for controlling CNC machines using the GRBL firmware. Refer to https://github.com/gnea/grbl/tree/master/doc/markdown for more information on the GRBL firmware.
ATTRIBUTE | DESCRIPTION |
---|---|
LOOP_INTERVAL |
loop interval for device
TYPE:
|
MOVEMENT_TIMEOUT |
timeout for movement
TYPE:
|
READ_FORMAT |
read format for device
TYPE:
|
WRITE_FORMAT |
write format for device
TYPE:
|
Data |
data for device
TYPE:
|
CLASS | DESCRIPTION |
---|---|
GRBL |
GRBL class for controlling CNC machines using the GRBL firmware. |
Documentation last updated: 2025-02-22
GRBL
GRBL(
port: str | None = None,
baudrate: int = 115200,
timeout: int = 1,
init_timeout: int = 2,
message_end: str = "\n",
*args,
simulation: bool = False,
**kwargs,
)
Bases: SerialDevice
GRBL class for controlling CNC machines using the GRBL firmware.
Refer to https://github.com/gnea/grbl/tree/master/doc/markdown for more information on the GRBL firmware.
Attributes:
port (str): device serial port
baudrate (int): device baudrate
timeout (int): device timeout
connection_details (dict): connection details for the device
serial (serial.Serial): serial object for the device
init_timeout (int): timeout for initialization
message_end (str): message end character
flags (SimpleNamespace[str, bool]): flags for the device
is_connected (bool): whether the device is connected
verbose (bool): verbosity of class
Methods:
getAlarms: check for alarms in the response
getErrors: check for errors in the response
getInfo: query device information
getParameters: query device parameters
getSettings: query device settings
getState: query device state
getStatus: query device status
clearAlarms: clear alarms in the response
halt: halt the device
home: home the device
resume: resume activity on the device
setSpeedFactor: set the speed factor in the device
clear: clear the input and output buffers
connect: connect to the device
disconnect: disconnect from the device
query: query the device (i.e. write and read data)
read: read data from the device
write: write data to the device
Initialize GRBL class
Args:
port (str|None): Serial port to connect to. Defaults to None.
baudrate (int): baudrate for serial communication. Defaults to 115200.
timeout (int): timeout for serial communication. Defaults to 1.
init_timeout (int): timeout for initialization of serial communication. Defaults to 2.
message_end (str): message end character for serial communication. Defaults to '
'. simulation (bool): simulation mode for testing. Defaults to False.
getAlarms
Checks for alarms in the response
PARAMETER | DESCRIPTION |
---|---|
response
|
response
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
bool
|
whether an alarm was found
TYPE:
|
getErrors
Checks for errors in the response
PARAMETER | DESCRIPTION |
---|---|
response
|
response
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
bool
|
whether an error was found
TYPE:
|
getInfo
Query device information
RETURNS | DESCRIPTION |
---|---|
list[str]
|
list[str]: information in the response |
getParameters
Query device parameters
RETURNS | DESCRIPTION |
---|---|
dict[str, list[float]]
|
dict[str, list[float]]: parameters in the response |
getSettings
Query device settings
RETURNS | DESCRIPTION |
---|---|
dict[str, int | float | str]
|
dict[str, int|float|str]: settings in the response |
getState
Query device state
RETURNS | DESCRIPTION |
---|---|
dict[str, str]
|
dict[str, str]: state in the response |
getStatus
Query device status
RETURNS | DESCRIPTION |
---|---|
tuple[str, ndarray[float], ndarray[float]]
|
tuple[str, np.ndarray[float], np.ndarray[float]]: status, current position, home offset |
home
Home the device
PARAMETER | DESCRIPTION |
---|---|
axis
|
axis to home. Defaults to None.
TYPE:
|
timeout
|
timeout for homing
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
bool
|
whether the device was homed
TYPE:
|
query
query(
data: Any,
multi_out: bool = True,
*,
timeout: int | float = 1,
jog: bool = False,
wait: bool = False,
**kwargs,
) -> list[str] | None
Query the device (i.e. write and read data)
PARAMETER | DESCRIPTION |
---|---|
data
|
data to query
TYPE:
|
multi_out
|
whether to read lines
TYPE:
|
timeout
|
timeout for query
TYPE:
|
jog
|
whether to perform jog movements
TYPE:
|
wait
|
whether to wait for the device to reach the status
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
list[str] | None
|
list[str]|None: response from the device |