FluidNC API reference¤
A subclass should be created from the parent fluidpy.FluidNC and can implement one or more of the handle_* methods
to receive callbacks when certain messages are received.
FluidNC Usage Example¤
Each platform will have a different mechanism for communicating with the controller, and will
each require a different BufferInterface implementation, defining read, write and readline methods. See
examples directory for CircuitPython and Python implementations.
Subclass fluidpy.FluidNC and implement handle_version method which is called when the controller has started.
Once the I/O interface is defined, instantiate subclass of fluidpy.FluidNC and call the listen method.
from fluidpy import FluidNC
class MyFluidExpander(FluidNC):
"""
Implement one or more 'handle_*' methods to receive incoming messages
"""
def __init__(self, io: BufferInterface) -> None:
super().__init__(io)
def handle_version(self, message: str) -> None:
print(f"Version: {message}")
io = MyBufferInterface()
fluid = MyFluidExpander(io)
fluid.listen()
API¤
FluidNC
¤
FluidNC(io: BufferInterface)
handle_accessory_state
¤
handle_accessory_state(state: str)
Parameters:
-
(state¤str) –accessor state information
handle_exp_io
¤
handle_feed
¤
handle_feed(feed_rate: DecimalNumber) -> None
Parameters:
-
(feed_rate¤DecimalNumber) –in mm/min or inches/min
handle_line_number
¤
handle_line_number(line_number: int) -> None
Parameters:
-
(line_number¤int) –current line number
handle_log
¤
handle_log(level: str, message: str) -> None
Parameters
level: one of DBG, INFO, WARN, ERROR
message: log message
handle_machine_state
¤
handle_machine_state(state: str) -> None
Parameters:
-
(state¤str) –one of one of
['Idle', 'Run', 'Hold', 'Jog', 'Alarm', 'Door', 'Check', 'Home', 'Sleep']
handle_mode
¤
handle_mode_command
¤
handle_mode_command(mode_cmd: str, status: str = 'None') -> None
Parameters:
-
(mode_cmd¤str) –one of
G54,G55,G56,G57,G58,G59,G28,G30,G92
handle_overrides
¤
handle_position
¤
handle_spindle
¤
handle_spindle(spindle_speed: DecimalNumber) -> None
Parameters:
-
(spindle_speed¤DecimalNumber) –in RPM
handle_tlo
¤
handle_tlo(message: str) -> None
Parameters:
-
(message¤str) –tool length offset message
handle_triggers
¤
handle_triggers(triggers: str) -> None
Parameters:
-
(triggers¤str) –X Y Z A B CXYZABC limit pins, respectivelyP> the probe pin. -T> the tool setter pinD H R S> the door, hold, soft-reset, and cycle-start pins, respectively
handle_variable
¤
Position
¤
Attributes:
-
a(DecimalNumber) –a value of the position
-
b(DecimalNumber) –b value of the position
-
c(DecimalNumber) –c value of the position
-
x(DecimalNumber) –x value of the position
-
y(DecimalNumber) –y value of the position
-
z(DecimalNumber) –z value of the position
Mode
¤
Attributes:
-
coolant–'MIST'(M7),'FLOOD'(M8),'OFF'(M9) -
feed_rate–feed rate
-
feed_rate_mode–'INVERSE'(G93),'UNITS/MIN'(G94),'UNITS/REV'(G95) -
is_absolute–absolute (G90), relative (G91)
-
is_inches–inches (G20), mm (G21)
-
is_rapid–rapid mode (G0), feed rate mode (G1)
-
plane–'XY'(G17),'XZ'(G18),'YZ'(G19) -
spindle_speed–spindle speed
-
spindle_state–'CW'(M3),'CCW'(M4),'STOP'(M5) -
tool_number–tool number 0-9
-
wco_index–work coordinate offset of
0(G53),1(G54),2(G55), etc