#!/usr/bin/env python3 # # SaveMySugar - transmit messages using Morse code via phone rings # # Copyright (C) 2015 Antonio Ospite # # 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 . import logging from savemysugar.CallDistanceTransceiver import CallDistanceTransceiver from savemysugar.Modem import Modem # TODO: set the logging level from the command line FORMAT = "%(created)f %(levelname)s:%(funcName)s %(message)s" logging.basicConfig(level=logging.DEBUG, format=FORMAT) def transmit(port, number, message): modem = Modem(port) transmitter = CallDistanceTransceiver(modem) transmitter.estimate_transmit_duration(message) transmitter.transmit(message, number) def main(): print("Available hardware serial ports:") for port in Modem.scan(): print(" - " + port) print() import sys if len(sys.argv) != 4: print("usage: %s" % sys.argv[0], " ") sys.exit(1) transmit(sys.argv[1], sys.argv[2], sys.argv[3]) if __name__ == "__main__": main()