Improved readout by secondary address

- save 1 REQ_UD2 by selecting instead of probing seconday address
This commit is contained in:
Stefan Wahren
2012-05-20 03:55:36 +02:00
parent ef630f2e5d
commit 69bc06eeb1
4 changed files with 26 additions and 26 deletions

View File

@ -29,7 +29,7 @@ main(int argc, char **argv)
mbus_frame_data reply_data; mbus_frame_data reply_data;
mbus_handle *handle = NULL; mbus_handle *handle = NULL;
char *device, *addr_str, matching_addr[16], *xml_result; char *device, *addr_str, *xml_result;
int address, baudrate = 9600; int address, baudrate = 9600;
memset((void *)&reply, 0, sizeof(mbus_frame)); memset((void *)&reply, 0, sizeof(mbus_frame));
@ -116,23 +116,23 @@ main(int argc, char **argv)
{ {
// secondary addressing // 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); fprintf(stderr, "%s: Error: The address mask [%s] matches more than one device.\n", __PRETTY_FUNCTION__, addr_str);
return 1; 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); fprintf(stderr, "%s: Error: The selected secondary address does not match any device [%s].\n", __PRETTY_FUNCTION__, addr_str);
return 1; 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; return 1;
} }
// else MBUS_PROBE_SINGLE // else MBUS_PROBE_SINGLE

View File

@ -29,7 +29,7 @@ main(int argc, char **argv)
mbus_frame_data reply_data; mbus_frame_data reply_data;
mbus_handle *handle = NULL; mbus_handle *handle = NULL;
char *device, *addr_str, matching_addr[16]; char *device, *addr_str;
int address, baudrate = 9600; int address, baudrate = 9600;
if (argc == 3) if (argc == 3)
@ -87,23 +87,23 @@ main(int argc, char **argv)
{ {
// secondary addressing // 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); fprintf(stderr, "%s: Error: The address mask [%s] matches more than one device.\n", __PRETTY_FUNCTION__, addr_str);
return 1; 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); fprintf(stderr, "%s: Error: The selected secondary address does not match any device [%s].\n", __PRETTY_FUNCTION__, addr_str);
return 1; 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; return 1;
} }
// else MBUS_PROBE_SINGLE // else MBUS_PROBE_SINGLE

View File

@ -72,23 +72,23 @@ main(int argc, char **argv)
{ {
// secondary addressing // 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); fprintf(stderr, "%s: Error: The address mask [%s] matches more than one device.\n", __PRETTY_FUNCTION__, addr_str);
return 1; 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); fprintf(stderr, "%s: Error: The selected secondary address does not match any device [%s].\n", __PRETTY_FUNCTION__, addr_str);
return 1; 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; return 1;
} }
// else MBUS_PROBE_SINGLE // else MBUS_PROBE_SINGLE

View File

@ -72,23 +72,23 @@ main(int argc, char **argv)
{ {
// secondary addressing // 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); fprintf(stderr, "%s: Error: The address mask [%s] matches more than one device.\n", __PRETTY_FUNCTION__, addr_str);
return 1; 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); fprintf(stderr, "%s: Error: The selected secondary address does not match any device [%s].\n", __PRETTY_FUNCTION__, addr_str);
return 1; 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; return 1;
} }
// else MBUS_PROBE_SINGLE // else MBUS_PROBE_SINGLE