Skip to content

Commit

Permalink
isotp: add receive timestamp to PDU as known from rawmode
Browse files Browse the repository at this point in the history
Signed-off-by: Oliver Hartkopp <[email protected]>
  • Loading branch information
hartkopp committed Dec 4, 2014
1 parent d5b2346 commit fe506e5
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions state_isotp.c
Original file line number Diff line number Diff line change
Expand Up @@ -155,12 +155,24 @@ inline void state_isotp() {

if (FD_ISSET(si, &readfds)) {

struct timeval tv = {0};

items = read(si, isobuf, ISOTPLEN);

/* read timestamp data */
if(ioctl(si, SIOCGSTAMP, &tv) < 0) {
PRINT_ERROR("Could not receive timestamp\n");
}

if (items > 0 && items <= ISOTPLEN) {

sprintf(rxmsg, "< pdu "); /* strlen = 6 */
int startlen;

sprintf(rxmsg, "< pdu %ld.%06ld ", tv.tv_sec, tv.tv_usec);
startlen = strlen(rxmsg);

for (i=0; i < items; i++)
sprintf(rxmsg + 6 + 2*i, "%02X", isobuf[i]);
sprintf(rxmsg + startlen + 2*i, "%02X", isobuf[i]);

sprintf(rxmsg + strlen(rxmsg), " >");
send(client_socket, rxmsg, strlen(rxmsg), 0);
Expand Down

0 comments on commit fe506e5

Please sign in to comment.