Examples from bin directory updated. API usage updated in mbus-protocol-aux.h.
This commit is contained in:
13
bin/mbus-serial-request-data-multi-reply.c
Normal file → Executable file
13
bin/mbus-serial-request-data-multi-reply.c
Normal file → Executable file
@ -73,13 +73,19 @@ main(int argc, char **argv)
|
||||
mbus_register_recv_event(&mbus_dump_recv_event);
|
||||
}
|
||||
|
||||
if ((handle = mbus_connect_serial(device)) == NULL)
|
||||
if ((handle = mbus_context_serial(device)) == NULL)
|
||||
{
|
||||
fprintf(stderr, "Failed to setup connection to M-bus gateway\n");
|
||||
fprintf(stderr, "Could not initialize M-Bus context: %s\n", mbus_error_str());
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (mbus_serial_set_baudrate(handle->m_serial_handle, baudrate) == -1)
|
||||
if (!mbus_connect(handle))
|
||||
{
|
||||
printf("Failed to setup connection to M-bus gateway\n");
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (mbus_serial_set_baudrate(handle, baudrate) == -1)
|
||||
{
|
||||
printf("Failed to set baud rate.\n");
|
||||
return 1;
|
||||
@ -174,6 +180,7 @@ main(int argc, char **argv)
|
||||
free(xml_result);
|
||||
|
||||
mbus_disconnect(handle);
|
||||
mbus_context_free(handle);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -70,13 +70,19 @@ main(int argc, char **argv)
|
||||
mbus_register_recv_event(&mbus_dump_recv_event);
|
||||
}
|
||||
|
||||
if ((handle = mbus_connect_serial(device)) == NULL)
|
||||
if ((handle = mbus_context_serial(device)) == NULL)
|
||||
{
|
||||
fprintf(stderr, "Failed to setup connection to M-bus gateway\n");
|
||||
fprintf(stderr, "Could not initialize M-Bus context: %s\n", mbus_error_str());
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (mbus_serial_set_baudrate(handle->m_serial_handle, baudrate) == -1)
|
||||
if (!mbus_connect(handle))
|
||||
{
|
||||
printf("Failed to setup connection to M-bus gateway\n");
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (mbus_serial_set_baudrate(handle, baudrate) == -1)
|
||||
{
|
||||
printf("Failed to set baud rate.\n");
|
||||
return 1;
|
||||
@ -162,6 +168,7 @@ main(int argc, char **argv)
|
||||
}
|
||||
|
||||
mbus_disconnect(handle);
|
||||
mbus_context_free(handle);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
14
bin/mbus-serial-scan-secondary.c
Normal file → Executable file
14
bin/mbus-serial-scan-secondary.c
Normal file → Executable file
@ -102,13 +102,19 @@ main(int argc, char **argv)
|
||||
return 1;
|
||||
}
|
||||
|
||||
if ((handle = mbus_connect_serial(device)) == NULL)
|
||||
if ((handle = mbus_context_serial(device)) == NULL)
|
||||
{
|
||||
fprintf(stderr, "Failed to setup connection to M-bus gateway: %s\n", mbus_error_str());
|
||||
fprintf(stderr, "Could not initialize M-Bus context: %s\n", mbus_error_str());
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (mbus_serial_set_baudrate(handle->m_serial_handle, baudrate) == -1)
|
||||
if (!mbus_connect(handle))
|
||||
{
|
||||
printf("Failed to setup connection to M-bus gateway\n");
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (mbus_serial_set_baudrate(handle, baudrate) == -1)
|
||||
{
|
||||
fprintf(stderr, "Failed to set baud rate.\n");
|
||||
return 1;
|
||||
@ -153,7 +159,7 @@ main(int argc, char **argv)
|
||||
mbus_scan_2nd_address_range(handle, 0, addr_mask);
|
||||
|
||||
mbus_disconnect(handle);
|
||||
|
||||
mbus_context_free(handle);
|
||||
//printf("Summary: Tried %ld address masks and found %d devices.\n", probe_count, match_count);
|
||||
|
||||
free(addr_mask);
|
||||
|
@ -62,13 +62,19 @@ main(int argc, char **argv)
|
||||
mbus_register_recv_event(&mbus_dump_recv_event);
|
||||
}
|
||||
|
||||
if ((handle = mbus_connect_serial(device)) == NULL)
|
||||
if ((handle = mbus_context_serial(device)) == NULL)
|
||||
{
|
||||
fprintf(stderr, "Could not initialize M-Bus context: %s\n", mbus_error_str());
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (!mbus_connect(handle))
|
||||
{
|
||||
printf("Failed to setup connection to M-bus gateway\n");
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (mbus_serial_set_baudrate(handle->m_serial_handle, baudrate) == -1)
|
||||
if (mbus_serial_set_baudrate(handle, baudrate) == -1)
|
||||
{
|
||||
printf("Failed to set baud rate.\n");
|
||||
return 1;
|
||||
@ -128,6 +134,7 @@ main(int argc, char **argv)
|
||||
}
|
||||
|
||||
mbus_disconnect(handle);
|
||||
mbus_context_free(handle);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -53,13 +53,19 @@ main(int argc, char **argv)
|
||||
return 1;
|
||||
}
|
||||
|
||||
if ((handle = mbus_connect_serial(device)) == NULL)
|
||||
if ((handle = mbus_context_serial(device)) == NULL)
|
||||
{
|
||||
printf("Failed to setup connection to M-bus device: %s\n", mbus_error_str());
|
||||
fprintf(stderr, "Could not initialize M-Bus context: %s\n", mbus_error_str());
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (mbus_serial_set_baudrate(handle->m_serial_handle, baudrate) == -1)
|
||||
if (!mbus_connect(handle))
|
||||
{
|
||||
printf("Failed to setup connection to M-bus gateway\n");
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (mbus_serial_set_baudrate(handle, baudrate) == -1)
|
||||
{
|
||||
printf("Failed to set baud rate.\n");
|
||||
return 1;
|
||||
@ -113,6 +119,7 @@ main(int argc, char **argv)
|
||||
|
||||
free(addr);
|
||||
mbus_disconnect(handle);
|
||||
mbus_context_free(handle);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -52,13 +52,19 @@ main(int argc, char **argv)
|
||||
return 0;
|
||||
}
|
||||
|
||||
if ((handle = mbus_connect_serial(device)) == NULL)
|
||||
if ((handle = mbus_context_serial(device)) == NULL)
|
||||
{
|
||||
printf("Failed to setup connection to M-bus device: %s\n", mbus_error_str());
|
||||
fprintf(stderr, "Could not initialize M-Bus context: %s\n", mbus_error_str());
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (!mbus_connect(handle))
|
||||
{
|
||||
printf("Failed to setup connection to M-bus gateway\n");
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (mbus_serial_set_baudrate(handle->m_serial_handle, source_baudrate) == -1)
|
||||
if (mbus_serial_set_baudrate(handle, source_baudrate) == -1)
|
||||
{
|
||||
printf("Failed to set baud rate.\n");
|
||||
return 1;
|
||||
@ -88,6 +94,7 @@ main(int argc, char **argv)
|
||||
}
|
||||
|
||||
mbus_disconnect(handle);
|
||||
mbus_context_free(handle);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
9
bin/mbus-tcp-request-data-multi-reply.c
Normal file → Executable file
9
bin/mbus-tcp-request-data-multi-reply.c
Normal file → Executable file
@ -62,7 +62,13 @@ main(int argc, char **argv)
|
||||
mbus_register_recv_event(&mbus_dump_recv_event);
|
||||
}
|
||||
|
||||
if ((handle = mbus_connect_tcp(host, port)) == NULL)
|
||||
if ((handle = mbus_context_tcp(host, port)) == NULL)
|
||||
{
|
||||
fprintf(stderr, "Could not initialize M-Bus context: %s\n", mbus_error_str());
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (!mbus_connect(handle))
|
||||
{
|
||||
fprintf(stderr, "Failed to setup connection to M-bus gateway\n");
|
||||
return 1;
|
||||
@ -157,6 +163,7 @@ main(int argc, char **argv)
|
||||
free(xml_result);
|
||||
|
||||
mbus_disconnect(handle);
|
||||
mbus_context_free(handle);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -62,7 +62,13 @@ main(int argc, char **argv)
|
||||
mbus_register_recv_event(&mbus_dump_recv_event);
|
||||
}
|
||||
|
||||
if ((handle = mbus_connect_tcp(host, port)) == NULL)
|
||||
if ((handle = mbus_context_tcp(host, port)) == NULL)
|
||||
{
|
||||
fprintf(stderr, "Could not initialize M-Bus context: %s\n", mbus_error_str());
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (!mbus_connect(handle))
|
||||
{
|
||||
fprintf(stderr, "Failed to setup connection to M-bus gateway\n");
|
||||
return 1;
|
||||
@ -147,6 +153,7 @@ main(int argc, char **argv)
|
||||
}
|
||||
|
||||
mbus_disconnect(handle);
|
||||
mbus_context_free(handle);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
11
bin/mbus-tcp-scan-secondary.c
Normal file → Executable file
11
bin/mbus-tcp-scan-secondary.c
Normal file → Executable file
@ -57,9 +57,15 @@ main(int argc, char **argv)
|
||||
return 1;
|
||||
}
|
||||
|
||||
if ((handle = mbus_connect_tcp(host, port)) == NULL)
|
||||
if ((handle = mbus_context_tcp(host, port)) == NULL)
|
||||
{
|
||||
fprintf(stderr, "Failed to setup connection to M-bus gateway: %s\n", mbus_error_str());
|
||||
fprintf(stderr, "Could not initialize M-Bus context: %s\n", mbus_error_str());
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (!mbus_connect(handle))
|
||||
{
|
||||
fprintf(stderr, "Failed to setup connection to M-bus gateway\n");
|
||||
return 1;
|
||||
}
|
||||
|
||||
@ -103,6 +109,7 @@ main(int argc, char **argv)
|
||||
mbus_scan_2nd_address_range(handle, 0, addr_mask);
|
||||
|
||||
mbus_disconnect(handle);
|
||||
mbus_context_free(handle);
|
||||
|
||||
//printf("Summary: Tried %ld address masks and found %d devices.\n", probe_count, match_count);
|
||||
|
||||
|
@ -51,7 +51,13 @@ main(int argc, char **argv)
|
||||
mbus_register_recv_event(&mbus_dump_recv_event);
|
||||
}
|
||||
|
||||
if ((handle = mbus_connect_tcp(host, port)) == NULL)
|
||||
if ((handle = mbus_context_tcp(host, port)) == NULL)
|
||||
{
|
||||
printf("Scan failed: Could not initialize M-Bus context: %s\n", mbus_error_str());
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (!mbus_connect(handle))
|
||||
{
|
||||
printf("Scan failed: Could not setup connection to M-bus gateway: %s\n", mbus_error_str());
|
||||
return 1;
|
||||
@ -110,6 +116,7 @@ main(int argc, char **argv)
|
||||
}
|
||||
|
||||
mbus_disconnect(handle);
|
||||
mbus_context_free(handle);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -45,9 +45,15 @@ main(int argc, char **argv)
|
||||
return 1;
|
||||
}
|
||||
|
||||
if ((handle = mbus_connect_tcp(host, port)) == NULL)
|
||||
if ((handle = mbus_context_tcp(host, port)) == NULL)
|
||||
{
|
||||
printf("Failed to setup connection to M-bus gateway: %s\n", mbus_error_str());
|
||||
fprintf(stderr, "Could not initialize M-Bus context: %s\n", mbus_error_str());
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (!mbus_connect(handle))
|
||||
{
|
||||
fprintf(stderr, "Failed to setup connection to M-bus gateway\n");
|
||||
return 1;
|
||||
}
|
||||
|
||||
@ -99,6 +105,7 @@ main(int argc, char **argv)
|
||||
|
||||
free(addr);
|
||||
mbus_disconnect(handle);
|
||||
mbus_context_free(handle);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user