User Tools

Site Tools

한국어

logicpython:cubloc_api:setmodbus

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
logicpython:cubloc_api:setmodbus [2026/04/14 04:57] – [Parameters] mfranklinlogicpython: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**: Writable holding-register byte buffer (2 bytes per register).     * **holdingRegisters**: Writable holding-register byte buffer (2 bytes per register).
     * **memoryLock**: lock object to synchronize Modbus memory access between the user program and the Modbus RTU slave process.     * **memoryLock**: lock object to synchronize Modbus memory access between the user program and the Modbus RTU slave process.
-    * **returnInterval**: Non-blocking delay in microseconds before sending response (default 0).+    * **returnInterval**: Delay in microseconds before replying to Modbus query from the Modbus master (default 0).
  
 ''protocol'' bit layout: ''protocol'' bit layout:
Line 69: Line 69:
 INPUT_PINS  = (6,  8,  10) INPUT_PINS  = (6,  8,  10)
 ADC_CHANS   = (0,  1,  2) ADC_CHANS   = (0,  1,  2)
- 
-coils           = bytearray(1) 
-discrete_inputs = bytearray(1) 
-input_regs      = bytearray(6) 
-holding_regs    = bytearray(2) 
-mem_lock        = _thread.allocate_lock() 
  
 for pin in OUTPUT_PINS: for pin in OUTPUT_PINS:
Line 82: Line 76:
     Input(pin)     Input(pin)
  
-SetModbus(09600364641, coils, discrete_inputs, input_regs, holding_regs, mem_lock)+# 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      = bytearray(6) 
 +holding_regs    = bytearray(2) 
 +mem_lock        = _thread.allocate_lock() 
 + 
 +SetModbus(UART_CHANNEL, 
 +    BAUD_RATE, 
 +    PROTOCOL, 
 +    BUFFER_SIZE, 
 +    BUFFER_SIZE, 
 +    SLAVE_ADDRESS 
 +    coils, discrete_inputs, input_regs, holding_regs, mem_lock)
  
 while True: while True:
logicpython/cubloc_api/setmodbus.1776142634.txt.gz · Last modified: by mfranklin