Skip to content

Commit d488f03

Browse files
committed
Change length search to old style
1 parent 47dbff6 commit d488f03

File tree

1 file changed

+16
-3
lines changed

1 file changed

+16
-3
lines changed

socketcandcl.c

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -302,7 +302,13 @@ inline void state_connected() {
302302

303303
sscanf(buf, "< frame %x %*d.%*d %s >", &frame.can_id, data_str);
304304

305-
if (element_length(buf, 2) == 8)
305+
char *s = buf + 7;
306+
for (; ++s;) {
307+
if (*s == ' ') {
308+
break;
309+
}
310+
}
311+
if ((s - buf - 7) > 4)
306312
frame.can_id |= CAN_EFF_FLAG;
307313

308314
frame.can_dlc = strlen(data_str) / 2;
@@ -322,8 +328,15 @@ inline void state_connected() {
322328
//force DLC 0 since it is undocumented feature
323329
frame.can_dlc = 0;
324330
frame.can_id |= CAN_RTR_FLAG;
325-
if (element_length(buf, 2) == 8)
326-
frame.can_id |= CAN_EFF_FLAG; //extended
331+
332+
char *s = buf + 6;
333+
for (; ++s;) {
334+
if (*s == ' ') {
335+
break;
336+
}
337+
}
338+
if ((s - buf - 7) > 4)
339+
frame.can_id |= CAN_EFF_FLAG;
327340

328341
ret = write(raw_socket, &frame, sizeof(struct can_frame));
329342
if (ret < sizeof(struct can_frame)) {

0 commit comments

Comments
 (0)