Fix event handling after moving callbacks to mbus handle
This commit is contained in:
parent
0cf57bfc35
commit
c2a3f4b871
@ -103,19 +103,18 @@ 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)
|
||||||
{
|
{
|
||||||
fprintf(stderr,"Failed to setup connection to M-bus gateway\n");
|
fprintf(stderr,"Failed to setup connection to M-bus gateway\n");
|
||||||
|
@ -64,18 +64,18 @@ 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)
|
||||||
{
|
{
|
||||||
fprintf(stderr,"Failed to setup connection to M-bus gateway\n");
|
fprintf(stderr,"Failed to setup connection to M-bus gateway\n");
|
||||||
|
@ -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");
|
||||||
@ -142,6 +136,12 @@ main(int argc, char **argv)
|
|||||||
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)
|
||||||
{
|
{
|
||||||
fprintf(stderr,"Failed to setup connection to M-bus gateway\n");
|
fprintf(stderr,"Failed to setup connection to M-bus gateway\n");
|
||||||
|
@ -108,18 +108,18 @@ 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)
|
||||||
{
|
{
|
||||||
fprintf(stderr,"Scan failed: Could not setup connection to M-bus gateway: %s\n", mbus_error_str());
|
fprintf(stderr,"Scan failed: Could not setup connection to M-bus gateway: %s\n", mbus_error_str());
|
||||||
|
@ -68,18 +68,18 @@ 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)
|
||||||
{
|
{
|
||||||
fprintf(stderr, "Failed to setup connection to M-bus gateway\n");
|
fprintf(stderr, "Failed to setup connection to M-bus gateway\n");
|
||||||
|
@ -79,18 +79,18 @@ 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)
|
||||||
{
|
{
|
||||||
fprintf(stderr, "Failed to setup connection to M-bus gateway\n%s\n", mbus_error_str());
|
fprintf(stderr, "Failed to setup connection to M-bus gateway\n%s\n", mbus_error_str());
|
||||||
|
@ -105,18 +105,18 @@ 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)
|
||||||
{
|
{
|
||||||
fprintf(stderr,"Failed to setup connection to M-bus gateway\n");
|
fprintf(stderr,"Failed to setup connection to M-bus gateway\n");
|
||||||
|
@ -59,18 +59,18 @@ 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)
|
||||||
{
|
{
|
||||||
fprintf(stderr, "Failed to setup connection to M-bus gateway\n");
|
fprintf(stderr, "Failed to setup connection to M-bus gateway\n");
|
||||||
|
@ -94,18 +94,18 @@ 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)
|
||||||
{
|
{
|
||||||
fprintf(stderr,"Scan failed: Could not setup connection to M-bus gateway: %s\n", mbus_error_str());
|
fprintf(stderr,"Scan failed: Could not setup connection to M-bus gateway: %s\n", mbus_error_str());
|
||||||
|
Loading…
x
Reference in New Issue
Block a user