tabify all changes to match project coding style
parent
39ebc30e39
commit
449c0b5658
80
candump.c
80
candump.c
|
|
@ -315,9 +315,9 @@ int main(int argc, char **argv)
|
||||||
struct timeval tv, last_tv;
|
struct timeval tv, last_tv;
|
||||||
int timeout_ms = -1; /* default to no timeout */
|
int timeout_ms = -1; /* default to no timeout */
|
||||||
FILE *logfile = NULL;
|
FILE *logfile = NULL;
|
||||||
int buffer_length = 0; /* number of entries to store in ring buffer */
|
int buffer_length = 0; /* number of entries to store in ring buffer */
|
||||||
int buffer_index = 0;
|
int buffer_index = 0;
|
||||||
unsigned char circular = 0;
|
unsigned char circular = 0;
|
||||||
|
|
||||||
|
|
||||||
signal(SIGTERM, sigterm);
|
signal(SIGTERM, sigterm);
|
||||||
|
|
@ -379,10 +379,10 @@ int main(int argc, char **argv)
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'b':
|
case 'b':
|
||||||
buffer_length = atoi(optarg);
|
buffer_length = atoi(optarg);
|
||||||
circular = 1;
|
circular = 1;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'l':
|
case 'l':
|
||||||
log = 1;
|
log = 1;
|
||||||
|
|
@ -445,15 +445,15 @@ int main(int argc, char **argv)
|
||||||
exit(0);
|
exit(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (circular && log){
|
if (circular && log){
|
||||||
fprintf(stderr, "Circular buffer and file output can't both be selected: please use either option in isolation\n");
|
fprintf(stderr, "Circular buffer and file output can't both be selected: please use either option in isolation\n");
|
||||||
exit(0);
|
exit(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (circular && logfrmt){
|
if (circular && logfrmt){
|
||||||
fprintf(stderr, "Circular buffer and file format output can't both be selected: please use either option in isolation\n");
|
fprintf(stderr, "Circular buffer and file format output can't both be selected: please use either option in isolation\n");
|
||||||
exit(0);
|
exit(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (silent == SILENT_INI) {
|
if (silent == SILENT_INI) {
|
||||||
if (log || circular) {
|
if (log || circular) {
|
||||||
|
|
@ -693,10 +693,10 @@ int main(int argc, char **argv)
|
||||||
if (silent != SILENT_ON)
|
if (silent != SILENT_ON)
|
||||||
fprintf(stderr, "Warning: Console output active while logging!\n");
|
fprintf(stderr, "Warning: Console output active while logging!\n");
|
||||||
|
|
||||||
if(circular)
|
if(circular)
|
||||||
fprintf(stderr, "Enabling Circular Logfile (max %d data points) '%s'\n", buffer_length, fname);
|
fprintf(stderr, "Enabling Circular Logfile (max %d data points) '%s'\n", buffer_length, fname);
|
||||||
else
|
else
|
||||||
fprintf(stderr, "Enabling Logfile '%s'\n", fname);
|
fprintf(stderr, "Enabling Logfile '%s'\n", fname);
|
||||||
|
|
||||||
logfile = fopen(fname, circular? "w+" : "w");
|
logfile = fopen(fname, circular? "w+" : "w");
|
||||||
if (!logfile) {
|
if (!logfile) {
|
||||||
|
|
@ -804,30 +804,30 @@ int main(int argc, char **argv)
|
||||||
extra_info = " R";
|
extra_info = " R";
|
||||||
}
|
}
|
||||||
|
|
||||||
if (circular) {
|
if (circular) {
|
||||||
char output[CL_CFSZ + TIMESTAMPSZ];
|
char output[CL_CFSZ + TIMESTAMPSZ];
|
||||||
char buf[CL_CFSZ]; /* max length */
|
char buf[CL_CFSZ]; /* max length */
|
||||||
char ts_buf[TIMESTAMPSZ];
|
char ts_buf[TIMESTAMPSZ];
|
||||||
|
|
||||||
sprint_timestamp(logtimestamp, &tv, &last_tv, ts_buf);
|
sprint_timestamp(logtimestamp, &tv, &last_tv, ts_buf);
|
||||||
/* log CAN frame with absolute timestamp & device */
|
/* log CAN frame with absolute timestamp & device */
|
||||||
sprint_canframe(buf, &frame, 0, maxdlen);
|
sprint_canframe(buf, &frame, 0, maxdlen);
|
||||||
|
|
||||||
/* force a payload size of exactly 25: this corresponds to
|
/* force a payload size of exactly 25: this corresponds to
|
||||||
8 characters for an extended can-id, 1 character for the hash
|
8 characters for an extended can-id, 1 character for the hash
|
||||||
and 16 character of payload (maximum allowable size)
|
and 16 character of payload (maximum allowable size)
|
||||||
*/
|
*/
|
||||||
snprintf(output, CL_CFSZ + TIMESTAMPSZ, "%s%*s %-25.25s%s\n", ts_buf,
|
snprintf(output, CL_CFSZ + TIMESTAMPSZ, "%s%*s %-25.25s%s\n", ts_buf,
|
||||||
max_devname_len, devname[idx], buf,
|
max_devname_len, devname[idx], buf,
|
||||||
extra_info);
|
extra_info);
|
||||||
|
|
||||||
/* if the buffer index has grown past the desired count, seek to head of file and reset counter */
|
/* if the buffer index has grown past the desired count, seek to head of file and reset counter */
|
||||||
if(++buffer_index >= buffer_length){
|
if(++buffer_index >= buffer_length){
|
||||||
rewind(logfile);
|
rewind(logfile);
|
||||||
buffer_index = 0;
|
buffer_index = 0;
|
||||||
}
|
}
|
||||||
fprintf(logfile, output);
|
fprintf(logfile, output);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (log) {
|
if (log) {
|
||||||
char buf[CL_CFSZ]; /* max length */
|
char buf[CL_CFSZ]; /* max length */
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue