Skip to content

Commit

Permalink
Update WIZnet-S2E-Tool
Browse files Browse the repository at this point in the history
1. Support serial baudrate up to 460.8kbps
2. Update README
3. Bug fixes
  • Loading branch information
renakim committed Feb 27, 2018
1 parent 083dd44 commit 1d7783c
Show file tree
Hide file tree
Showing 5 changed files with 49 additions and 42 deletions.
8 changes: 6 additions & 2 deletions FWUploadThread.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,8 @@ def run(self):
self.serverport = int(params[1])

# network reachable check
ping_reponse = os.system("ping " + ("-n 2 " if sys.platform.lower()=="win32" else "-c 1 ") + self.serverip)
os.system("ping " + ("-n 1 " if sys.platform.lower()=="win32" else "-c 1 ") + self.serverip)
ping_reponse = os.system("ping " + ("-n 1 " if sys.platform.lower()=="win32" else "-c 1 ") + self.serverip)
# ping_reponse = os.system('ping -n 1 ' + params[0])
if ping_reponse == 0:
print('Device[%s] network OK' % self.dest_mac)
Expand Down Expand Up @@ -122,7 +123,7 @@ def run(self):
if self.client.state is SOCK_OPEN_STATE:
sys.stdout.write('[%r] is OPEN\r\n' % (self.serverip))
# sys.stdout.write('[%r] client.working_state is %r\r\n' % (self.serverip, self.client.working_state))
# time.sleep(1)
time.sleep(0.5)
except Exception as e:
sys.stdout.write('%r\r\n' % e)

Expand Down Expand Up @@ -227,6 +228,9 @@ def run(self):
response = ""
break
sys.stdout.write('Device [%s] firmware upload success!\r\n' % (self.dest_mac))
# for send FIN packet
time.sleep(2.5)
self.client.shutdown()
except (KeyboardInterrupt, SystemExit):
sys.stdout.write('%r\r\n' % e)
finally:
Expand Down
37 changes: 26 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,19 @@ WIZnet-S2E-Tool is module Configuration & Test Tool for WIZnet S2E devices. \
Python interpreter based and it is platform independent. \
It works on version 2.7 and 3.6 python.

## Tutorial
[WIZwiki](https://wizwiki.net/wiki/doku.php) provides a step-by-step tutorial on the WIZnet-S2E-Tool. \
You can see it on the following links. This content will continue to be updated.

- [1. Overview & Environment](http://wizwiki.net/wiki/doku.php?id=products:wiz750sr:clitool:overview:en)
- [2. How to use CLI Config Tool](https://wizwiki.net/wiki/doku.php?id=products:wiz750sr:clitool:option:en)
- [3. Single device configuration](http://wizwiki.net/wiki/doku.php?id=products:wiz750sr:clitool:single:en)
- [4. Multi devices configuration](http://wizwiki.net/wiki/doku.php?id=products:wiz750sr:clitool:multi:en)
- [5. Using File Options](https://wizwiki.net/wiki/doku.php?id=products:wiz750sr:clitool:fileoption:en)
- [6. Loopback Test]

----

# SUPPORT DEVICES
## 1 Port Serial to Ethernet Module
- [WIZ750SR](http://wizwiki.net/wiki/doku.php?id=products:wiz750sr:start)
Expand All @@ -29,7 +42,7 @@ It works on version 2.7 and 3.6 python.

# CONFIGURATION TOOL
- [CLI Configuration Tool](#cli-configuration-tool)
- GLI Configuration Tool (Not suppoted yet)
- GUI Configuration Tool (Not supported yet)
<!-- - [GUI Configuration Tool](#GUI-Configuration-Tool) -->


Expand Down Expand Up @@ -76,7 +89,7 @@ or
--gw GW Gateway address
--dns DNS DNS server address

#### Channel #0 Options:
#### Channel #1 Options:
--port0 PORT0 Local port number
--nmode0 {0,1,2,3} Network operation mode (0: tcpclient, 1: tcpserver, 2: mixed, 3: udp)
--rip0 IP Remote host IP address / Domain
Expand All @@ -99,7 +112,7 @@ or
--ri number TCP client reconnection interval value [TCP client only]
(0: Not use / 1~65535: TCP client reconnection interval (Unit: millisecond))

#### Channel #1 Options:
#### Channel #2 Options:
--port1 PORT1 Local port number
--nmode1 {0,1,2,3} Network operation mode (0: tcpclient, 1: tcpserver, 2: mixed, 3: udp)
--rip1 IP Remote host IP address / Domain
Expand Down Expand Up @@ -148,10 +161,10 @@ You can see detail description as following command.

- 1 Port S2E devices
- WIZ750SR Series
- Use [Channel #0 Options](#channel-#0-options:) only.
- Use [Channel #1 Options](#channel-1-options) only.
- 2 Port S2E devices
- WIZ752SR Series
- Use [Channel #0 Options](#channel-#0-options:) & [Channel #1 Options](#channel-#1-options) both.
- Use [Channel #1 Options](#channel-1-options) & [Channel #2 Options](#channel-2-options) both.

And **all other options are common** for 1 port & 2 port S2E devices.

Expand All @@ -161,11 +174,13 @@ And **all other options are common** for 1 port & 2 port S2E devices.
First, you could search devices use '-s' or '--search' option.

$ python wizconfig.py -s
And then **mac_list.txt** is created, there are MAC address information of each devices.
And then **mac_list.txt** is created, there are MAC address information of each device.

</br>

#### 2. Configuration
First, find the option(s) for you want to set from [Options](#options). And then config the device(s) use following command.

* Single Device

$ python wizconfig.py -d 00:08:DC:XX:XX:XX [Options ...]
Expand All @@ -191,7 +206,7 @@ And then **mac_list.txt** is created, there are MAC address information of each
#### 3. Firmware Upload

##### Step 1 - Set IP address
When do device's firmware upload, need TCP connection with devices to send Firmware file.
When do device's firmware upload, need TCP connection with device to send Firmware file.

So first, use **-m/--multiset** option for **set ip address to the same network-band as host**.

Expand Down Expand Up @@ -244,21 +259,21 @@ You can use example files named **cmd_oneport.txt** and **cmd_twoport.txt**.

* Single device

* One port devices
* for One port

$ python wizconfig.py -d 00:08:DC:XX:XX:XX --getfile cmd_oneport.txt

* Two port devices
* for Two port

$ python wizconfig.py -d 00:08:DC:XX:XX:XX --getfile cmd_twoport.txt

* ALL devices

* One port devices
* for One port

$ python wizconfig.py -a --getfile cmd_oneport.txt

* Two port devices
* for Two port

$ python wizconfig.py -a --getfile cmd_twoport.txt

Expand Down
10 changes: 6 additions & 4 deletions WIZArgParser.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ def config_arg(self):

group = parser.add_argument_group('Configuration')
group.add_argument('-s', '--search', action='store_true', help='Search devices (in same network)')

group.add_argument('-r', '--reset', action='store_true', help='Reboot device')
group.add_argument('-f', '--factory', action='store_true', help='Factory reset')
# multi ip set
Expand All @@ -63,8 +64,8 @@ def config_arg(self):
group.add_argument('--gw', help='Gateway address')
group.add_argument('--dns', help='DNS server address')

### Channel 0 options
group = parser.add_argument_group('Channel #0 Options')
### Channel 1 options
group = parser.add_argument_group('Channel #1 Options')
group.add_argument('--port0', help='Local port number')
group.add_argument('--nmode0', choices=['0', '1', '2', '3'],
help='Network operation mode (0: tcpclient, 1: tcpserver, 2: mixed, 3: udp)')
Expand Down Expand Up @@ -92,8 +93,8 @@ def config_arg(self):
help='''TCP client reconnection interval value [TCP client only]\n(0: Not use / 1~65535: TCP client reconnection interval (Unit: millisecond))''')
# group.add_argument('--ec', choices=['0','1'], help='UART Echoback function enable (Data UART port)')

## Channel 1 options
group = parser.add_argument_group('Channel #1 Options')
## Channel 2 options
group = parser.add_argument_group('Channel #2 Options')
group.add_argument('--port1', help='Local port number')
group.add_argument('--nmode1', choices=['0', '1', '2', '3'],
help='Network operation mode (0: tcpclient, 1: tcpserver, 2: mixed, 3: udp)')
Expand Down Expand Up @@ -138,4 +139,5 @@ def config_arg(self):
group.add_argument('--getfile', help='File name to Get info. Refer default command(cmd_oneport.txt or cmd_twoport.txt).')

args = parser.parse_args()

return args
16 changes: 3 additions & 13 deletions WIZMSGHandler.py
Original file line number Diff line number Diff line change
Expand Up @@ -266,20 +266,10 @@ def get_filelog(self, macaddr):
print('No reply from device. exit program.')
sys.exit(0)

cmdsetObj = WIZ752CMDSET(logging.ERROR)

mac_addr = macaddr.replace(":", "")
for i in range(0, len(self.getreply)):
if b'MN' in self.getreply[i]:
cmdsetObj = WIZ752CMDSET(logging.ERROR)
filename = 'getfile_%s.log' % (mac_addr)

# if 'MN' in self.getreply[i] and self.getreply[i][2:] in 'WIZ752SR-12x':
# cmdsetObj = WIZ752CMDSET(logging.ERROR)
# filename = 'get_detail_2port_%s.txt' % (mac_addr)
# # sys.stdout.write("* Product name: %s\r\n" % (self.getreply[i][2:]))
# elif 'MN' in self.getreply[i] and self.getreply[i][2:] in 'WIZ750SR':
# cmdsetObj = WIZ750CMDSET(logging.ERROR)
# filename = 'get_detail_1port_%s.txt' % (mac_addr)
# # sys.stdout.write("* Product name: %s\r\n" % (self.getreply[i][2:]))
filename = 'getfile_%s.log' % (mac_addr)

for i in range(0, len(self.getreply)):
f = open(filename, 'w')
Expand Down
20 changes: 8 additions & 12 deletions wizconfig.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,23 +30,20 @@

BAUDRATES = [300, 600, 1200, 1800, 2400, 4800, 9600, 14400, 19200, 28800, 38400, 57600, 115200, 230400]

cmd_oneport = ['MC','VR','MN','UN','ST','IM','OP','DD','CP','PO','DG','KA','KI','KE','RI','LI','SM','GW','DS','PI','PP','DX','DP','DI','DW','DH','LP','RP','RH','BR','DB','PR','SB','FL','IT','PT','PS','PD','TE','SS','NP','SP']
cmd_twoport = ['MC','VR','MN','UN','ST','IM','OP','DD','CP','PO','DG','KA','KI','KE','RI','LI','SM','GW','DS','PI','PP','DX','DP','DI','DW','DH','LP','RP','RH','BR','DB','PR','SB','FL','IT','PT','PS','PD','TE','SS','NP','SP','QS','QO','QH','QP','QL','RV','RA','RE','RR','EI','EN','RS','EB','ED','EP','ES','EF','E0','E1','NT','NS','ND']

class WIZMakeCMD:
def search(self):
cmd_list = []
# Search All Devices on the network
# 장치 검색 시 필요 정보 Get
cmd_list.append(["MA", "FF:FF:FF:FF:FF:FF"])
cmd_list.append(["PW", " "])
cmd_list.append(["MC", ""])
cmd_list.append(["LI", ""]) # IP address
cmd_list.append(["VR", ""])
cmd_list.append(["MN", ""])
cmd_list.append(["RH", ""])
cmd_list.append(["RP", ""])
cmd_list.append(["OP", ""]) # Network operation mode
cmd_list.append(["IM", ""]) # IP address allocation method(Static/DHCP)
for cmd in cmd_twoport:
cmd_list.append([cmd, ""])
return cmd_list

def get_value(self, mac_addr, filename):
# 파일의 command들에 대한 정보를 가져옴
cmd_list = []
Expand All @@ -73,6 +70,7 @@ def set_value(self, mac_addr, filename):
getcmd_list.append(line[:2])
for cmd in getcmd_list:
cmd_list.append([cmd, ""])

cmd_list.append(["SV", ""])
cmd_list.append(["RT", ""])
f.close()
Expand Down Expand Up @@ -375,7 +373,7 @@ def isvalid(self, mac_addr):
print('* Single devcie config: %s' % mac_addr)
cmd_list = wizmakecmd.setcommand(mac_addr, list(setcmd.keys()), list(setcmd.values()))
get_cmd_list = wizmakecmd.getcommand(mac_addr, list(setcmd.keys()))
# print(get_cmd_list)
# print('get_cmd_list', get_cmd_list)

if args.all or args.multiset:
if not args.fwfile:
Expand Down Expand Up @@ -409,6 +407,4 @@ def isvalid(self, mac_addr):
wizmsghangler.parseresponse()

wizmsghangler.get_log()



0 comments on commit 1d7783c

Please sign in to comment.