Radiocraft Wireless M-Bus extension module
2.18
|
These functions are called from different C functions and contain common functionality. More...
Modules | |
List helper functions | |
These functions are used to manipulate the internal buffer. | |
Functions | |
static void | mbusDebug (const char *prefix, const char *format,...) |
Send mbus debug message to the device output in the format "<prefix>:<formated string>" This function is by default empty, but is active when compiling with DEBUG defined. More... | |
static void | mbusPrintInfo (const char *prefix, const char *format,...) |
Send mbus info message to the device output in the format "<prefix>:<formated string>". More... | |
static int8 | mbus_address_compare (tdef_mbus_slave_address *a, tdef_mbus_frame *f) |
Compare the address in a received frame to a given address. More... | |
static int | mbusPower (uint8 power) |
Control power to module. More... | |
static int | mbusConfigEnter (void) |
Entering configuration mode. More... | |
static int | mbusConfigExit (void) |
Exit configuration mode. More... | |
static int | mbusConfigTransact (uint8 cmd, uint8 *data, int d_size, uint8 *reply, int r_size) |
Send a single configuration command with additional data and receive the reply. More... | |
static int | mbusConfigCmd (uint8 cmd, uint8 *reply, int size) |
Send a single command/argument. More... | |
static int | mbusConfigData (uint8 cmd) |
Send configuration data. More... | |
static int | mbus_read_reg (int8 reg, int size, const char *name) |
Reads the value of one or more registers in the M-Bus module and prints the value to the device output as hexadecimal values. More... | |
static int | mbus_read_regs (int8 reg, uint8 *buffer, int size) |
Reads the value of one or more registers in the M-Bus module and stores the value in the provided buffer. More... | |
static int | mbus_config_mem_reg (uint8 reg, uint8 val) |
Change the value of a register in the M-Bus module. More... | |
static int | mbus_config (int8 mode, int8 rssi, int8 only_installed) |
Configure a number of common settings. More... | |
static int | mbus_receive (tdef_mbus_start_frame *start, int8 *data, int16 *rssi) |
Receive a new frame from the M-Bus module. More... | |
static void | mbus_th_reader (void *arg) |
Thread function to recieve data and add to frame buffer list. More... | |
static int | mbusConfigFactoryReset (void) |
This function performs a factory reset of the RF module. More... | |
These functions are called from different C functions and contain common functionality.
|
static |
Compare the address in a received frame to a given address.
[in] | a | Pointer to the given address in the compare |
[in] | f | Pointer to an address field in a frame |
Definition at line 399 of file mod_mbus.c.
References mbus_frame::id, mbus_slave_address::id, mbus_frame::manufacture, mbus_slave_address::manufacturer, mbus_frame::type, mbus_slave_address::type, mbus_frame::version, and mbus_slave_address::version.
Referenced by flist_search_remove().
|
static |
Configure a number of common settings.
[in] | mode | Set the M-Bus mode( see mbusOpen() for values). Set to -1 to not change it. |
[in] | rssi | Set true to include RSSI in each packet. Set to -1 to not change it. |
[in] | only_installed | Set true to only receive packets from installed/registered slaves. Set to -1 to not change it. |
Definition at line 864 of file mod_mbus.c.
References mbus_config_mem_reg(), mbus_read_reg(), mbusConfigEnter(), mbusConfigExit(), mbusDebug(), MUTEX_LOCK, MUTEX_UNLOCK, rssi_included, and rw_lock.
Referenced by mbusCallFilterEnable(), and mbusOpen().
|
static |
Change the value of a register in the M-Bus module.
It check to make sure that it does not already have the value, to avoid unneeded writing to the flash.
[in] | reg | The register to change |
[in] | val | The new value |
Definition at line 830 of file mod_mbus.c.
References mbusConfigCmd(), and mbusConfigData().
Referenced by mbus_config().
|
static |
Reads the value of one or more registers in the M-Bus module and prints the value to the device output as hexadecimal values.
[in] | reg | The index of the first register to read |
[in] | size | The number of sequential registers to read. |
[in] | name | The name of the register to show in the output. |
Definition at line 774 of file mod_mbus.c.
References mbusConfigCmd(), and mbusDebug().
Referenced by mbus_config().
|
static |
Reads the value of one or more registers in the M-Bus module and stores the value in the provided buffer.
[in] | reg | The index of the first register to read |
[in] | buffer | The bufer to place the data in. |
[in] | size | The number of sequential registers to read. |
Definition at line 805 of file mod_mbus.c.
References mbusConfigCmd().
Referenced by mbus_info().
|
static |
Receive a new frame from the M-Bus module.
[in] | start | The frame to store the information from the header in. |
[in] | data | Buffer to store the received data in. |
[out] | rssi | If not NULL and if the RSSI is included in the packet, this is set to the RSSI of the packet. |
Definition at line 944 of file mod_mbus.c.
References fd, mbus_start_frame::length, MBUS_DATA_LENGTH, MUTEX_LOCK, MUTEX_UNLOCK, rssi_included, and rw_lock.
Referenced by mbus_th_reader().
|
static |
Thread function to recieve data and add to frame buffer list.
[in] | arg | Unused. There to comply with thread interface |
Definition at line 1065 of file mod_mbus.c.
References cfg_active, mbus_frame::control, mbus_start_frame::control, mbus_frame::data, flist_append(), mbus_frame_list_elem::frame, mbus_frame::id, mbus_start_frame::id, mbus_frame::length, mbus_start_frame::length, mbus_frame::linsec, mbus_frame::manufacture, mbus_start_frame::manufacturer, mbus_receive(), mbus_frame::rssi, run_thread, mbus_frame::type, mbus_start_frame::type, mbus_frame::version, and mbus_start_frame::version.
Referenced by mbusStartReader().
|
static |
Send a single command/argument.
Will send the supplied configuration command/argument, and return any expected reply.
The module must first have been set in configuration mode using mbusConfigEnter().
[in] | cmd | The command or value to send. |
[in] | reply | Reference to where reply is stored. |
[in] | size | Size of expected reply, '0' of no reply is expected. |
Definition at line 723 of file mod_mbus.c.
References mbusConfigTransact().
Referenced by mbus_config_mem_reg(), mbus_info(), mbus_read_reg(), mbus_read_regs(), mbus_register_slave(), and mbusSend().
|
static |
Send configuration data.
Sends the supplied data and does not expect confirmation.
The module must first have been set in configuration mode using mbusConfigEnter().
[in] | cmd | The command or value to send. |
Definition at line 741 of file mod_mbus.c.
References fd, and mbusDebug().
Referenced by mbus_config_mem_reg().
|
static |
Entering configuration mode.
Request entering configuration mode by sending '0x00', and wait for confirmation. Any data received but not read and data written but not transmitted will be flushed, to ensure synchronization.
To exit configuration mode mbusConfigExit() must be called.
Definition at line 459 of file mod_mbus.c.
References cfg_activated, cfg_active, fd, and mbusDebug().
Referenced by mbus_config(), mbus_info(), mbus_register_slave(), mbusOpen(), and mbusSend().
|
static |
Exit configuration mode.
Request exit configuration mode by sending 'X', notice that the actual exit can't be confirmed, and success is always assumed.
To enter configuration mode, mbusConfigEnter() must be called.
Definition at line 558 of file mod_mbus.c.
References cfg_activated, cfg_active, fd, and mbusDebug().
Referenced by mbus_config(), mbus_info(), mbus_register_slave(), mbusConfigFactoryReset(), mbusOpen(), and mbusSend().
|
static |
This function performs a factory reset of the RF module.
This includes erasing the serial number, so care should be taken when using it.
Definition at line 1110 of file mod_mbus.c.
References cfg_activated, cfg_active, fd, mbusConfigExit(), mbusConfigTransact(), mbusDebug(), MUTEX_LOCK, MUTEX_UNLOCK, and rw_lock.
|
static |
Send a single configuration command with additional data and receive the reply.
Will send the supplied configuration command/argument and the additional data, and return any expected reply.
The module must first have been set in configuration mode using mbusConfigEnter().
[in] | cmd | The command or value to send. |
[in] | data | Additional data to send. |
[in] | d_size | The length of the additional data to send |
[in] | reply | Reference to where reply is stored. |
[in] | r_size | Size of expected reply, '0' of no reply is expected. |
Definition at line 617 of file mod_mbus.c.
References fd, and mbusDebug().
Referenced by mbus_register_slave(), mbusConfigCmd(), and mbusConfigFactoryReset().
|
static |
Send mbus debug message to the device output in the format "<prefix>:<formated string>" This function is by default empty, but is active when compiling with DEBUG defined.
[in] | prefix | prefix to message |
[in] | format | the format and arguments |
Definition at line 364 of file mod_mbus.c.
Referenced by flist_append(), flist_clear(), flist_remove_first_element(), flist_search_remove(), mbus_config(), mbus_info(), mbus_read_reg(), mbus_register_slave(), mbusCallClose(), mbusCallFilterEnable(), mbusCallFilterReceive(), mbusCallGetBufferLevel(), mbusCallInfo(), mbusCallOpen(), mbusCallReceive(), mbusCallRegisterSlave(), mbusCallSend(), mbusClose(), mbusConfigData(), mbusConfigEnter(), mbusConfigExit(), mbusConfigFactoryReset(), mbusConfigTransact(), mbusOpen(), mbusPower(), mbusSend(), moduleInit(), and moduleNotify().
|
static |
Control power to module.
Power the module on or off.
[in] | power | If 0 then off else on. |
Definition at line 424 of file mod_mbus.c.
References cfg_activated, and mbusDebug().
Referenced by mbusClose(), mbusOpen(), and moduleInit().
|
static |
Send mbus info message to the device output in the format "<prefix>:<formated string>".
[in] | prefix | prefix to message |
[in] | format | the format and arguments |
Definition at line 376 of file mod_mbus.c.
Referenced by mbus_info().