Creation of special Kernel event handling (USB auto connection for serial communication)

From Lofaro Lab Wiki
Revision as of 00:09, 23 April 2015 by Jfogle (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

Creation of special Kernel event handling (USB auto connection for serial communication) This will enable a user to connect a USB to serial device to their computer and auto generate the serial connection.

~$sudo adduser [USERNAME] dialout ~$sudo touch /etc/udev/rules.d/95-serialdaemon.rules ~$sudo chmod +x /etc/udev/rules.d/95-serialdaemon.rules ~$sudo gedit /etc/udev/rules.d/95-serialdaemon.rules

Insert:

KERNEL=="ttyUSB0", ENV{SYSTEMD_WANTS}="serialdaemon.service"

Save and close file

~$sudo touch /lib/systemd/system/serialdaemon.service ~$sudo chmod +x /lib/systemd/system/serialdaemon.service ~$sudo gedit /lib/systemd/system/serialdaemon.service

Insert:

[Unit] Description=USB serial to socket bridge After=remote-fs.target After=syslog.target [Service] ExecStart=/mnt/serialdaemon.sh

Save and close file

~$sudo touch /mnt/serialdaemon.sh ~$sudo chmod +x /mnt/serialdaemon.sh ~$sudo gedit /mnt/serialdaemon.sh

Insert:

  1. !/bin/sh

date +%F-%T >> /var/log/serialdaemon.log /usr/local/serialdaemon/serialdaemon -serial /dev/ttyUSB0 -port 15789 -baud 9600 >> /var/log/serialdaemon.log 2>&1 date +%F-%T >> /var/log/serialdaemon.log

Save and close file

Restart Computer Upon restart plug in serial device and verify ~$stty < /dev/ttyUSB0