Fix event handling after moving callbacks to mbus handle
This commit is contained in:
@ -103,18 +103,17 @@ main(int argc, char **argv)
|
|||||||
device = argv[c];
|
device = argv[c];
|
||||||
addr_str = argv[c+1];
|
addr_str = argv[c+1];
|
||||||
|
|
||||||
|
|
||||||
if (debug)
|
|
||||||
{
|
|
||||||
mbus_register_send_event(&mbus_dump_send_event);
|
|
||||||
mbus_register_recv_event(&mbus_dump_recv_event);
|
|
||||||
}
|
|
||||||
|
|
||||||
if ((handle = mbus_context_serial(device)) == NULL)
|
if ((handle = mbus_context_serial(device)) == NULL)
|
||||||
{
|
{
|
||||||
fprintf(stderr, "Could not initialize M-Bus context: %s\n", mbus_error_str());
|
fprintf(stderr, "Could not initialize M-Bus context: %s\n", mbus_error_str());
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (debug)
|
||||||
|
{
|
||||||
|
mbus_register_send_event(handle, &mbus_dump_send_event);
|
||||||
|
mbus_register_recv_event(handle, &mbus_dump_recv_event);
|
||||||
|
}
|
||||||
|
|
||||||
if (mbus_connect(handle) == -1)
|
if (mbus_connect(handle) == -1)
|
||||||
{
|
{
|
||||||
|
@ -64,17 +64,17 @@ main(int argc, char **argv)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (debug)
|
|
||||||
{
|
|
||||||
mbus_register_send_event(&mbus_dump_send_event);
|
|
||||||
mbus_register_recv_event(&mbus_dump_recv_event);
|
|
||||||
}
|
|
||||||
|
|
||||||
if ((handle = mbus_context_serial(device)) == NULL)
|
if ((handle = mbus_context_serial(device)) == NULL)
|
||||||
{
|
{
|
||||||
fprintf(stderr, "Could not initialize M-Bus context: %s\n", mbus_error_str());
|
fprintf(stderr, "Could not initialize M-Bus context: %s\n", mbus_error_str());
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (debug)
|
||||||
|
{
|
||||||
|
mbus_register_send_event(handle, &mbus_dump_send_event);
|
||||||
|
mbus_register_recv_event(handle, &mbus_dump_recv_event);
|
||||||
|
}
|
||||||
|
|
||||||
if (mbus_connect(handle) == -1)
|
if (mbus_connect(handle) == -1)
|
||||||
{
|
{
|
||||||
|
@ -116,12 +116,6 @@ main(int argc, char **argv)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (debug)
|
|
||||||
{
|
|
||||||
mbus_register_send_event(&mbus_dump_send_event);
|
|
||||||
mbus_register_recv_event(&mbus_dump_recv_event);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (addr_mask == NULL)
|
if (addr_mask == NULL)
|
||||||
{
|
{
|
||||||
fprintf(stderr, "Failed to allocate address mask.\n");
|
fprintf(stderr, "Failed to allocate address mask.\n");
|
||||||
@ -141,6 +135,12 @@ main(int argc, char **argv)
|
|||||||
free(addr_mask);
|
free(addr_mask);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (debug)
|
||||||
|
{
|
||||||
|
mbus_register_send_event(handle, &mbus_dump_send_event);
|
||||||
|
mbus_register_recv_event(handle, &mbus_dump_recv_event);
|
||||||
|
}
|
||||||
|
|
||||||
if (mbus_connect(handle) == -1)
|
if (mbus_connect(handle) == -1)
|
||||||
{
|
{
|
||||||
|
@ -108,17 +108,17 @@ main(int argc, char **argv)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (debug)
|
|
||||||
{
|
|
||||||
mbus_register_send_event(&mbus_dump_send_event);
|
|
||||||
mbus_register_recv_event(&mbus_dump_recv_event);
|
|
||||||
}
|
|
||||||
|
|
||||||
if ((handle = mbus_context_serial(device)) == NULL)
|
if ((handle = mbus_context_serial(device)) == NULL)
|
||||||
{
|
{
|
||||||
fprintf(stderr,"Scan failed: Could not initialize M-Bus context: %s\n", mbus_error_str());
|
fprintf(stderr,"Scan failed: Could not initialize M-Bus context: %s\n", mbus_error_str());
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (debug)
|
||||||
|
{
|
||||||
|
mbus_register_send_event(handle, &mbus_dump_send_event);
|
||||||
|
mbus_register_recv_event(handle, &mbus_dump_recv_event);
|
||||||
|
}
|
||||||
|
|
||||||
if (mbus_connect(handle) == -1)
|
if (mbus_connect(handle) == -1)
|
||||||
{
|
{
|
||||||
|
@ -68,17 +68,17 @@ main(int argc, char **argv)
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (debug)
|
|
||||||
{
|
|
||||||
mbus_register_send_event(&mbus_dump_send_event);
|
|
||||||
mbus_register_recv_event(&mbus_dump_recv_event);
|
|
||||||
}
|
|
||||||
|
|
||||||
if ((handle = mbus_context_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());
|
fprintf(stderr, "Could not initialize M-Bus context: %s\n", mbus_error_str());
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (debug)
|
||||||
|
{
|
||||||
|
mbus_register_send_event(handle, &mbus_dump_send_event);
|
||||||
|
mbus_register_recv_event(handle, &mbus_dump_recv_event);
|
||||||
|
}
|
||||||
|
|
||||||
if (mbus_connect(handle) == -1)
|
if (mbus_connect(handle) == -1)
|
||||||
{
|
{
|
||||||
|
@ -79,17 +79,17 @@ main(int argc, char **argv)
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (debug)
|
|
||||||
{
|
|
||||||
mbus_register_send_event(&mbus_dump_send_event);
|
|
||||||
mbus_register_recv_event(&mbus_dump_recv_event);
|
|
||||||
}
|
|
||||||
|
|
||||||
if ((handle = mbus_context_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());
|
fprintf(stderr, "Could not initialize M-Bus context: %s\n", mbus_error_str());
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (debug)
|
||||||
|
{
|
||||||
|
mbus_register_send_event(handle, &mbus_dump_send_event);
|
||||||
|
mbus_register_recv_event(handle, &mbus_dump_recv_event);
|
||||||
|
}
|
||||||
|
|
||||||
if (mbus_connect(handle) == -1)
|
if (mbus_connect(handle) == -1)
|
||||||
{
|
{
|
||||||
|
@ -105,17 +105,17 @@ main(int argc, char **argv)
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (debug)
|
|
||||||
{
|
|
||||||
mbus_register_send_event(&mbus_dump_send_event);
|
|
||||||
mbus_register_recv_event(&mbus_dump_recv_event);
|
|
||||||
}
|
|
||||||
|
|
||||||
if ((handle = mbus_context_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());
|
fprintf(stderr, "Could not initialize M-Bus context: %s\n", mbus_error_str());
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (debug)
|
||||||
|
{
|
||||||
|
mbus_register_send_event(handle, &mbus_dump_send_event);
|
||||||
|
mbus_register_recv_event(handle, &mbus_dump_recv_event);
|
||||||
|
}
|
||||||
|
|
||||||
if (mbus_connect(handle) == -1)
|
if (mbus_connect(handle) == -1)
|
||||||
{
|
{
|
||||||
|
@ -59,17 +59,17 @@ main(int argc, char **argv)
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (debug)
|
|
||||||
{
|
|
||||||
mbus_register_send_event(&mbus_dump_send_event);
|
|
||||||
mbus_register_recv_event(&mbus_dump_recv_event);
|
|
||||||
}
|
|
||||||
|
|
||||||
if ((handle = mbus_context_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());
|
fprintf(stderr, "Could not initialize M-Bus context: %s\n", mbus_error_str());
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (debug)
|
||||||
|
{
|
||||||
|
mbus_register_send_event(handle, &mbus_dump_send_event);
|
||||||
|
mbus_register_recv_event(handle, &mbus_dump_recv_event);
|
||||||
|
}
|
||||||
|
|
||||||
if (mbus_connect(handle) == -1)
|
if (mbus_connect(handle) == -1)
|
||||||
{
|
{
|
||||||
|
@ -94,17 +94,17 @@ main(int argc, char **argv)
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (debug)
|
|
||||||
{
|
|
||||||
mbus_register_send_event(&mbus_dump_send_event);
|
|
||||||
mbus_register_recv_event(&mbus_dump_recv_event);
|
|
||||||
}
|
|
||||||
|
|
||||||
if ((handle = mbus_context_tcp(host, port)) == NULL)
|
if ((handle = mbus_context_tcp(host, port)) == NULL)
|
||||||
{
|
{
|
||||||
fprintf(stderr,"Scan failed: Could not initialize M-Bus context: %s\n", mbus_error_str());
|
fprintf(stderr,"Scan failed: Could not initialize M-Bus context: %s\n", mbus_error_str());
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (debug)
|
||||||
|
{
|
||||||
|
mbus_register_send_event(handle, &mbus_dump_send_event);
|
||||||
|
mbus_register_recv_event(handle, &mbus_dump_recv_event);
|
||||||
|
}
|
||||||
|
|
||||||
if (mbus_connect(handle) == -1)
|
if (mbus_connect(handle) == -1)
|
||||||
{
|
{
|
||||||
|
Reference in New Issue
Block a user