New parameter for mbus_send_ping_frame to purge response

This commit is contained in:
Stefan Wahren 2012-09-01 22:51:44 +02:00
parent d2608d5de7
commit 1a538e73aa
4 changed files with 16 additions and 9 deletions

View File

@ -95,7 +95,7 @@ main(int argc, char **argv)
fflush(stdout);
}
if (mbus_send_ping_frame(handle, address) == -1)
if (mbus_send_ping_frame(handle, address, 0) == -1)
{
printf("Scan failed. Could not send ping frame: %s\n", mbus_error_str());
return 1;

View File

@ -78,7 +78,7 @@ main(int argc, char **argv)
fflush(stdout);
}
if (mbus_send_ping_frame(handle, address) == -1)
if (mbus_send_ping_frame(handle, address, 0) == -1)
{
printf("Scan failed. Could not send ping frame: %s\n", mbus_error_str());
return 1;

View File

@ -1786,10 +1786,10 @@ mbus_sendrecv_request(mbus_handle *handle, int address, mbus_frame *reply, int m
//------------------------------------------------------------------------------
// send a data request packet to from master to slave
// send a data request packet to from master to slave and optional purge response
//------------------------------------------------------------------------------
int
mbus_send_ping_frame(mbus_handle *handle, int address)
mbus_send_ping_frame(mbus_handle *handle, int address, char purge_response)
{
int retval = 0;
mbus_frame *frame;
@ -1808,7 +1808,13 @@ mbus_send_ping_frame(mbus_handle *handle, int address)
if (mbus_send_frame(handle, frame) == -1)
{
MBUS_ERROR("%s: failed to send mbus frame.\n", __PRETTY_FUNCTION__);
retval = -1;
mbus_frame_free(frame);
return -1;
}
if (purge_response)
{
mbus_purge_frames(handle);
}
mbus_frame_free(frame);

View File

@ -265,12 +265,13 @@ int mbus_sendrecv_request(mbus_handle *handle, int address, mbus_frame *reply, i
/**
* Sends ping frame to given slave using "unified" handle
*
* @param handle Initialized handle
* @param address Address (0-255)
* @param handle Initialized handle
* @param address Address (0-255)
* @param purge_response Response flag (=0 don't receive response, >0 purge response)
*
* @return Zero when successful.
*/
int mbus_send_ping_frame(mbus_handle *handle, int address);
int mbus_send_ping_frame(mbus_handle *handle, int address, char purge_response);
/**
* Select slave by secondary address using "unified" handle