|
@@ -63,6 +63,7 @@ const char hex_asc_upper[] = "0123456789ABCDEF";
|
|
|
#define hex_asc_upper_lo(x) hex_asc_upper[((x)&0x0F)]
|
|
|
#define hex_asc_upper_hi(x) hex_asc_upper[((x)&0xF0) >> 4]
|
|
|
|
|
|
+
|
|
|
static inline void put_hex_byte(char *buf, __u8 byte)
|
|
|
{
|
|
|
buf[0] = hex_asc_upper_hi(byte);
|
|
@@ -219,13 +220,21 @@ int parse_canframe(char *cs, cu_t *cu)
|
|
|
|
|
|
/* check for optional DLC value for CAN 2.0B frames */
|
|
|
if (cs[++idx] && (tmp = asc2nibble(cs[idx++])) <= CAN_MAX_DLEN) {
|
|
|
+#ifdef OLDCAN
|
|
|
+ cu->cc.can_dlc = tmp;
|
|
|
+#else
|
|
|
cu->cc.len = tmp;
|
|
|
+#endif
|
|
|
|
|
|
/* check for optional raw DLC value for CAN 2.0B frames */
|
|
|
if ((tmp == CAN_MAX_DLEN) && (cs[idx++] == CC_DLC_DELIM)) {
|
|
|
tmp = asc2nibble(cs[idx]);
|
|
|
if ((tmp > CAN_MAX_DLEN) && (tmp <= CAN_MAX_RAW_DLC))
|
|
|
- cu->cc.len8_dlc = tmp;
|
|
|
+#ifdef OLDCAN
|
|
|
+ cu->cc.can_dlc = tmp;
|
|
|
+#else
|
|
|
+ cu->cc.len = tmp;
|
|
|
+#endif
|
|
|
}
|
|
|
}
|
|
|
return mtu;
|
|
@@ -307,7 +316,13 @@ int parse_canframe(char *cs, cu_t *cu)
|
|
|
unsigned char dlc = asc2nibble(cs[idx]);
|
|
|
|
|
|
if ((dlc > CAN_MAX_DLEN) && (dlc <= CAN_MAX_RAW_DLC))
|
|
|
- cu->cc.len8_dlc = dlc;
|
|
|
+ {
|
|
|
+#ifdef OLDCAN
|
|
|
+ cu->cc.can_dlc = dlc;
|
|
|
+#else
|
|
|
+ cu->cc.len = dlc;
|
|
|
+#endif
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
return mtu;
|
|
@@ -394,9 +409,19 @@ int snprintf_canframe(char *buf, size_t size, cu_t *cu, int sep)
|
|
|
|
|
|
/* check for optional raw DLC value for CAN 2.0B frames */
|
|
|
if (len == CAN_MAX_DLEN) {
|
|
|
- if ((cu->cc.len8_dlc > CAN_MAX_DLEN) && (cu->cc.len8_dlc <= CAN_MAX_RAW_DLC)) {
|
|
|
+#ifdef OLDCAN
|
|
|
+ if ((cu->cc.can_dlc > CAN_MAX_DLEN) && (cu->cc.can_dlc <= CAN_MAX_RAW_DLC))
|
|
|
+#else
|
|
|
+ if ((cu->cc.len8_dlc > CAN_MAX_DLEN) && (cu->cc.len8_dlc <= CAN_MAX_RAW_DLC))
|
|
|
+#endif
|
|
|
+ {
|
|
|
buf[offset++] = CC_DLC_DELIM;
|
|
|
- buf[offset++] = hex_asc_upper_lo(cu->cc.len8_dlc);
|
|
|
+#ifdef OLDCAN
|
|
|
+ buf[offset++] = hex_asc_upper_lo(cu->cc.can_dlc);
|
|
|
+#else
|
|
|
+ buf[offset++] = hex_asc_upper_lo(cu->cc.len8_dlc);
|
|
|
+#endif
|
|
|
+
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -424,7 +449,11 @@ int snprintf_canframe(char *buf, size_t size, cu_t *cu, int sep)
|
|
|
|
|
|
/* check for extra DLC when having a Classic CAN with 8 bytes payload */
|
|
|
if (!is_canfd && (len == CAN_MAX_DLEN)) {
|
|
|
- unsigned char dlc = cu->cc.len8_dlc;
|
|
|
+#ifdef OLDCAN
|
|
|
+ unsigned char dlc = cu->cc.can_dlc;
|
|
|
+#else
|
|
|
+ unsigned char dlc = cu->cc.len8_dlc;
|
|
|
+#endif
|
|
|
|
|
|
if ((dlc > CAN_MAX_DLEN) && (dlc <= CAN_MAX_RAW_DLC)) {
|
|
|
buf[offset++] = CC_DLC_DELIM;
|
|
@@ -557,7 +586,11 @@ int snprintf_long_canframe(char *buf, size_t size, cu_t *cu, int view)
|
|
|
/* The len value is sanitized (see above) */
|
|
|
if (!is_canfd) {
|
|
|
if (view & CANLIB_VIEW_LEN8_DLC) {
|
|
|
- unsigned char dlc = cu->cc.len8_dlc;
|
|
|
+#ifdef OLDCAN
|
|
|
+ unsigned char dlc = cu->cc.can_dlc;
|
|
|
+#else
|
|
|
+ unsigned char dlc = cu->cc.len8_dlc;
|
|
|
+#endif
|
|
|
|
|
|
/* fall back to len if we don't have a valid DLC > 8 */
|
|
|
if (!((len == CAN_MAX_DLEN) && (dlc > CAN_MAX_DLEN) &&
|