M-Bus
api.mbusTransaction(msg, timeout, retry)
- Overview
- Arguments
- Return
- Example
Transmit "msg" and wait given "timeout" milliseconds for the answer. The transmission is retried "retry" times.
Turn on MBus using mbusState first.
- msg (string) - Message sent to MBus
- timeout (integer) - The maximum time in milliseconds to wait for answer from MBus device
- retry (integer) - Optional number of retransmissions, default number is 1
- status (integer) - Number of bytes received, zero on failure
- c (integer) - MBus c frame field
- a (integer) - MBus a frame field
- ci (integer) - MBus ci frame field
- answer (string) - MBus frame payload received from the bus
--Send MBus frame [0x10, 0x50, 0x30, 0x16] and wait 5s for the answer twice
msg = pack.pack('<b4', 0x10, 0x50, 0x30, 0x16)
status,c,a,ci,ans = api.mbusTransaction(msg, 5000, 2)
api.mbusSetup(baudrate, parity, stopBits, dataBits)
- Overview
- Arguments
- Example
Configures the MBus communication interface. Configuration from GUI is used by default, but it can be overriden using this function.
Turn on M-Bus using mbusState after setting up M-Bus parameters using this function.
- baudrate (integer) - Baudrate to use for communication (up to 921600 baud)
- parity (integer) - Parity, 0 for none, 1 for odd and 2 for even parity
- stopBits (integer) - Number of stop bits, 1 or 2 allowed
- dataBits (integer) - Number of data bits, 7 or 8 allowed
--setup M-Bus interface to 9600 Baud, 8E2
api.mbusSetup(9600, 2, 2, 8)
api.mbusState(state)
- Overview
- Arguments
- Example
Turns on the M-Bus circuitry.
Must be used before function api.mbusTransaction().
- state (integer) - New state of MBus circuitry: 0 for off, 1 for on (apprx 30s power-up)
api.mbusState(1) --turn on M-Bus