I am working on an API to read CAN signal. This part of the code outputs the received CAN in the form of a string.
xlCanGetEventString(&xlCanRxEvt)
The CAN signal is in the form of:
XL_CAN_EV_TAG_RX_OK ch:1 t=9026813952 id:98FF1880 dlc:8 862EC5350C138336
XL_CAN_EV_TAG_RX_OK ch:1 t=9027108864 id:98FF1980 dlc:8 500111065C018C03
XL_CAN_EV_TAG_RX_OK ch:1 t=9027411968 id:98FF1A80 dlc:8 0000FFFFFFFFFFFF
XL_CAN_EV_TAG_RX_OK ch:1 t=9027411968 id:98FF1A80 dlc:8 0000FFFFFFFFFFFF
XL_CAN_EV_TAG_RX_OK ch:1 t=9027657728 id:98FF5180 dlc:5 C000000000
In that signal I need to read the IDs from each line and then display the data only for the IDs I need. I am currently doing this by using a bunch of if and for statements, and using char arrays to read different part of the line.
This feels very inefficient to me, is there another way to do it ? To maybe directly extract the Id part or compare the ID part without having to store the whole thread into an array ? Or any best or efficient way to do the same ? I don't find a variable storing the data or ID in the typedef struct xlCanRxEvt either. Any suggestion will be greatly appreciated.