struct termios topts;
struct ifreq ifr;
int running = 1;
+ int tstamp = 0;
char txcmd, rxcmd;
char txbuf[SLC_MTU];
char rxbuf[SLC_MTU];
setsockopt(s, SOL_CAN_RAW,
CAN_RAW_FILTER, &fi,
sizeof(struct can_filter));
+ continue;
+ }
+
+ /* check for timestamp on/off command */
+ if (rxcmd == 'Z') {
+ tstamp = rxbuf[1] & 0x01;
+ continue;
}
if ((rxcmd != 't') && (rxcmd != 'T') &&
sprintf(&txbuf[txp + 2*i], "%02X",
txf.data[i]);
+ if (tstamp) {
+ struct timeval tv;
+
+ if (ioctl(s, SIOCGSTAMP, &tv) < 0)
+ perror("SIOCGSTAMP");
+
+ sprintf(&txbuf[txp + 2*txf.can_dlc], "%04lX",
+ (tv.tv_sec%60)*1000 + tv.tv_usec/1000);
+ }
+
strcat(txbuf, "\r"); /* add terminating character */
nbytes = write(p, txbuf, strlen(txbuf));
if (nbytes < 0) {