I am using the CAN2USb for a long time under Linux via socket can and I have created a library / c++14 wrapper to be able to use simple functions / c++-containers (and function callbacks etc.).
Now I want to include the possibility to use the code under windows by filling code in "ifdef" blocks*.
Is there a simple basic (~20 Lines= example how to use CANAL (CAN Abstraction Layer) API
(
http://www.8devices.com/media/products/ ... AL_API.pdf) ?
Unfortunately the source code of the windows test application does not help me.
(
http://www.8devices.com/media/products/ ... ce_1_0.zip).
*Linux:
#include <net/if.h> // can as network layer
#include <linux/can.h> // socket can headers
#include <linux/can/raw.h> // socket can structs
...
ip link set ...
ifconfig ...
...
//read
fd_set readSet;
FD_ZERO(&readSet);
FD_SET(this->socket, &readSet);
if (select((this->socket + 1), &readSet, NULL, NULL, &timeout) >= 0)
{
if (FD_ISSET(this->socket, &readSet))
{
recvbytes = read(this->socket, &frame_rd, sizeof(struct can_frame));
// data is in frame_rd
//write
write(this->socket, frame, sizeof(struct can_frame));