From d477b5bc24309f90789159e4f0ca3cc8bab620dd Mon Sep 17 00:00:00 2001 From: Wouter Symons Date: Tue, 4 Feb 2020 15:17:21 +0100 Subject: [PATCH] cpu/native/can/candev_linux: add check for real can when setting bittimings in init --- cpu/native/can/candev_linux.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/cpu/native/can/candev_linux.c b/cpu/native/can/candev_linux.c index 1bbf888e58..874931cdb6 100644 --- a/cpu/native/can/candev_linux.c +++ b/cpu/native/can/candev_linux.c @@ -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"); @@ -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;