글
python socket server test
simple example from socket import * tcpSock = socket(AF_INET, SOCK_STREAM) tcpSock.bind(('',7000)) tcpSock.listen(5) while True: con, addr = tcpSock.accept() print "connected..." , addr data = con.recv(1024) print ' '.join("{02x}".format(ord(c)) for c in data) data[0] = '\x06' con.send(data) con.close() tcpSock.close() more complex
python serial 통신
* http://stackoverflow.com/questions/4040151/python-serial-port * http://pinkwink.kr/566 pyserial 설치 easy_install pyserial 혹은 pip install pyserial serial 통신 import serial ser = serial.Serial('com13', 9600, timeout = 5) # ser = = serial.Serial(13,9600) ser.read(100) d2 = ('\x02' , '\x30', '\x31', '\x35', '\x31', '\x36', '\x36' , '\x32', '\x36' , '\x03', '\x00') ser.write(''.join(d2)) ser.close()