if you are using pyserial module to read the communication from your device on UART , you will have to know which port the is your system connected to.
the following is a simple code to scan through all the COM ports and find out which com port is in opened. at the end of the program , you will see the serial uart that is in use being printed
import pyserial
for i in range(256):
try:
s = serial.Serial(i)
available.append( (i, s.portstr))
port = i
s.close()
except serial.SerialException:
pass
ser = serial.Serial(port, 115200,timeout=1)
print ser.portstr
happy scripting!
Showing posts with label pyserial data. Show all posts
Showing posts with label pyserial data. Show all posts
Wednesday, December 28, 2011
Wednesday, November 2, 2011
pyserial
pyserial module is really useful . i have been using it for perfroming uart related communication.
there a lot of sites which provides this pyserial downloads.
import serial
ser = serial.Serial(0) # open serial port
print ser.portstr # prints the used port
ser.write("hello") # write a string
ser.close()
you can use the above code as a test program for performing a pyserial communication from windows.
there a lot of sites which provides this pyserial downloads.
import serial
ser = serial.Serial(0) # open serial port
print ser.portstr # prints the used port
ser.write("hello") # write a string
ser.close()
you can use the above code as a test program for performing a pyserial communication from windows.
Subscribe to:
Posts (Atom)