add new helper functions to check primary and secondary addresses

This commit is contained in:
Stefan Wahren
2012-12-31 13:37:17 +01:00
parent a8cc7b0acd
commit 61fd2aa1c7
3 changed files with 67 additions and 2 deletions

View File

@ -1629,6 +1629,12 @@ mbus_send_switch_baudrate_frame(mbus_handle * handle, int address, int baudrate)
int control_information = 0;
mbus_frame *frame;
if (mbus_is_primary_address(address) == 0)
{
MBUS_ERROR("%s: invalid address %d\n", __PRETTY_FUNCTION__, address);
return -1;
}
switch (baudrate)
{
case 300:
@ -1690,6 +1696,12 @@ mbus_send_request_frame(mbus_handle * handle, int address)
{
int retval = 0;
mbus_frame *frame;
if (mbus_is_primary_address(address) == 0)
{
MBUS_ERROR("%s: invalid address %d\n", __PRETTY_FUNCTION__, address);
return -1;
}
frame = mbus_frame_new(MBUS_FRAME_TYPE_SHORT);
@ -1729,6 +1741,12 @@ mbus_sendrecv_request(mbus_handle *handle, int address, mbus_frame *reply, int m
MBUS_ERROR("%s: Invalid M-Bus handle for request.\n", __PRETTY_FUNCTION__);
return 1;
}
if (mbus_is_primary_address(address) == 0)
{
MBUS_ERROR("%s: invalid address %d\n", __PRETTY_FUNCTION__, address);
return 1;
}
frame = mbus_frame_new(MBUS_FRAME_TYPE_SHORT);
@ -1880,6 +1898,12 @@ mbus_send_ping_frame(mbus_handle *handle, int address, char purge_response)
{
int retval = 0;
mbus_frame *frame;
if (mbus_is_primary_address(address) == 0)
{
MBUS_ERROR("%s: invalid address %d\n", __PRETTY_FUNCTION__, address);
return 1;
}
frame = mbus_frame_new(MBUS_FRAME_TYPE_SHORT);