C2000 CAN RX

조회 수: 7 (최근 30일)
Yusuf Selim KARATAS
Yusuf Selim KARATAS 2020년 5월 9일
답변: UDAYA PEDDIRAJU 2024년 8월 30일
Dear All,
I am using Simulink to build a model to receive CAN messages. You can see diagram below. I am getting "error: expression must have struct or union type" error. Please help me. How can I solve that?
Thanks.
"ykarata1_BMS_C2000_RX_deneme.c", line 67: error: expression must have struct or union type
"ykarata1_BMS_C2000_RX_deneme.c", line 68: error: expression must have struct or union type
"ykarata1_BMS_C2000_RX_deneme.c", line 70: error: expression must have struct or union type
"ykarata1_BMS_C2000_RX_deneme.c", line 71: error: expression must have struct or union type
"ykarata1_BMS_C2000_RX_deneme.c", line 73: error: expression must have struct or union type
/* S-Function (scanunpack): '<S1>/CAN Unpack' */
65 {
66 /* S-Function (scanunpack): '<S1>/CAN Unpack' */
67 if ((1 == ykarata1_BMS_C2000_RX_deneme_B.eCANReceive_o2[0].Length) &&
68 (ykarata1_BMS_C2000_RX_deneme_B.eCANReceive_o2[0].ID != INVALID_CAN_ID)
69 ) {
70 if ((4 == ykarata1_BMS_C2000_RX_deneme_B.eCANReceive_o2[0].ID) && (0U ==
71 ykarata1_BMS_C2000_RX_deneme_B.eCANReceive_o2[0].Extended) ) {
72 (void) memcpy(&ykarata1_BMS_C2000_RX_deneme_B.CANUnpack,
73 ykarata1_BMS_C2000_RX_deneme_B.eCANReceive_o2[0].Data,
74 1 * sizeof(uint8_T));
75 }
76 }
77 }
  댓글 수: 1
Erich Russenberger
Erich Russenberger 2024년 7월 4일
@Yusuf Selim KARATAS, did you solve this issue? I have the same now.. thanks.

댓글을 달려면 로그인하십시오.

답변 (1개)

UDAYA PEDDIRAJU
UDAYA PEDDIRAJU 2024년 8월 30일
Hi Yusuf,
The error "expression must have struct or union type" in your Simulink model indicates a mismatch in data types.
To resolving it:
  1. Ensure that ykarata1_BMS_C2000_RX_deneme_B.eCANReceive_o2[0] and ykarata1_BMS_C2000_RX_deneme_B.CANUnpack have compatible data structures.
  2. Double-check that you're using correct indices to access elements within the eCANReceive_o2 array.
  3. If necessary, cast data to the appropriate type using (struct *) or (union *).

태그

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by