This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
| logicpython:cubloc_api:setmodbus [2026/04/14 04:57] – [Parameters] mfranklin | logicpython:cubloc_api:setmodbus [2026/04/14 05:10] (current) – [Example] mfranklin | ||
|---|---|---|---|
| Line 1: | Line 1: | ||
| ====== SetModbus ====== | ====== SetModbus ====== | ||
| - | Configure UART settings and start the LogicPython Modbus RTU slave worker. | + | Configure UART settings and start the LogicPython Modbus RTU slave process. |
| ===== Syntax ===== | ===== Syntax ===== | ||
| Line 35: | Line 35: | ||
| * **holdingRegisters**: | * **holdingRegisters**: | ||
| * **memoryLock**: | * **memoryLock**: | ||
| - | * **returnInterval**: | + | * **returnInterval**: |
| '' | '' | ||
| Line 69: | Line 69: | ||
| INPUT_PINS | INPUT_PINS | ||
| ADC_CHANS | ADC_CHANS | ||
| - | |||
| - | coils = bytearray(1) | ||
| - | discrete_inputs = bytearray(1) | ||
| - | input_regs | ||
| - | holding_regs | ||
| - | mem_lock | ||
| for pin in OUTPUT_PINS: | for pin in OUTPUT_PINS: | ||
| Line 82: | Line 76: | ||
| Input(pin) | Input(pin) | ||
| - | SetModbus(0, 9600, 3, 64, 64, 1, coils, discrete_inputs, | + | # Configure and start the Modbus RTU slave process |
| + | UART_CHANNEL = 0 | ||
| + | BAUD_RATE = 115200 | ||
| + | PROTOCOL = 3 # 8N1 | ||
| + | BUFFER_SIZE = 64 | ||
| + | SLAVE_ADDRESS = 1 | ||
| + | |||
| + | coils = bytearray(1) | ||
| + | discrete_inputs = bytearray(1) | ||
| + | input_regs | ||
| + | holding_regs | ||
| + | mem_lock | ||
| + | |||
| + | SetModbus(UART_CHANNEL, | ||
| + | BAUD_RATE, | ||
| + | PROTOCOL, | ||
| + | BUFFER_SIZE, | ||
| + | BUFFER_SIZE, | ||
| + | SLAVE_ADDRESS, | ||
| + | | ||
| while True: | while True: | ||