Commit 64015b70 authored by Franksen, Benjamin's avatar Franksen, Benjamin
Browse files

scan: print errors and warnings to stderr

parent 07487640
......@@ -226,11 +226,11 @@ static ssize_t ellsi_read(void *pvt, struct can_frame *frame) {
ntohl(state->msg.header.subcommand),
ntohl(state->msg.header.payloadLen));
if (nbytes < 0) {
printf("ellsi_read: recv failed\n");
fprintf(stderr, "ellsi_read: recv failed\n");
return -1;
}
if (state->msg.header.magic != htonl(ELLSI_MAGIC)) {
printf("ellsi_read: bad magic\n");
fprintf(stderr, "ellsi_read: bad magic\n");
return -1;
}
switch (ntohl(state->msg.header.command)) {
......@@ -245,7 +245,7 @@ static ssize_t ellsi_read(void *pvt, struct can_frame *frame) {
assert(state->msg.header.payloadLen == 0);
nbytes = write(state->sock, &state->msg.header, sizeof(state->msg.header));
if (nbytes < sizeof(state->msg.header)) {
printf("ellsi_read: reply to heartbeat failed\n");
fprintf(stderr, "ellsi_read: reply to heartbeat failed\n");
}
break;
#if 0
......@@ -263,7 +263,7 @@ static ssize_t ellsi_read(void *pvt, struct can_frame *frame) {
state->unread--;
this = state->next++;
if (this->len & CAN_TELEGRAM_LEN_TXDONE) {
printf("ellsi_read: ignored confirmation (TXDONE)\n");
fprintf(stderr, "ellsi_read: ignored confirmation (TXDONE)\n");
return ellsi_read(pvt, frame);
}
frame->can_id = ntohl(this->id) & CAN_SFF_MASK;
......@@ -295,7 +295,7 @@ static int ellsi_check(int sock) {
memset(&ack, 0, sizeof(ack));
r = recv(sock, &ack, sizeof(ack), MSG_WAITALL);
if (r < 0) {
printf("ellsi_check: recv failed\n"); return r;
fprintf(stderr, "ellsi_check: recv failed\n"); return r;
}
debug("ellsi_check: got back magic %#x cmd %#x subcmd %#x payloadLen %d\n",
ntohl(ack.header.magic),
......@@ -335,7 +335,7 @@ static int ellsi_register(ellsi_state_t *state) {
ELLSI_MAGIC, ELLSI_CMD_REGISTER, ELLSI_SUBCMD_AUTOACK);
r = write(state->sock, &msg, sizeof(msg));
if (r < 0) {
printf("ellsi_register: write failed\n"); return r;
fprintf(stderr, "ellsi_register: write failed\n"); return r;
}
return ellsi_check(state->sock);
}
......@@ -358,21 +358,21 @@ static int ellsi_set_baudrate(ellsi_state_t *state, int baudrate) {
msg.header.payloadLen = htonl(sizeof(msg.payload));
msg.payload = htonl(code);
} else {
printf("ignoring invalid baudrate %d\n", baudrate);
fprintf(stderr, "ignoring invalid baudrate %d\n", baudrate);
}
}
debug("ellsi_set_baudrate: send magic %#x cmd %#x subcmd %#x baudrate_code %#x\n",
ELLSI_MAGIC, ELLSI_CMD_CTRL, ELLSI_IOCTL_CAN_SET_BAUDRATE, code);
r = write(state->sock, &msg, sizeof(msg));
if (r < 0) {
printf("ellsi_set_baudrate: write failed\n"); return r;
fprintf(stderr, "ellsi_set_baudrate: write failed\n"); return r;
}
msg.header.command = htonl(ELLSI_CMD_CTRL);
msg.header.subcommand = htonl(ELLSI_IOCTL_GET_LAST_STATE);
msg.header.payloadLen = htonl(sizeof(msg.payload));
r = write(state->sock, &msg, sizeof(msg));
if (r < 0) {
printf("ellsi_set_baudrate: write failed\n"); return r;
fprintf(stderr, "ellsi_set_baudrate: write failed\n"); return r;
}
return ellsi_check(state->sock);
}
......@@ -395,14 +395,14 @@ static int ellsi_add_can_ids(ellsi_state_t *state) {
ELLSI_MAGIC, ELLSI_CMD_CTRL, ELLSI_IOCTL_CAN_ID_ADD);
r = write(state->sock, &msg, sizeof(msg));
if (r < 0) {
printf("ellsi_add_can_ids: write failed\n"); return r;
fprintf(stderr, "ellsi_add_can_ids: write failed\n"); return r;
}
msg.header.command = htonl(ELLSI_CMD_CTRL);
msg.header.subcommand = htonl(ELLSI_IOCTL_GET_LAST_STATE);
msg.header.payloadLen = htonl(sizeof(msg.payload));
r = write(state->sock, &msg, sizeof(msg));
if (r < 0) {
printf("ellsi_add_can_ids: write failed\n"); return r;
fprintf(stderr, "ellsi_add_can_ids: write failed\n"); return r;
}
return ellsi_check(state->sock);
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment