필요한 것들:
1. python
2. python serial extension(pyserial) : http://sourceforge.net/projects/pyserial/
3. python win32 extension : http://starship.python.net/crew/mhammond/win32/
* 윈도환경에서 파이썬 프로그램 참고 서적: Python Programming On Win32(O'reilly)
[Open port 0 at "9600,8,N,1", no timeout]
>>> import serial
>>> ser = serial.Serial(0) # open first serial port
>>> print ser.portstr # check which port was really used
>>> ser.write("hello") # write a string
>>> ser.close() # close port
[Open named port at "19200,8,N,1", 1s timeout]
>>> ser = serial.Serial('com5', 19200, timeout=1)
>>> x = ser.read() # read one byte
>>> s = ser.read(10) # read up to ten bytes (timeout)
>>> line = ser.readline() # read a '\n' terminated line
>>> ser.close()
댓글 없음:
댓글 쓰기