tashtalk/tashtalkd/tashtalkd

43 lines
1.5 KiB
Python

#!/usr/bin/env python3
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program 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 General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
import argparse
import logging
import sys
import serial
from daemon.protocol.ltoudp import LtoudpDaemon
def main(argv):
parser = argparse.ArgumentParser(description='Userspace daemon for TashTalk.')
parser.add_argument('--device', '-d', metavar='DEVICE', required=True, help='serial device where TashTalk is connected')
parser.add_argument('--verbose', '-v', action='count', default=0, help='increase verbosity of logging')
args = parser.parse_args(argv[1:])
logging.basicConfig(level=logging.DEBUG if args.verbose > 1 else logging.INFO if args.verbose else logging.WARNING,
format='[%(levelname)s] %(message)s')
serial_obj = serial.Serial(port=args.device, baudrate=1000000, timeout=0, rtscts=True)
daemon = LtoudpDaemon(serial_obj)
daemon.initialize()
daemon.run()
if __name__ == '__main__': sys.exit(main(sys.argv))