Skip to content

Commit

Permalink
use separate commands for isotp PDUs
Browse files Browse the repository at this point in the history
< pdu ... : is the data from the CAN ISOTP socket
< sendpdu ... : is the request from the client to send on CAN

Signed-off-by: Oliver Hartkopp <[email protected]>
  • Loading branch information
hartkopp committed Dec 4, 2014
1 parent d510fb2 commit 7419642
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions state_isotp.c
Original file line number Diff line number Diff line change
Expand Up @@ -157,9 +157,9 @@ inline void state_isotp() {
items = read(si, isobuf, ISOTPLEN);
if (items > 0 && items <= ISOTPLEN) {

sprintf(rxmsg, "< isopdu "); /* strlen = 9 */
sprintf(rxmsg, "< pdu "); /* strlen = 6 */
for (i=0; i < items; i++)
sprintf(rxmsg + 9 + 2*i, "%02X", isobuf[i]);
sprintf(rxmsg + 6 + 2*i, "%02X", isobuf[i]);

sprintf(rxmsg + strlen(rxmsg), " >");
send(client_socket, rxmsg, strlen(rxmsg), 0);
Expand All @@ -186,7 +186,7 @@ inline void state_isotp() {
return;
}

if(!strncmp("< isopdu ", buf, 9)) {
if(!strncmp("< sendpdu ", buf, 10)) {
items = element_length(buf, 2);
if (items & 1) {
PRINT_ERROR("odd number of ASCII Hex values\n");
Expand All @@ -201,11 +201,11 @@ inline void state_isotp() {

for (i = 0; i < items; i++) {

tmp = asc2nibble(buf[(2*i) + 9]);
tmp = asc2nibble(buf[(2*i) + 10]);
if (tmp > 0x0F)
return;
isobuf[i] = (tmp << 4);
tmp = asc2nibble(buf[(2*i) + 10]);
tmp = asc2nibble(buf[(2*i) + 11]);
if (tmp > 0x0F)
return;
isobuf[i] |= tmp;
Expand Down

0 comments on commit 7419642

Please sign in to comment.