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