Updated userial utility.
This commit is contained in:
@@ -1,24 +1,49 @@
|
|||||||
import serial
|
# Purpose: Use userial (www.tty1.net/userial) to communicate with an I2C device
|
||||||
ser = serial.Serial("/dev/ttyACM1") # COM5 or similar under Windows
|
# Released to the Public Domain by Opendous Inc. 2011-03-01
|
||||||
|
import serial # PySerial (http://pyserial.sourceforge.net/) for accessing the serial port on multiple platforms
|
||||||
|
import sys # command-line argument handling
|
||||||
|
|
||||||
cmd = 'IC64'
|
|
||||||
ser.write((cmd + "\n"))
|
|
||||||
print "Command " + cmd + " returned: " + ser.readline()
|
|
||||||
|
|
||||||
cmd = 'IS90W00S91R01P'
|
def userialI2CScan(comport):
|
||||||
ser.write((cmd + "\n"))
|
# open the given serial port for communication
|
||||||
print "Command " + cmd + " returned: " + ser.readline()
|
ser = serial.Serial(comport) # COM5 or similar under Windows
|
||||||
|
|
||||||
cmd = 'IS90W01S91R01P'
|
# 100kHz I2C = 64, 400kHz I2C = 190
|
||||||
ser.write((cmd + "\n"))
|
cmd = 'IC64'
|
||||||
print "Command " + cmd + " returned: " + ser.readline()
|
ser.write((cmd + "\n"))
|
||||||
|
print "Command " + cmd + " returned: " + ser.readline()
|
||||||
|
|
||||||
cmd = 'ISA0W00SA1R01P'
|
# userial command usage instructions can be found in userial_user_guide.pdf
|
||||||
ser.write((cmd + "\n"))
|
|
||||||
print "Command " + cmd + " returned: " + ser.readline()
|
|
||||||
|
|
||||||
cmd = 'ISA0W01SA1R01P'
|
cmd = 'IS90W00S91R01P'
|
||||||
ser.write((cmd + "\n"))
|
ser.write((cmd + "\n"))
|
||||||
print "Command " + cmd + " returned: " + ser.readline()
|
print "Command " + cmd + " returned: " + ser.readline()
|
||||||
|
|
||||||
|
cmd = 'IS90W01S91R01P'
|
||||||
|
ser.write((cmd + "\n"))
|
||||||
|
print "Command " + cmd + " returned: " + ser.readline()
|
||||||
|
|
||||||
|
cmd = 'ISA0W00SA1R01P'
|
||||||
|
ser.write((cmd + "\n"))
|
||||||
|
print "Command " + cmd + " returned: " + ser.readline()
|
||||||
|
|
||||||
|
cmd = 'ISA0W01SA1R01P'
|
||||||
|
ser.write((cmd + "\n"))
|
||||||
|
print "Command " + cmd + " returned: " + ser.readline()
|
||||||
|
|
||||||
|
|
||||||
|
ser.close()
|
||||||
|
|
||||||
|
# if this file is the program actually being run, print usage info or run SerialSendReceive
|
||||||
|
if __name__ == '__main__':
|
||||||
|
if (len(sys.argv) != 2):
|
||||||
|
print "Use userial (www.tty1.net/userial) to Communicate with an I2C Device"
|
||||||
|
print " Usage:"
|
||||||
|
print " python", sys.argv[0], "<port>"
|
||||||
|
print " Where <port> = serial port; COM? on Windows, '/dev/ttyACM0 on Linux'"
|
||||||
|
print " Enumerated serial port can be found in Linux using dmesg"
|
||||||
|
print " look for something like cdc_acm 2-1:1.0: ttyACM0: USB ACM device"
|
||||||
|
print " python", sys.argv[0], "COM5"
|
||||||
|
exit()
|
||||||
|
userialI2CScan(sys.argv[1])
|
||||||
|
|
||||||
ser.close()
|
|
||||||
|
|||||||
BIN
Micropendous/Firmware/userial/userial_user_guide.pdf
Normal file
BIN
Micropendous/Firmware/userial/userial_user_guide.pdf
Normal file
Binary file not shown.
Reference in New Issue
Block a user