当前位置: 首页>>代码示例>>Python>>正文


Python Adafruit_BBIO.UART类代码示例

本文整理汇总了Python中Adafruit_BBIO.UART的典型用法代码示例。如果您正苦于以下问题:Python UART类的具体用法?Python UART怎么用?Python UART使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了UART类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: __init__

    def __init__(self, Beagle_UART="UART1", port="/dev/ttyO1", address=128):
        """
            Beagle_UART - UART0, UART1 or UART2 on BeagleBone Black to use
            port        - /dev/ttyXX device to connect to
            address     - address of Sabertooth controller to send commands to
            
        """
        self.UART = Beagle_UART
        self.port = port
        self.address = address

        if (self.UART == None) or (self.port == None) or (self.address < 128 or self.address > 135):
            raise ("Invalid parameters")
            return None

        # Setup UART on BeagleBone (loads device tree overlay)
        UART.setup(self.UART)
        
        # Initialiase serial port
        self.saber = serial.Serial()
        self.saber.baudrate = 9600
        self.saber.port = '/dev/%s' % (self.port)
        self.saber.open()
        self.isOpen = self.saber.isOpen()
        return None
开发者ID:ayoubserti,项目名称:BBB-Bot,代码行数:25,代码来源:Sabertooth.py

示例2: __init__

	def __init__(self, UART_number):

		# initiate sensor with a UART value
		UART.setup("UART" + str(UART_number))

		# UART number corresponds to terminal number (convenient)
		self.tty = UART_number
开发者ID:atecce,项目名称:MarsOASIS,代码行数:7,代码来源:UART.py

示例3: imu

def imu():
    pub = rospy.Publisher("lisa/sensors/imu", Imu, queue_size=10)
    times_per_second = 5
    bytes_to_read = 130  #This is slightly over twice the length of a single line of data.  A single line is ~58 characters.

    rospy.loginfo("Initializing IMU")
    rospy.init_node("imu")
    rate = rospy.Rate(times_per_second) # 10hz
    UART.setup("UART1")
    ser = serial.Serial(port = "/dev/ttyO1", baudrate=115200)
    ser.close()
    ser.open()
    if ser.isOpen():
    	print "Serial is open!"

    while not rospy.is_shutdown():
        ser.flushInput() #The imu blasts us with data and fills up the serial input buffer.  We clear it out here to wait for new values
        stream = ser.read(bytes_to_read)
        full_orientation = stream.split('\n')[-2] #Since we're getting a stream of data, we don't know whether we're starting at the beginning of the line or the middle. This throws out the last partial line and gets the previous full line
        yaw_deg = float(re.split('\s*', full_orientation)[-2])
        rospy.loginfo("yaw=%0.3f", yaw_deg)
        # correct backwards yaw
        #yaw = yaw_deg * math.pi / 180.0
        yaw = -1.0 * yaw_deg * math.pi / 180.0
        q = tf.transformations.quaternion_from_euler(0, 0, yaw)
        o = Imu()
        o.orientation.x = q[0]
        o.orientation.y = q[1]
        o.orientation.z = q[2]
        o.orientation.w = q[3]
        publish_orientation(pub, o)
        rate.sleep()

    ser.close()
开发者ID:weird-science-avc,项目名称:lisa,代码行数:34,代码来源:imu.py

示例4: dumb_tty

def dumb_tty(port):
	"""
	Simple dumb TTY that allows you to execute commands in Command
	Mode. Bit buggy when reading output. Good demo of CommandMode.

	Dependency on Adafruit_BBIO, but may be removed if your UART is
	already prepared.

	Parameters
	----------
	port : string
		the dir to the TTY or COM port

	"""
	UART.setup("UART1")
	hlsd = pyhypnolsd.command_mode.from_port(port)

	get_command = True
	while (get_command):
		# Get input
		command = raw_input("> ")

		# Check for exit
		if (command == "exit"):
			get_command = False
			continue

		# Send command, let it print output
		hlsd.send_command(command, True)

	# Close remaining connections
	hlsd.close()
开发者ID:rclough,项目名称:pyHypnoLSD,代码行数:32,代码来源:dumb_tty.py

示例5: __init__

    def __init__(self):
        self.UDP_IPReceive = ""
        self.UDP_IPSend = "192.168.1.19"
        self.UDP_PORT_RECV = 5005
        self.UDP_PORT_SEND = 5006

        self.receiveSock = socket.socket(socket.AF_INET,  # Internet
                         socket.SOCK_DGRAM)  # UDP
        self.receiveSock.bind((self.UDP_IPReceive, self.UDP_PORT_RECV))

        self.sendSock = socket.socket(socket.AF_INET,  # Internet
                             socket.SOCK_DGRAM)  # UDP

        uart.setup("UART2")  # Sensor Board
        self.telemetry = serial.Serial(port="/dev/ttyO2", baudrate=115200)
        self.telemetry.close()
        self.telemetry.open()

        uart.setup("UART1")  # Motor Driver Board
        self.thrusters = serial.Serial(port="/dev/ttyO1", baudrate=115200)
        self.thrusters.close()
        self.thrusters.open()

        self.vert = 0
        self.port = 0
        self.stbd = 0
        self.port1 = 0
        self.stbd1 = 0
        self.port2 = 0
        self.stbd2 = 0

        self.receiver()
        self.telemetryStatus()
开发者ID:hephaestus9,项目名称:ROV,代码行数:33,代码来源:ROV_Main.py

示例6: setup_bbb_uart

 def setup_bbb_uart(self):
     # Is this necessary if I don't want to use it myself??
     UART.setup(self.uart)
     self.ser = serial.Serial(port=self.tty, baudrate=9600)
     self.ser.close()
     self.ser.open()
     if self.ser.isOpen():
         return True
     else:
         return False
开发者ID:FishPi,项目名称:FishPi-POCV---Command---Control,代码行数:10,代码来源:gpsd_interface.py

示例7: __main__

def __main__():
	UART.setup("UART1")
	UART.setup("UART2")
	GPS1 = serial.Serial('/dev/ttyO1', 4800)
	GPS2 = serial.Serial('/dev/ttyO2', 4800)
	while(1):
		if GPS1.inWaiting() ==0:
			parse(GPS1.readline())	 
		if GPS2.inWaiting() ==0:
			parse(GPS2.readline())
开发者ID:dsmetzger,项目名称:autonomous_car_project,代码行数:10,代码来源:get_nmea.py

示例8: __main__

def __main__():
	UART.setup("UART1")
	UART.setup("UART4")
	GPS1 = serial.Serial('/dev/ttyO1', 4800)
	GPS4 = serial.Serial('/dev/ttyO4', 4800)
	while(1):
		if GPS1.inWaiting() ==1:
			parse(GPS1.readline(),1)	 
		if GPS4.inWaiting() ==1:
			parse(GPS4.readline(),4)
开发者ID:dsmetzger,项目名称:autonomous_car_project,代码行数:10,代码来源:get_nmea.py

示例9: __init__

    def __init__(self):
        self.mScreenBuffer = ScreenBuffer()

        UART.setup(Sender.mUart)

        self.mSerial = serial.Serial(port = mUartDev, buadrate = mBaudRate)
        self.mSerial.close()
        self.mSerial.open()
        if self.mSerial.isOpen():
            self.mSerial.write("Beaglebone serial is open.")
开发者ID:Pitt-CSC,项目名称:LED-Matrix,代码行数:10,代码来源:Sender.py

示例10: __init__

	def __init__(self, port=1):
		threading.Thread.__init__(self)

		UART.setup(("UART%i" % port))

		self.serial = serial.Serial(port=("/dev/ttyO%i" % port), baudrate=115200, timeout=0.1)
		self.serial.close()
		self.serial.open()

		self.serial.write("Started\r\n")
开发者ID:alyyousuf7,项目名称:RollE,代码行数:10,代码来源:Bluetooth.py

示例11: initialize_UART

 def initialize_UART(self, uart_port_str, ser_port_str):
     print("Initializing motor controller UART")
     try:
         uart.setup(uart_port_str)
         self.ser = serial.Serial(port=ser_port_str, baudrate=9600, timeout=1)
         self.ser.close()
         self.ser.open()
         print("Successfully initialized UART")
     except Exception as e:
         print("error in opening uart.")
         print(e)
开发者ID:mjdesrosiers,项目名称:SurveyBot,代码行数:11,代码来源:Motor_Controller.py

示例12: get_ph

def get_ph():
    print 'we are in get_ph'
    uart.setup('UART2')
    ser = serial.Serial(port = '/dev/ttyO2', baudrate=38400)
    print 'opened serial port'
    ser.open()
    ser.write('R\r')
    data = ser.read()
    print 'ph received raw as %s' % data
    ser.close()
    uart.cleanup()
    return data
开发者ID:AKAMEDIASYSTEM,项目名称:bbb-garden,代码行数:12,代码来源:poller.py

示例13: main

def main():

    """Entry point to nabaztag_client application.

    Initialises the Serial port, starts all application threads, and initiates the websocket connection
    """

    # Serial setup
    UART.setup("UART1")
    serial = pyserial.Serial(port=SERIAL, baudrate=RATE)

    serial_queue = Queue.Queue()
    update_queue = Queue.Queue()

    serial_write_thread = SerialWriter(
        serial,
        serial_queue,
        name="serialwrite"
    )

    serial_read_thread = SerialReader(
        serial,
        update_queue,
        name="serialread"
    )

    update_thread = UpdateThread(
        POST_URL.format(
            host=HOST,
            port=PORT,
            identifier=getid(INTERFACE)
        ),
        update_queue,
        name="postupdate"
    )

    serial_write_thread.start()
    serial_read_thread.start()
    update_thread.start()

    websocket_thread = WSClient(
        WS_URL.format(
            host=HOST,
            port=PORT,
            identifier=getid(INTERFACE)
        ),
        serial_queue,
        update_queue,
        name="websocket"
    )

    websocket_thread.connect()
    websocket_thread.run_forever()
开发者ID:Zileus,项目名称:resurrecting-the-rabbit,代码行数:53,代码来源:nabaztag_client.py

示例14: openUart

def openUart():
        """
        Opens UART1 (TX = 24, RX = 26). Returns true if successful.
        """

        UART.setup("UART1")
        ser = serial.Serial(port = "/dev/ttyO1", baudrate=9600, timeout=_TIMEOUT)

        # Reset port
        ser.close()
        ser.open()

        return ser
开发者ID:benmhess,项目名称:SmartPlanter,代码行数:13,代码来源:code.py

示例15: __init__

    def __init__(self):
        #VRCSR protocol defines  
        self.SYNC_REQUEST  =  0x5FF5
        self.SYNC_RESPONSE =  0x0FF0
        self.PROTOCOL_VRCSR_HEADER_SIZE = 6
        self.PROTOCOL_VRCSR_XSUM_SIZE   = 4
        
        #CSR Address for sending an application specific custom command
        self.ADDR_CUSTOM_COMMAND  = 0xF0

        #The command to send.
        #The Propulsion command has a payload format of:
        # 0xAA R_ID THRUST_0 THRUST_1 THRUST_2 ... THRUST_N 
        # Where:
        #   0xAA is the command byte
        #   R_ID is the NODE ID of the thruster to respond with data
        #   THRUST_X is the thruster power value (-1 to 1) for the thruster with motor id X
        self.PROPULSION_COMMAND   = 0xAA

        #flag for the standard thruster response which contains 
        self.RESPONSE_THRUSTER_STANDARD = 0x2
        #standard response is the device type followed by 4 32-bit floats and 1 byte
        self.RESPONSE_THRUSTER_STANDARD_LENGTH = 1 + 4 * 4 + 1 

        #The propulsion command packets are typically sent as a multicast to a group ID defined for thrusters
        self.THRUSTER_GROUP_ID    = 0x81
        
        #default to 0 thrust for motor 
        self.thrust = [0,0]
        
        #default to 0 motor node for responses
        self.motor_response_node = 0
       
        #deault for send_motor_command
        self.send_motor_command = False
  
        #open the serial port
        UART.setup("UART4")
        try:        
            self.port = serial.Serial(port = "/dev/ttyO4",baudrate=115200)
            self.port.timeout = 1
        except IOError:
            print ("Error:  Could not open serial port: " + args.portname)     
            sys.exit()
        
        #setup GPIO
        rec_output_enable_pin="P9_12"
        GPIO.setup(rec_output_enable_pin, GPIO.OUT)
        #set receiver output enable to enable
        GPIO.output(rec_output_enable_pin, GPIO.LOW)
开发者ID:TempleWaterfOWLS,项目名称:beagleboneblack,代码行数:50,代码来源:motor_comm.py


注:本文中的Adafruit_BBIO.UART类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。