Radiocraft Wireless M-Bus extension module  2.18
Modcall C functions

These functions can be called from VPL using the MODCALL keyword. More...

Functions

static int32 MODDECL mbusCallOpen (HANDLE *pCPU, void *pBase)
 Open communication interface to the module. More...
 
static int32 MODDECL mbusCallClose (HANDLE *pCPU, void *pBase)
 Close communication interface to the module. More...
 
static int32 MODDECL mbusCallFilterReceive (HANDLE *pCPU, void *pBase)
 Check if any MBUS packets has been received for a given filter. More...
 
static int32 MODDECL mbusCallReceive (HANDLE *pCPU, void *pBase)
 Check if any MBUS packets has been received. More...
 
static int32 MODDECL mbusCallSend (HANDLE *pCPU, void *pBase)
 Send a MBUS message. More...
 
static int32 MODDECL mbusCallInfo (HANDLE *pCPU, void *pBase)
 Perform a series of tests to validate communication. More...
 
static int32 MODDECL mbusCallFilterEnable (HANDLE *pCPU, void *pBase)
 Set mode. More...
 
static int32 MODDECL mbusCallRegisterSlave (HANDLE *pCPU, void *pBase)
 Register a slave device. More...
 
static int32 MODDECL mbusCallGetBufferLevel (HANDLE *pCPU, void *pBase)
 Get the actual level of how full the buffer is in promille. More...
 

Detailed Description

These functions can be called from VPL using the MODCALL keyword.

Function Documentation

◆ mbusCallClose()

static int32 MODDECL mbusCallClose ( HANDLE *  pCPU,
void *  pBase 
)
static

Close communication interface to the module.

Parameters
[in]pCPUThe handle to the system.
[in]pBasePointer to structure with function parameters.
Returns
0 Close successfull
-1 Failed to stop device
-2 List clean-up failure
-3 Failed to stop device and list clean-up failure

Definition at line 2095 of file mod_mbus.c.

References lock, mbusClose(), mbusDebug(), mbusStopReader(), MUTEX_LOCK, and MUTEX_UNLOCK.

Referenced by moduleInit().

◆ mbusCallFilterEnable()

static int32 MODDECL mbusCallFilterEnable ( HANDLE *  pCPU,
void *  pBase 
)
static

Set mode.

Parameters
[in]pCPUThe handle to the system.
[in]pBasePointer to structure with function parameters.
Returns
-1 Interface error

Definition at line 2302 of file mod_mbus.c.

References lock, mbus_config(), mbusClose(), mbusDebug(), mbusOpen(), MUTEX_LOCK, MUTEX_UNLOCK, mbus_set_filter::only_installed, and rssi_included.

Referenced by moduleInit().

◆ mbusCallFilterReceive()

static int32 MODDECL mbusCallFilterReceive ( HANDLE *  pCPU,
void *  pBase 
)
static

Check if any MBUS packets has been received for a given filter.

Parameters
[in]pCPUThe handle to the system.
[in]pBasepointer to VPL functions data structure
Returns
1 New data available
0 Buffer empty or no matching frame from slave registered
-1 Failed to access receive interface
-2 M-Bus interface is not open
-3 Invalid input
-4 No slave registered with this index

Definition at line 2123 of file mod_mbus.c.

References mbus_filter_receive::frame, mbus_slave_address::id, mbus_filter_receive::idx, lock, mbus_slave_address::manufacturer, MAX_SLAVE_REGISTERS, mbus_slave_register, mbusBufferReceive(), mbusDebug(), MUTEX_LOCK, MUTEX_UNLOCK, mbus_slave_address::type, and mbus_slave_address::version.

Referenced by moduleInit().

◆ mbusCallGetBufferLevel()

static int32 MODDECL mbusCallGetBufferLevel ( HANDLE *  pCPU,
void *  pBase 
)
static

Get the actual level of how full the buffer is in promille.

Parameters
[in]pCPUThe handle to the system.
[in]pBasePointer to structure with function parameters.
Returns
buffer full level in promille
-1 Interface error

Definition at line 2365 of file mod_mbus.c.

References lock, mbusDebug(), mbusGetBufferLevel(), MUTEX_LOCK, and MUTEX_UNLOCK.

Referenced by moduleInit().

◆ mbusCallInfo()

static int32 MODDECL mbusCallInfo ( HANDLE *  pCPU,
void *  pBase 
)
static

Perform a series of tests to validate communication.

Perform a series of test by reading out configuration values to validate communication to module, result is send to device output.

Prints:

  • Signal strength
  • Signal quality
  • Temperature monitoring
  • Battery Monitoring
  • MBUS_MODE
  • DATA_INTERFACE
  • PART_NUMBER
  • HW_REV_NO
  • FW_REV_NO
  • SERIAL_NUMBER
  • INSTALL_MODE
  • RSSI_MODE

Result

mbus_test:Signal quality = 0
mbus_test:RSSI           = 205 (-102 dBm)
mbus_test:Temperature    = 32 C
mbus_test:VCC            = 3450mV
mbus_test:MBUS_MODE      = 0x01
mbus_test:DATA_INTERFACE = 0x00
mbus_test:PART_NUMBER    = RC1180-MBUS3
mbus_test:HW_REV_NO      = 2.00
mbus_test:FW_REV_NO      = 3.15
mbus_info:SERIAL_NUMBER  = 01 23 45 67 89 AB CD EF
mbus_info:INSTALL_MODE   = 0x02
mbus_info:RSSI_MODE      = 0x01
Parameters
[in]pCPUThe handle to the system.
[in]pBasepointer to VPL functions data structure
Returns
0 Message send
-1 Interface error
-2 Module failure

Definition at line 2274 of file mod_mbus.c.

References lock, mbus_info(), mbusClose(), mbusDebug(), mbusOpen(), MUTEX_LOCK, MUTEX_UNLOCK, and rssi_included.

Referenced by moduleInit().

◆ mbusCallOpen()

static int32 MODDECL mbusCallOpen ( HANDLE *  pCPU,
void *  pBase 
)
static

Open communication interface to the module.

Parameters
[in]pCPUThe handle to the system.
[in]pBasePointer to structure with function parameters.
Returns
-1 Interface error

Definition at line 2068 of file mod_mbus.c.

References lock, mbus_open::max_frames, mbusDebug(), mbusOpen(), mbusStartReader(), mbus_open::mode, MUTEX_LOCK, MUTEX_UNLOCK, mbus_open::overwrite, and mbus_open::rssi.

Referenced by moduleInit().

◆ mbusCallReceive()

static int32 MODDECL mbusCallReceive ( HANDLE *  pCPU,
void *  pBase 
)
static

Check if any MBUS packets has been received.

Parameters
[in]pCPUThe handle to the system.
[in]pBasepointer to VPL functions data structure
Returns
1 New data available
0 Buffer empty or no matching frame from slave address in buffer
-1 Failed to access receive interface
-2 M-Bus interface is not open.

Definition at line 2160 of file mod_mbus.c.

References mbus_receive::frame, mbus_receive::id, mbus_slave_address::id, lock, mbus_receive::manufacturer, mbus_slave_address::manufacturer, mbusBufferReceive(), mbusDebug(), MUTEX_LOCK, MUTEX_UNLOCK, mbus_receive::timeout, mbus_receive::type, mbus_slave_address::type, mbus_receive::version, and mbus_slave_address::version.

Referenced by moduleInit().

◆ mbusCallRegisterSlave()

static int32 MODDECL mbusCallRegisterSlave ( HANDLE *  pCPU,
void *  pBase 
)
static

Register a slave device.

It is stored persistently.

Parameters
[in]pCPUThe handle to the system.
[in]pBasePointer to structure with function parameters.
Returns
-1 Interface error

Definition at line 2331 of file mod_mbus.c.

References mbus_reg_slave::id, mbus_reg_slave::idx, mbus_reg_slave::key, lock, mbus_reg_slave::manufacturer, mbus_register_slave(), mbusClose(), mbusDebug(), mbusOpen(), MUTEX_LOCK, MUTEX_UNLOCK, rssi_included, mbus_reg_slave::type, and mbus_reg_slave::version.

Referenced by moduleInit().

◆ mbusCallSend()

static int32 MODDECL mbusCallSend ( HANDLE *  pCPU,
void *  pBase 
)
static

Send a MBUS message.

Parameters
[in]pCPUThe handle to the system.
[in]pBasepointer to VPL functions data structure
Returns
0 Message sent
-1 Invalid parameter.
-2 Failed to send message

Definition at line 2190 of file mod_mbus.c.

References mbus_send::control, mbus_send::data, mbus_send::length, lock, MBUS_DATA_LENGTH, mbusClose(), mbusDebug(), mbusOpen(), mbusSend(), MUTEX_LOCK, MUTEX_UNLOCK, and rssi_included.

Referenced by moduleInit().