本文整理汇总了Python中Adafruit_BBIO.UART.setup方法的典型用法代码示例。如果您正苦于以下问题:Python UART.setup方法的具体用法?Python UART.setup怎么用?Python UART.setup使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Adafruit_BBIO.UART
的用法示例。
在下文中一共展示了UART.setup方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: from Adafruit_BBIO import UART [as 别名]
# 或者: from Adafruit_BBIO.UART import setup [as 别名]
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
示例2: __init__
# 需要导入模块: from Adafruit_BBIO import UART [as 别名]
# 或者: from Adafruit_BBIO.UART import setup [as 别名]
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
示例3: imu
# 需要导入模块: from Adafruit_BBIO import UART [as 别名]
# 或者: from Adafruit_BBIO.UART import setup [as 别名]
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()
示例4: dumb_tty
# 需要导入模块: from Adafruit_BBIO import UART [as 别名]
# 或者: from Adafruit_BBIO.UART import setup [as 别名]
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()
示例5: __init__
# 需要导入模块: from Adafruit_BBIO import UART [as 别名]
# 或者: from Adafruit_BBIO.UART import setup [as 别名]
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()
示例6: setup_bbb_uart
# 需要导入模块: from Adafruit_BBIO import UART [as 别名]
# 或者: from Adafruit_BBIO.UART import setup [as 别名]
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
示例7: __main__
# 需要导入模块: from Adafruit_BBIO import UART [as 别名]
# 或者: from Adafruit_BBIO.UART import setup [as 别名]
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())
示例8: __main__
# 需要导入模块: from Adafruit_BBIO import UART [as 别名]
# 或者: from Adafruit_BBIO.UART import setup [as 别名]
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)
示例9: __init__
# 需要导入模块: from Adafruit_BBIO import UART [as 别名]
# 或者: from Adafruit_BBIO.UART import setup [as 别名]
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.")
示例10: __init__
# 需要导入模块: from Adafruit_BBIO import UART [as 别名]
# 或者: from Adafruit_BBIO.UART import setup [as 别名]
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")
示例11: initialize_UART
# 需要导入模块: from Adafruit_BBIO import UART [as 别名]
# 或者: from Adafruit_BBIO.UART import setup [as 别名]
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)
示例12: get_ph
# 需要导入模块: from Adafruit_BBIO import UART [as 别名]
# 或者: from Adafruit_BBIO.UART import setup [as 别名]
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
示例13: main
# 需要导入模块: from Adafruit_BBIO import UART [as 别名]
# 或者: from Adafruit_BBIO.UART import setup [as 别名]
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()
示例14: openUart
# 需要导入模块: from Adafruit_BBIO import UART [as 别名]
# 或者: from Adafruit_BBIO.UART import setup [as 别名]
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
示例15: __init__
# 需要导入模块: from Adafruit_BBIO import UART [as 别名]
# 或者: from Adafruit_BBIO.UART import setup [as 别名]
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)