You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

67 lines
2.1 KiB

---
title: handy tools for MMDVM
summary: >
Some nice ideas and so...
date: 2022-07-31T13:12:39+02:00
#categories: [computerstuff]
tags: [linux,systemd,networking,manjaro,dns]
draft: true
---
#### the script
~~~bash
# file: "kill-mmdvm.sh"
#!/bin/bash
#udev/rules.d contains a rule file like:
#SUBSYSTEM=="tty", ATTRS{idVendor}=="1fc9", ATTRS{idProduct}=="0094", SYMLINK+="ttyGD77", TAG+="systemd", ENV{SYSTEMD_WANTS}="mmdvmhost.service"
#ACTION=="remove", SUBSYSTEM=="tty", ENV{ID_VENDOR_ID}=="1fc9", ENV{ID_MODEL_ID}=="0094", RUN+="/etc/udev/kill-mmdvm.sh"
#
#mmdvmhost service stopping lasts about 1 minute to succeed, so kill is the option...
if [ "$ACTION" = "remove" ]
then
systemctl kill -s KILL mmdvmhost.service
fi
~~~
#### restarting/reloading udev rules without reboot
~~~console
# udevadm control --reload-rules && udevadm trigger
~~~
#### gd77 udev rules
~~~ini
# file: "/etc/udev/rules.d/99-gd77.rules"
# USB rules for GD-77
# Place this in /etc/udev/rules.d/ to let all users talk to the radios by USB.
#
SUBSYSTEM=="usb", ATTRS{idVendor}=="15a2", ATTRS{idProduct}=="0073", MODE="0666"
# HIDAPI/libusb
SUBSYSTEM=="usb", ATTRS{idVendor}=="15a2", ATTRS{idProduct}=="0073", MODE="0666"
SUBSYSTEM=="usb", ATTRS{idVendor}=="1fc9", ATTRS{idProduct}=="0094", MODE="0666"
# HIDAPI/hidraw
KERNEL=="hidraw*", ATTRS{idVendor}=="15a2", ATTRS{idProduct}=="0073", MODE="0666"
KERNEL=="hidraw*", ATTRS{idVendor}=="1fc9", ATTRS{idProduct}=="0094", MODE="0666"
# HIDAPI/hiddev
## We need to unbind this device, otherwise LibUsb will fail to SetConfiguration() and ClaimInterface()
# For Bootloader (usbhid)
KERNEL=="hiddev*", ATTRS{idVendor}=="15a2", ATTRS{idProduct}=="0073", MODE="0666", RUN+="/bin/bash -c 'ID=$(IFS=/; read -a array <<< %p; echo ${array[-3]}); echo $ID > /sys/bus/usb/drivers/usbhid/unbind'"
# OpenGD77
KERNEL=="ttyACM[0-9]*", SUBSYSTEM=="tty", ATTRS{idVendor}=="1fc9", ATTRS{idProduct}=="0094", MODE="0666", GROUP="dialout", SYMLINK+="OpenGD77"
~~~
***
Sources:
* <https://gist.github.com/gru-github/cf7c121e6b0e441676fb3263ebe02193>
* <https://unix.stackexchange.com/questions/39370/how-to-reload-udev-rules-without-reboot>