void diag_l3_vag_decode(UNUSED(struct diag_l3_conn *d_l3_conn), struct diag_msg *msg, char *buf, size_t bufsize) { char buf2[128]; char buf3[16]; const char *s; fprintf(stderr, FLFMT "Obviously broken code !\n", FL); switch (msg->type) { case DIAG_VAG_CMD_DTC_CLEAR: s = "Clear DTCs"; break; case DIAG_VAG_CMD_END_COMMS: s = "End Comms"; break; case DIAG_VAG_CMD_DTC_RQST: s = "Request DTCs"; break; case DIAG_VAG_CMD_READ_DATA: s = "Read Data (single)"; break; case DIAG_VAG_RSP_ASCII: s = "ASCII Data"; break; case DIAG_VAG_RSP_HEX: s = "Hex Data"; break; default: snprintf(buf3, sizeof(buf3), "0x%X", msg->type); s = buf3; break; } snprintf(buf2, sizeof(buf2), "Command: %s: ", s); smartcat(buf, bufsize, buf2); snprintf(buf2, sizeof(buf2), "Data : "); smartcat(buf, bufsize, buf2); for (int i=3; i < msg->data[0]; i++) { snprintf(buf2, sizeof(buf2), "0x%X ", msg->data[i]); smartcat(buf, bufsize, buf2); } smartcat(buf, bufsize, "\n"); return; }
static char * diag_l3_vag_decode(UNUSED(struct diag_l3_conn *d_l3_conn), struct diag_msg *msg, char *buf, size_t bufsize) { char buf2[128]; char buf3[16]; const char *s; int i; /* XXX What is supposed to go here for arguments? * The "sprintf(" that follows had no arguments for the format, I added the "0, 0". */ fprintf(stderr, FLFMT "Obviously broken code !\n", FL); snprintf(buf, bufsize, "Block Len 0x%X, Counter 0x%X ", 0, 0); switch (msg->data[2]) { case 0x05: s = "Clear DTCs"; break; case 0x06: s = "End Comms"; break; case 0x07: s = "Request DTCs"; break; case 0x08: s = "Read Data (single)"; break; case 0x09: s = "Ack"; break; case 0xF6: s = "ASCII Data"; break; case 0xFC: s = "Hex Data"; break; default: /* XXX The argument Was "buf[2]" and not msg->data[2], which must be wrong. */ snprintf(buf3, sizeof(buf3), "0x%X", msg->data[2]); s = buf3; break; } snprintf(buf2, sizeof(buf2), "Command: %s: ", s); smartcat(buf, bufsize, buf2); snprintf(buf2, sizeof(buf2), "Data : "); smartcat(buf, bufsize, buf2); for (i=3; i < msg->data[0]; i++) { snprintf(buf2, sizeof(buf2), "0x%X ", msg->data[i]); smartcat(buf, bufsize, buf2); } smartcat(buf, bufsize, "\n"); return buf; }