print all errors on stderr in all binaries

This commit is contained in:
Stefan Wahren
2013-04-26 08:18:17 +02:00
parent ea0c6c3455
commit f6601ca40f
8 changed files with 38 additions and 38 deletions

View File

@ -51,7 +51,7 @@ main(int argc, char **argv)
if (mbus_is_secondary_address(addr) == 0)
{
printf("Misformatted secondary address. Must be 16 character HEX number.\n");
fprintf(stderr,"Misformatted secondary address. Must be 16 character HEX number.\n");
return 1;
}
@ -63,19 +63,19 @@ main(int argc, char **argv)
if (mbus_connect(handle) == -1)
{
printf("Failed to setup connection to M-bus gateway\n");
fprintf(stderr,"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");
fprintf(stderr,"Failed to set baud rate.\n");
return 1;
}
if (mbus_send_select_frame(handle, addr) == -1)
{
printf("Failed to send selection frame: %s\n", mbus_error_str());
fprintf(stderr,"Failed to send selection frame: %s\n", mbus_error_str());
return 1;
}
@ -83,13 +83,13 @@ main(int argc, char **argv)
if (ret == MBUS_RECV_RESULT_TIMEOUT)
{
printf("No reply from device with secondary address %s: %s\n", argv[2], mbus_error_str());
fprintf(stderr,"No reply from device with secondary address %s: %s\n", argv[2], mbus_error_str());
return 1;
}
if (ret == MBUS_RECV_RESULT_INVALID)
{
printf("Invalid reply from %s: The address address probably match more than one device: %s\n", argv[2], mbus_error_str());
fprintf(stderr,"Invalid reply from %s: The address address probably match more than one device: %s\n", argv[2], mbus_error_str());
return 1;
}
@ -97,13 +97,13 @@ main(int argc, char **argv)
{
if (mbus_send_request_frame(handle, MBUS_ADDRESS_NETWORK_LAYER) == -1)
{
printf("Failed to send request to selected secondary device: %s\n", mbus_error_str());
fprintf(stderr,"Failed to send request to selected secondary device: %s\n", mbus_error_str());
return 1;
}
if (mbus_recv_frame(handle, &reply) != MBUS_RECV_RESULT_OK)
{
printf("Failed to recieve reply from selected secondary device: %s\n", mbus_error_str());
fprintf(stderr,"Failed to recieve reply from selected secondary device: %s\n", mbus_error_str());
return 1;
}
@ -115,7 +115,7 @@ main(int argc, char **argv)
}
else
{
printf("Unknown reply:\n");
fprintf(stderr,"Unknown reply:\n");
mbus_frame_print(&reply);
}