Skip to content

Commit

Permalink
cpu/native/can/candev_linux: add check for real can when setting bitt…
Browse files Browse the repository at this point in the history
…imings in init
  • Loading branch information
wosym committed Feb 21, 2020
1 parent 7692093 commit d477b5b
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion cpu/native/can/candev_linux.c
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,14 @@ static int _init(candev_t *candev)

real_bind(dev->sock, (struct sockaddr *)&addr, sizeof(addr));

_set_bittiming(dev, &candev->bittiming);
/* Only set bitrate on real can interfaces.
* Not supported on virtual can interfaces ("vcanX") */
if (strncmp(dev->conf->interface_name, "can", strlen("can"))) {
DEBUG("not setting bitrate on virtual can interface %s\n", dev->conf->interface_name);
}
else {
_set_bittiming(dev, &candev->bittiming);
}

DEBUG("CAN linux device ready\n");

Expand Down Expand Up @@ -300,6 +307,8 @@ static int _set(candev_t *candev, canopt_t opt, void *value, size_t value_len)
case CANOPT_BITTIMING:
DEBUG("candev_linux: CANOPT_BITTIMING\n");

/* Only set bitrate on real can interfaces.
* Not supported on virtual can interfaces ("vcanX") */
if (strncmp(dev->conf->interface_name, "can", strlen("can"))) {
DEBUG("candev_native: _set: error interface is not real can\n");
return -EINVAL;
Expand Down

0 comments on commit d477b5b

Please sign in to comment.