246 netId=par.check(
"CanDeviceNum", Value(-1),
"numeric identifier of the can device").asInt32();
247 if (netId == -1) netId=par.check(
"canDeviceNum", Value(-1),
"numeric identifier of the can device").asInt32();
249 txTimeout=par.check(
"CanTxTimeout", Value(500),
"timeout on transmission [ms]").asInt32();
250 if (txTimeout == 500) txTimeout=par.check(
"canTxTimeout", Value(500),
"timeout on transmission [ms]").asInt32();
252 rxTimeout=par.check(
"CanRxTimeout", Value(500),
"timeout on receive when calling blocking read [ms]").asInt32() ;
253 if (rxTimeout == 500) rxTimeout=par.check(
"canRxTimeout", Value(500),
"timeout on receive when calling blocking read [ms]").asInt32() ;
255 canTxQueue=par.check(
"CanTxQueue", Value(
TX_QUEUE_SIZE),
"length of tx buffer").asInt32();
258 canRxQueue=par.check(
"CanRxQueue", Value(
RX_QUEUE_SIZE),
"length of rx buffer").asInt32() ;
261 int so_timestamping_flags = 0;
263 skt = socket(
PF_CAN, SOCK_RAW, CAN_RAW );
267 sprintf (ifr.ifr_name,
"can%d",netId);
268 ioctl(skt, SIOCGIFINDEX, &ifr);
271 struct sockaddr_can addr;
273 addr.can_ifindex = ifr.ifr_ifindex;
274 bind( skt, (
struct sockaddr*)&addr,
sizeof(addr) );
277 if (-1 == (flags = fcntl(skt, F_GETFL, 0))) flags = 0;
278 fcntl(skt, F_SETFL, flags | O_NONBLOCK);