| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152 |
- #!/usr/bin/python
- #
- # Copyright (c) 2019 Clementine Computing LLC.
- #
- # This file is part of PopuFare.
- #
- # PopuFare is free software: you can redistribute it and/or modify
- # it under the terms of the GNU Affero General Public License as published by
- # the Free Software Foundation, either version 3 of the License, or
- # (at your option) any later version.
- #
- # PopuFare is distributed in the hope that it will be useful,
- # but WITHOUT ANY WARRANTY; without even the implied warranty of
- # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- # GNU Affero General Public License for more details.
- #
- # You should have received a copy of the GNU Affero General Public License
- # along with PopuFare. If not, see <https://www.gnu.org/licenses/>.
- #
- import serial
- import sys
- import re
- import time
- import subprocess as sp
- from os import listdir
- from os.path import isfile, join
- from os import system
- DEBUG = True
- VERBOSE = True
- ret = system("rm -f /dev/ttyPIU /dev/ttyGPRS /dev/ttyDIU /dev/ttyGPS")
- DEVDIR = "/dev"
- for devfn in ["ttyUSB0", "ttyUSB1"]:
- s = sp.check_output("dmesg | grep " + devfn + " | tail -n1", shell=True)
- s = s.strip()
- print s
- if re.search(r'FTDI', s):
- print devfn, "-> /dev/ttyPIU (ftdi)"
- system("ln -s " + devfn + " /dev/ttyPIU")
- elif re.search(r'pl2303', s):
- print devfn, "-> /dev/ttyGPRS (pl2303)"
- system("ln -s " + devfn + " /dev/ttyGPRS")
- system("ln -s /dev/ttyACM0 /dev/ttyGPS")
|