2017年6月22日 星期四

pi3 UART by python

#!/usr/bin/env python
import serial

ser = serial.Serial(
  port='/dev/ttyAMA0',
  baudrate = 9600,
  parity=serial.PARITY_NONE,
  stopbits=serial.STOPBITS_ONE,
  bytesize=serial.EIGHTBITS,
  timeout=1
)

print "Serial is open: " + str(ser.isOpen())

print "Now Writing"
ser.write("This is a test")

print "Did write, now read"
x = ser.readline()
print "got '" + x + "'"

ser.close()

port='/dev/ttyAMA0'
 console=/dev/ttyS0,115200 

沒有留言:

張貼留言