15const BYTE
ECI_CAN_FD_DLC_LUT[16] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 12, 16, 20, 24, 32, 48, 64};
17inline void EciPrintCtrlMessage(
const ECI_CTRL_MESSAGE *pStcCtrlMsg,
const std::string &strDevice,
const bool isSending)
19 if (pStcCtrlMsg !=
nullptr)
21 switch (pStcCtrlMsg->wCtrlClass)
25 if ((ECI_STRUCT_VERSION_V0 == pStcCtrlMsg->u.sCanMessage.dwVer) ||
26 (ECI_STRUCT_VERSION_V1 == pStcCtrlMsg->u.sCanMessage.dwVer))
28 OS_Printf(isSending ?
">>>>> CAN >>>>> " :
"<<<<< CAN <<<<< ");
29 OS_Printf(
"Device: %s, Time: %10u, Type: %2u, ID: %08X, Flags: %c%c%c%c%c%c ", strDevice.c_str(),
30 pStcCtrlMsg->u.sCanMessage.u.V1.dwTime,
31 pStcCtrlMsg->u.sCanMessage.u.V1.uMsgInfo.Bits.type,
32 pStcCtrlMsg->u.sCanMessage.u.V1.dwMsgId,
33 pStcCtrlMsg->u.sCanMessage.u.V1.uMsgInfo.Bits.ext ?
'E' :
' ',
34 pStcCtrlMsg->u.sCanMessage.u.V1.uMsgInfo.Bits.rtr ?
'R' :
' ',
35 pStcCtrlMsg->u.sCanMessage.u.V1.uMsgInfo.Bits.srr ?
'S' :
' ',
36 pStcCtrlMsg->u.sCanMessage.u.V1.uMsgInfo.Bits.edl ?
'L' :
' ',
37 pStcCtrlMsg->u.sCanMessage.u.V1.uMsgInfo.Bits.brs ?
'B' :
' ',
38 pStcCtrlMsg->u.sCanMessage.u.V1.uMsgInfo.Bits.ovr ?
'O' :
' ');
40 if (not pStcCtrlMsg->u.sCanMessage.u.V1.uMsgInfo.Bits.rtr)
44 if (ECI_STRUCT_VERSION_V0 == pStcCtrlMsg->u.sCanMessage.dwVer)
46 bRealLen =
static_cast<BYTE
>(
47 std::min(
static_cast<uint64_t
>(bRealLen), std::size(pStcCtrlMsg->u.sCanMessage.u.V0.abData)));
49 else if (ECI_STRUCT_VERSION_V1 == pStcCtrlMsg->u.sCanMessage.dwVer)
51 bRealLen =
static_cast<BYTE
>(
52 std::min(
static_cast<uint64_t
>(bRealLen), std::size(pStcCtrlMsg->u.sCanMessage.u.V1.abData)));
59 for (BYTE bIndex = 0; bIndex < bRealLen; bIndex++)
61 OS_Printf(
"%02X ", pStcCtrlMsg->u.sCanMessage.u.V1.abData[bIndex]);
67 OS_Printf(
"DLC: %u", pStcCtrlMsg->u.sCanMessage.u.V0.uMsgInfo.Bits.dlc);
77 if (ECI_STRUCT_VERSION_V0 == pStcCtrlMsg->u.sLinMessage.dwVer)
80 "Time: %10u, Type: %2u, ID: %08X, Flags: %c%c%c%c ", pStcCtrlMsg->u.sLinMessage.u.V0.dwTime,
81 pStcCtrlMsg->u.sLinMessage.u.V0.uMsgInfo.Bits.type, pStcCtrlMsg->u.sLinMessage.u.V0.dwMsgId,
82 pStcCtrlMsg->u.sLinMessage.u.V0.uMsgInfo.Bits.ecs ?
'E' :
' ',
83 pStcCtrlMsg->u.sLinMessage.u.V0.uMsgInfo.Bits.ido ?
'I' :
' ',
84 pStcCtrlMsg->u.sLinMessage.u.V0.uMsgInfo.Bits.sor ?
'S' :
' ',
85 pStcCtrlMsg->u.sLinMessage.u.V0.uMsgInfo.Bits.ovr ?
'O' :
' ');
87 if (!pStcCtrlMsg->u.sLinMessage.u.V0.uMsgInfo.Bits.ido)
89 if (pStcCtrlMsg->u.sLinMessage.u.V0.uMsgInfo.Bits.dlc)
93 for (bIndex = 0; bIndex < pStcCtrlMsg->u.sLinMessage.u.V0.uMsgInfo.Bits.dlc; bIndex++)
95 OS_Printf(
"%02X ", pStcCtrlMsg->u.sLinMessage.u.V0.abData[bIndex]);
101 OS_Printf(
"DLC: %u", pStcCtrlMsg->u.sLinMessage.u.V0.uMsgInfo.Bits.dlc);
115 OS_Printf(
"ERROR: invalid pointer: pStcCtrlMsg\n");
120 std::string *hwSerial, uint32_t *hwPort,
unsigned char *operationMode,
121 unsigned char *busTimingRegister0,
unsigned char *busTimingRegister1)
123 bool isParsedOK =
true;
140 *operationMode = ECI_CAN_OPMODE_EXTENDED;
144 *operationMode = ECI_CAN_OPMODE_LISTONLY;
148 *operationMode = ECI_CAN_OPMODE_LOWSPEED;
152 *operationMode = ECI_CAN_OPMODE_STANDARD;
159 IV_ASSERT_MSG(
"[IXXATCommonFunctions:parseBoard] Open mode not valid.");
165 *operationMode |= ECI_CAN_OPMODE_ERRFRAME;
171 *busTimingRegister0 = ECI_CAN_BT0_10KB;
172 *busTimingRegister1 = ECI_CAN_BT1_10KB;
176 *busTimingRegister0 = ECI_CAN_BT0_20KB;
177 *busTimingRegister1 = ECI_CAN_BT1_20KB;
181 *busTimingRegister0 = ECI_CAN_BT0_50KB;
182 *busTimingRegister1 = ECI_CAN_BT1_50KB;
186 *busTimingRegister0 = ECI_CAN_BT0_100KB;
187 *busTimingRegister1 = ECI_CAN_BT1_100KB;
191 *busTimingRegister0 = ECI_CAN_BT0_125KB;
192 *busTimingRegister1 = ECI_CAN_BT1_125KB;
196 *busTimingRegister0 = ECI_CAN_BT0_250KB;
197 *busTimingRegister1 = ECI_CAN_BT1_250KB;
201 *busTimingRegister0 = ECI_CAN_BT0_500KB;
202 *busTimingRegister1 = ECI_CAN_BT1_500KB;
206 *busTimingRegister0 = ECI_CAN_BT0_800KB;
207 *busTimingRegister1 = ECI_CAN_BT1_800KB;
211 *busTimingRegister0 = ECI_CAN_BT0_1000KB;
212 *busTimingRegister1 = ECI_CAN_BT1_1000KB;
217 IV_ASSERT_MSG(
"[IXXATCommonFunctions:parseBoard] Baud rate not valid.");
bool parseBoard(const iv::model::comms::NetworkData &commConfig, IIxxatInterface **interfaceOpt, std::string *hwSerial, uint32_t *hwPort, unsigned char *operationMode, unsigned char *busTimingRegister0, unsigned char *busTimingRegister1)
Definition IxxatCommonFunctions.hpp:119