2014년 7월 10일 목요일

Python Simple Script for WIZ107SR

Source Github Link

WIZ107SR



WIZ107SR is a gateway module that converts serial protocol (RS-232) into TCP/IP protocol by using W7100A.

Link WIZ107SR materials - WIZ107SR

SW - Download & Install





Script descriptions - TCPClient




  • Init. serial port number and baudrate



[code lang=c]
serial.Serial("COM1", 57600)
[/code]


  • Change to serial commond mode



Change to serial command mode; when serial command switch code is '123'.
Just only input serial command mode switch code of 3bytes without '\r\n'.
Serial command mode switch code is set by using ConfigTool.

[code lang=c]
ser.write(b'123')
[/code]


  • Setting TCPClient mode



[code lang=c]
ser.write(b'LP5000rn') # Source port number : ex.) 5000
ser.write(b'RP3000rn') # TCP server port number : ex.) 3000
ser.write(b'RH192.168.10.100rn') # TCP server IP address : ex.) '192.168.10.100'
ser.write(b'OP0rn') # Set TCP Client mode : OP0 - TCPClinet
ser.write(b'SVrn') # Save Setting
ser.write(b'RTrn') # Reboot
[/code]


  • Send



[code lang=c]
ser.write(b'hellorn')
[/code]


  • recv



[code lang=c]
serial_recv_buf = 10
line = ser.read(serial_recv_buf)
[/code]

FAQ; How know the status of TCP connections ?



We can know the TCP connection by using 8pin.

In the initial time, this pin is INPUT for Hardware Trigger(for
serial command mode). After that, this pin is OUTPUT for
connection status. When the connection is established, this pin
goes Low. And, it will go HIGH when connection is closed.

댓글 없음:

댓글 쓰기