I posted same issue in libpcap's github repo.
I have a program woking well on my PC (ubuntu 16.04 amd64, with libpcap0.8 and libpcap0.8-dev installed from ubuntu apt repo, version 1.7.4) . Now I'm running that CAN bus monitor in my raspberry pi 3 and I found some issues.
While I'm opening a socketcan interface with libpcap.
Code: Select all
char err_buff[PCAP_ERRBUF_SIZE];
pcap_t *hl;
hl = pcap_open_live(CAN_DEV.c_str(), BUFSIZ, 1, 1000, err_buff);
if (hl == NULL)
{
/* open failed */
std::cout << "Couldn't open device " << CAN_DEV << std::endl;
std::cout <<" Error: " << err_buff << std::endl;
return -1;
}
if (pcap_datalink(hl) != DLT_CAN_SOCKETCAN)
{
// it is not a socketCAN frame
std::cout << "Device doesn't use socketCAN, it use " << pcap_datalink(hl) << std::endl;
return -1;
}
However on my PC it's working as expected.
FYI, my raspberry pi 3 is running Linux 4.14.33. I've recompiled the kernel to support CAN devices and my PCAN-USB FD adapter.
And I set up the CAN interface using:
Code: Select all
sudo ip link set can0 type can bitrate 500000 triple-sampling on
sudo ifconfig can0 up
So I guess the problem lies in somewhere else like kernel configuration or other libraries missing or something else?
Please advice... Is there anyone ever encountered samilar issue? Any help is appreciated!