mirror of
https://github.com/gentoo-mirror/guru.git
synced 2026-07-21 21:13:27 -04:00
net-misc/can-utils: New package 2020.12.0
Package-Manager: Portage-3.0.13, Repoman-3.0.2 Signed-off-by: Hans Fredrik Nordhaug <hansfn@gmail.com>
This commit is contained in:
19
net-misc/can-utils/files/slcan.service
Normal file
19
net-misc/can-utils/files/slcan.service
Normal file
@@ -0,0 +1,19 @@
|
||||
[Unit]
|
||||
Description=Userspace daemon for serial line CAN interface driver SLCAN
|
||||
|
||||
[Service]
|
||||
Environment=can_speed=S5
|
||||
Environment=tty_baud=460800
|
||||
Environment=tty_device=ttyUSB0
|
||||
Environment=can_device=can0
|
||||
|
||||
|
||||
ExecStartPre=/sbin/modprobe slcan
|
||||
ExecStartPre=/bin/stty -F /dev/${tty_device} ${tty_baud} line 0 cs8 -onlcr -echo raw min 100 time 2
|
||||
ExecStartPre=/bin/sh -c 'echo -e -n "C\rF\r${can_speed}\rO\r" > /dev/${tty_device}'
|
||||
|
||||
ExecStart=/usr/bin/slcand -F ${tty_device} ${can_device}
|
||||
ExecStartPost=/bin/sleep 1
|
||||
ExecStartPost=/bin/ip link set can0 txqueuelen 1000 up
|
||||
|
||||
ExecStopPost=/sbin/modprobe -r slcan
|
||||
18
net-misc/can-utils/files/slcan.service.conf
Normal file
18
net-misc/can-utils/files/slcan.service.conf
Normal file
@@ -0,0 +1,18 @@
|
||||
# This file contains the configuration for the slcan daemon
|
||||
|
||||
|
||||
|
||||
# The `stty' command includes support for speeds of 57600, 115200,
|
||||
# 230400, 460800, 500000, 576000, 921600, 1000000, 1152000, 1500000,
|
||||
# 2000000, 2500000, 3000000, 3500000, or 4000000
|
||||
|
||||
# 921600 baud for S6
|
||||
# 460800 baud for S5
|
||||
|
||||
# Case sensitive speed setting
|
||||
|
||||
[Service]
|
||||
Environment=can_speed=S5
|
||||
Environment=tty_baud=460800
|
||||
Environment=tty_device=ttyUSB0
|
||||
Environment=can_device=can0
|
||||
18
net-misc/can-utils/files/slcand.confd
Normal file
18
net-misc/can-utils/files/slcand.confd
Normal file
@@ -0,0 +1,18 @@
|
||||
# /etc/conf.d/slcand
|
||||
# This file contains the configuration for the slcan daemon
|
||||
|
||||
|
||||
|
||||
# The `stty' command includes support for speeds of 57600, 115200,
|
||||
# 230400, 460800, 500000, 576000, 921600, 1000000, 1152000, 1500000,
|
||||
# 2000000, 2500000, 3000000, 3500000, or 4000000
|
||||
|
||||
# 921600 baud for S6
|
||||
# 460800 baud for S5
|
||||
|
||||
# Case sensitive speed setting
|
||||
|
||||
can_speed="S5"
|
||||
tty_baud="460800"
|
||||
tty_device="ttyUSB0"
|
||||
can_device="can0"
|
||||
39
net-misc/can-utils/files/slcand.initd
Normal file
39
net-misc/can-utils/files/slcand.initd
Normal file
@@ -0,0 +1,39 @@
|
||||
#!/sbin/runscript
|
||||
# Copyright 2013 Brunvoll AS
|
||||
|
||||
|
||||
start() {
|
||||
|
||||
if [ -z "${can_speed}" -o -z "${tty_baud}" -o -z "${tty_device}" -o -z "${can_device}" ]; then
|
||||
eerror "CAN speed, CAN device, tty_baud or tty_device not set"
|
||||
return 1
|
||||
fi
|
||||
|
||||
if ! grep -q slcan /proc/modules; then
|
||||
einfo "Loading module slcan"
|
||||
modprobe slcan || return 1
|
||||
fi
|
||||
|
||||
ebegin "Creating can0 at speed ${can_speed} on device ${tty_device}"
|
||||
einfo "Setting baudrate of ${tty_device} to ${tty_baud}"
|
||||
stty -F /dev/${tty_device} ${tty_baud} line 0 cs8 -onlcr -echo raw min 100 time 2
|
||||
sleep 1
|
||||
einfo "Set bitrate of slcan on ${tty_device} to ${can_speed}: "
|
||||
echo -e -n "C\rF\r${can_speed}\rO\r" > /dev/${tty_device}
|
||||
sleep 1
|
||||
einfo "Starting slcand"
|
||||
start-stop-daemon --start --background --make-pidfile \
|
||||
--pidfile /var/run/slcand.pid \
|
||||
--exec /usr/bin/slcand -- ${tty_device} ${can_device}
|
||||
sleep 1
|
||||
ifconfig ${can_device} up
|
||||
eend $?
|
||||
}
|
||||
|
||||
stop() {
|
||||
ebegin "Stopping slcand"
|
||||
start-stop-daemon --stop --quiet --pidfile /var/run/slcand.pid
|
||||
sleep 1
|
||||
rmmod slcan
|
||||
eend $?
|
||||
}
|
||||
Reference in New Issue
Block a user