mirror of
https://github.com/apache/nuttx-apps.git
synced 2026-08-01 20:29:00 +00:00
canutils/slcan: explicitly manage the interface.
A recent change (https://github.com/apache/nuttx/pull/16199) has made the bitrate setting no longer bring the interface up. Moreover, it is now no longer possible to change bitrate of a CAN interface if it is up. Therefore, slcan needs to bring the interface down to change it. Fortunately, it already had commands to open and close the interface which map nicely to this. Signed-off-by: Carlos Sanchez <carlossanchez@geotab.com>
This commit is contained in:
parent
4fb47a6a6d
commit
f94bccf119
1 changed files with 32 additions and 6 deletions
|
|
@ -316,9 +316,22 @@ int main(int argc, char *argv[])
|
|||
{
|
||||
/* open CAN interface */
|
||||
|
||||
mode = 1;
|
||||
debug_print("Open interface\n");
|
||||
ok_return(fd);
|
||||
struct ifreq ifr;
|
||||
|
||||
strlcpy(ifr.ifr_name, argv[1], IFNAMSIZ);
|
||||
|
||||
ifr.ifr_flags = IFF_UP;
|
||||
if (ioctl(s, SIOCSIFFLAGS, &ifr) < 0)
|
||||
{
|
||||
syslog(LOG_ERR, "Open interface failed\n");
|
||||
fail_return(fd);
|
||||
}
|
||||
else
|
||||
{
|
||||
mode = 1;
|
||||
debug_print("Open interface\n");
|
||||
ok_return(fd);
|
||||
}
|
||||
}
|
||||
else if (buf[0] == 'S')
|
||||
{
|
||||
|
|
@ -392,9 +405,22 @@ int main(int argc, char *argv[])
|
|||
{
|
||||
/* close interface */
|
||||
|
||||
mode = 0;
|
||||
debug_print("Close interface\n");
|
||||
ok_return(fd);
|
||||
struct ifreq ifr;
|
||||
|
||||
strlcpy(ifr.ifr_name, argv[1], IFNAMSIZ);
|
||||
|
||||
ifr.ifr_flags = 0;
|
||||
if (ioctl(s, SIOCSIFFLAGS, &ifr) < 0)
|
||||
{
|
||||
syslog(LOG_ERR, "Close interface failed\n");
|
||||
fail_return(fd);
|
||||
}
|
||||
else
|
||||
{
|
||||
mode = 0;
|
||||
debug_print("Close interface\n");
|
||||
ok_return(fd);
|
||||
}
|
||||
}
|
||||
else if (buf[0] == 'T')
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue