Marlin Api
This module provides a class to interact with the Marlin firmware.
ATTRIBUTE | DESCRIPTION |
---|---|
LOOP_INTERVAL |
loop interval for checking status
TYPE:
|
MOVEMENT_TIMEOUT |
timeout for movement
TYPE:
|
READ_FORMAT |
read format for serial communication
TYPE:
|
WRITE_FORMAT |
write format for serial communication
TYPE:
|
Data |
data structure for serial communication
TYPE:
|
CLASS | DESCRIPTION |
---|---|
Marlin |
Marlin class provides methods to interact with the Marlin firmware. |
Marlin
Marlin(
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
Marlin class provides methods to interact with the Marlin firmware.
Refer to https://marlinfw.org/meta/gcode/ for more information on the Marlin 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:
getInfo: Query device information
getSettings: Query device settings
getStatus: Query device status
halt: Halt the device
home: Home the device
setSpeedFactor: Set the speed factor in the device
connect: Connect to the device
query: Query the device (i.e. write and read data)
clear: clear the input and output buffers
connect: connect to the device
disconnect: disconnect from the device
read: read data from the device
write: write data to the device
Initialize Marlin 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.
getInfo
Query device information
RETURNS | DESCRIPTION |
---|---|
dict[str, str]
|
dict[str, str]: information in the response |
getSettings
Query device settings
RETURNS | DESCRIPTION |
---|---|
dict[str, int | float | str]
|
dict[str, int|float|str]: settings 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 |
halt
halt() -> Position
Halt the device
RETURNS | DESCRIPTION |
---|---|
Position
|
current position of the device
TYPE:
|
home
Home the device
PARAMETER | DESCRIPTION |
---|---|
axis
|
axis to home. Defaults to None.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
bool
|
whether the device was homed
TYPE:
|
query
query(
data: Any,
multi_out: bool = True,
*,
timeout: int | float = 1,
wait: bool = False,
**kwargs,
) -> list[str] | None
Query the device (i.e. write and read data)
PARAMETER | DESCRIPTION |
---|---|
data
|
data to write to the device
TYPE:
|
multi_out
|
whether to read multiple lines of data. Defaults to True.
TYPE:
|
timeout
|
timeout for reading data. Defaults to 1.
TYPE:
|
wait
|
whether to wait for the device to be idle. Defaults to False.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
list[str] | None
|
list[str]|None: response from the device |