Skip to content

Instantly share code, notes, and snippets.

@jaeoh2
Created February 14, 2019 07:49
Show Gist options
  • Save jaeoh2/fb14b4b0d32ffc066da18dc0c0809f2d to your computer and use it in GitHub Desktop.
Save jaeoh2/fb14b4b0d32ffc066da18dc0c0809f2d to your computer and use it in GitHub Desktop.
CAN bitfield parser for ROS callback
typedef struct CAN_msgTag
{
uint8_t Sig_1 : 8;
uint8_t Sig_2 : 8;
uint8_t Sig_3 : 8;
uint8_t Sig_4 : 8;
uint8_t Sig_5 : 8;
uint8_t Sig_6 : 8;
uint8_t Sig_7 : 8;
uint8_t Sig_8 : 8;
} CAN_msg;
void ROS_callback(const CanFrame::ConstPtr& msg)
{
CAN_msg *ptr;
memcpy(&ptr, &msg->data, 8);
}
@ssyonny
Copy link

ssyonny commented Dec 4, 2022

uint8 인데 비트필드로 8을 줄 필요가 있남?

@jaeoh2
Copy link
Author

jaeoh2 commented Dec 4, 2022

uint8 인데 비트필드로 8을 줄 필요가 있남?

Signal 길이에 따라서 비트필드 값으로 넣어주셔야 합니다

@ssyonny
Copy link

ssyonny commented Dec 5, 2022

내말은 비트필드 문이 의미가 없어보인다는거지

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment