1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2025-01-18 12:52:44 +01:00

Merge pull request #13342 from wosym/pr/socketcanfix

cpu/native/can/candev_linux: add check for real can
This commit is contained in:
Kaspar Schleiser 2020-02-24 09:39:12 +01:00 committed by GitHub
commit 58450c6c59
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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;