src.dualinventive.com/dinet/libdi-php/tests/can_open.php

25 lines
449 B
PHP

<?php
/* Search for vcan0 and do a open/close call */
$found = false;
$ifaces = di_can_list();
foreach ($ifaces as &$iface) {
if ($iface == "vcan0") {
$found = true;
break;
}
}
if ($found) {
$fd = di_can_open("vcan0");
di_can_close($fd);
return;
}
printf("ERROR vcan0 doesn't exist, execute:\n");
printf("$ sudo modprobe vcan\n");
printf("$ sudo ip link add dev vcan0 type vcan\n");
printf("$ sudo ip link set up vcan0\n");
exit(1);