From 69bc06eeb1c8cf20f03337e0d6cd35f4cae5ee02 Mon Sep 17 00:00:00 2001 From: Stefan Wahren Date: Sun, 20 May 2012 03:55:36 +0200 Subject: [PATCH] Improved readout by secondary address - save 1 REQ_UD2 by selecting instead of probing seconday address --- bin/mbus-serial-request-data-multi-reply.c | 14 +++++++------- bin/mbus-serial-request-data.c | 14 +++++++------- bin/mbus-tcp-request-data-multi-reply.c | 12 ++++++------ bin/mbus-tcp-request-data.c | 12 ++++++------ 4 files changed, 26 insertions(+), 26 deletions(-) diff --git a/bin/mbus-serial-request-data-multi-reply.c b/bin/mbus-serial-request-data-multi-reply.c index cab96ef..35eb473 100644 --- a/bin/mbus-serial-request-data-multi-reply.c +++ b/bin/mbus-serial-request-data-multi-reply.c @@ -29,7 +29,7 @@ main(int argc, char **argv) mbus_frame_data reply_data; mbus_handle *handle = NULL; - char *device, *addr_str, matching_addr[16], *xml_result; + char *device, *addr_str, *xml_result; int address, baudrate = 9600; memset((void *)&reply, 0, sizeof(mbus_frame)); @@ -116,23 +116,23 @@ main(int argc, char **argv) { // secondary addressing - int probe_ret; + int ret; - probe_ret = mbus_probe_secondary_address(handle, addr_str, matching_addr); + ret = mbus_select_secondary_address(handle, addr_str); - if (probe_ret == MBUS_PROBE_COLLISION) + if (ret == MBUS_PROBE_COLLISION) { fprintf(stderr, "%s: Error: The address mask [%s] matches more than one device.\n", __PRETTY_FUNCTION__, addr_str); return 1; } - else if (probe_ret == MBUS_PROBE_NOTHING) + else if (ret == MBUS_PROBE_NOTHING) { fprintf(stderr, "%s: Error: The selected secondary address does not match any device [%s].\n", __PRETTY_FUNCTION__, addr_str); return 1; } - else if (probe_ret == MBUS_PROBE_ERROR) + else if (ret == MBUS_PROBE_ERROR) { - fprintf(stderr, "%s: Error: Failed to probe secondary address [%s].\n", __PRETTY_FUNCTION__, addr_str); + fprintf(stderr, "%s: Error: Failed to select secondary address [%s].\n", __PRETTY_FUNCTION__, addr_str); return 1; } // else MBUS_PROBE_SINGLE diff --git a/bin/mbus-serial-request-data.c b/bin/mbus-serial-request-data.c index 6d0826b..5816c3c 100644 --- a/bin/mbus-serial-request-data.c +++ b/bin/mbus-serial-request-data.c @@ -29,7 +29,7 @@ main(int argc, char **argv) mbus_frame_data reply_data; mbus_handle *handle = NULL; - char *device, *addr_str, matching_addr[16]; + char *device, *addr_str; int address, baudrate = 9600; if (argc == 3) @@ -87,23 +87,23 @@ main(int argc, char **argv) { // secondary addressing - int probe_ret; + int ret; - probe_ret = mbus_probe_secondary_address(handle, addr_str, matching_addr); + ret = mbus_select_secondary_address(handle, addr_str); - if (probe_ret == MBUS_PROBE_COLLISION) + if (ret == MBUS_PROBE_COLLISION) { fprintf(stderr, "%s: Error: The address mask [%s] matches more than one device.\n", __PRETTY_FUNCTION__, addr_str); return 1; } - else if (probe_ret == MBUS_PROBE_NOTHING) + else if (ret == MBUS_PROBE_NOTHING) { fprintf(stderr, "%s: Error: The selected secondary address does not match any device [%s].\n", __PRETTY_FUNCTION__, addr_str); return 1; } - else if (probe_ret == MBUS_PROBE_ERROR) + else if (ret == MBUS_PROBE_ERROR) { - fprintf(stderr, "%s: Error: Failed to probe secondary address [%s].\n", __PRETTY_FUNCTION__, addr_str); + fprintf(stderr, "%s: Error: Failed to select secondary address [%s].\n", __PRETTY_FUNCTION__, addr_str); return 1; } // else MBUS_PROBE_SINGLE diff --git a/bin/mbus-tcp-request-data-multi-reply.c b/bin/mbus-tcp-request-data-multi-reply.c index 5ae94b0..e85e8e1 100644 --- a/bin/mbus-tcp-request-data-multi-reply.c +++ b/bin/mbus-tcp-request-data-multi-reply.c @@ -72,23 +72,23 @@ main(int argc, char **argv) { // secondary addressing - int probe_ret; + int ret; - probe_ret = mbus_probe_secondary_address(handle, addr_str, matching_addr); + ret = mbus_select_secondary_address(handle, addr_str); - if (probe_ret == MBUS_PROBE_COLLISION) + if (ret == MBUS_PROBE_COLLISION) { fprintf(stderr, "%s: Error: The address mask [%s] matches more than one device.\n", __PRETTY_FUNCTION__, addr_str); return 1; } - else if (probe_ret == MBUS_PROBE_NOTHING) + else if (ret == MBUS_PROBE_NOTHING) { fprintf(stderr, "%s: Error: The selected secondary address does not match any device [%s].\n", __PRETTY_FUNCTION__, addr_str); return 1; } - else if (probe_ret == MBUS_PROBE_ERROR) + else if (ret == MBUS_PROBE_ERROR) { - fprintf(stderr, "%s: Error: Failed to probe secondary address [%s].\n", __PRETTY_FUNCTION__, addr_str); + fprintf(stderr, "%s: Error: Failed to select secondary address [%s].\n", __PRETTY_FUNCTION__, addr_str); return 1; } // else MBUS_PROBE_SINGLE diff --git a/bin/mbus-tcp-request-data.c b/bin/mbus-tcp-request-data.c index 0d8db18..6f91be4 100644 --- a/bin/mbus-tcp-request-data.c +++ b/bin/mbus-tcp-request-data.c @@ -72,23 +72,23 @@ main(int argc, char **argv) { // secondary addressing - int probe_ret; + int ret; - probe_ret = mbus_probe_secondary_address(handle, addr_str, matching_addr); + ret = mbus_select_secondary_address(handle, addr_str); - if (probe_ret == MBUS_PROBE_COLLISION) + if (ret == MBUS_PROBE_COLLISION) { fprintf(stderr, "%s: Error: The address mask [%s] matches more than one device.\n", __PRETTY_FUNCTION__, addr_str); return 1; } - else if (probe_ret == MBUS_PROBE_NOTHING) + else if (ret == MBUS_PROBE_NOTHING) { fprintf(stderr, "%s: Error: The selected secondary address does not match any device [%s].\n", __PRETTY_FUNCTION__, addr_str); return 1; } - else if (probe_ret == MBUS_PROBE_ERROR) + else if (ret == MBUS_PROBE_ERROR) { - fprintf(stderr, "%s: Error: Failed to probe secondary address [%s].\n", __PRETTY_FUNCTION__, addr_str); + fprintf(stderr, "%s: Error: Failed to select secondary address [%s].\n", __PRETTY_FUNCTION__, addr_str); return 1; } // else MBUS_PROBE_SINGLE