예제 #1
0
def parse_args():
    """
	Parses arguments for this program.
	
	Returns:
	An object with the following attributes:
	 serialport (str): what is after -s or --serial on the command line
	"""
    # try to automatically find the port
    port = textserial.get_port()
    if port == None:
        port = "0"

    parser = argparse.ArgumentParser(
        description="Serial port communication testing program.", epilog="If the port is 0, stdin/stdout are used.\n"
    )
    parser.add_argument(
        "-s", "--serial", help="path to serial port " '(default value: "%s")' % port, dest="serialport", default=port
    )

    return parser.parse_args()
예제 #2
0
def parse_args():
    """
    Parses arguments for this program.
    
    Returns:
    An object with the following attributes:
     serialport (str): what is after -s or --serial on the command line
    """
    # try to automatically find the port
    port = textserial.get_port()
    if port == None:
        port = "0"

    parser = argparse.ArgumentParser(
        description='Serial port communication testing program.',
        epilog='If the port is 0, stdin/stdout are used.\n')
    parser.add_argument('-s',
                        '--serial',
                        help='path to serial port '
                        '(default value: "%s")' % port,
                        dest='serialport',
                        default=port)

    return parser.parse_args()
예제 #3
0
	# Restart the communication attempt
	communication()


'''
	process route finding requests here
'''
if __name__ == "__main__":
	edmonton = read_city_graph("edmonton-roads-2.0.1.txt")
	#print("Done importing Edmonton map to a graph.")
	
	try:
		# if one has an echo program:
		baud = 9600
		port = textserial.get_port()
		if port == None:
			print("No suitable port found, exiting")
			#return
		#print("Attempting to use an 'echo' program on",port)

		with textserial.TextSerial(port,baud,newline='\n') as ser:
			while True:
				communication()

	except serial.SerialException as exc:
		print("Failure. \n",exc)
	except OSError as exc: # error on Linux
		if exc.errno!=2:
			raise
		print("Failure. \n",exc)