Skip to content

Commit b205cab

Browse files
committed
修复M5设置wifi名称密码、320状态检测接口
1 parent 5011cc9 commit b205cab

File tree

7 files changed

+70
-42
lines changed

7 files changed

+70
-42
lines changed

pymycobot/common.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -796,6 +796,10 @@ def read(self, genre, method=None, command=None, _class=None, timeout=None):
796796
elif _class in ["MyCobot", "MyCobotSocket", "MyCobot320", "MyCobot320Socket"]:
797797
if genre == ProtocolCode.GET_ROBOT_STATUS:
798798
wait_time = 75
799+
elif genre == ProtocolCode.GET_ROBOT_STATUS:
800+
wait_time = 90
801+
elif genre == ProtocolCode.SET_SSID_PWD or genre == ProtocolCode.GET_SSID_PWD:
802+
wait_time = 0.05
799803
data = b""
800804

801805
if method is not None:

pymycobot/mecharm270.py

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -131,17 +131,21 @@ def _mesg(self, genre, *args, **kwargs):
131131
return self._res(real_command, has_reply, genre)
132132

133133
def _res(self, real_command, has_reply, genre):
134-
try_count = 0
135-
while try_count < 3:
134+
if genre == ProtocolCode.SET_SSID_PWD or genre == ProtocolCode.GET_SSID_PWD:
136135
self._write(self._flatten(real_command))
137136
data = self._read(genre)
138-
if data is not None and data != b'':
139-
break
140-
try_count += 1
141137
else:
142-
return -1
138+
try_count = 0
139+
while try_count < 3:
140+
self._write(self._flatten(real_command))
141+
data = self._read(genre)
142+
if data is not None and data != b'':
143+
break
144+
try_count += 1
145+
else:
146+
return -1
143147
if genre == ProtocolCode.SET_SSID_PWD:
144-
return None
148+
return 1
145149
res = self._process_received(data, genre)
146150
if res is not None and isinstance(res, list) and len(res) == 1 and genre not in [ProtocolCode.GET_BASIC_VERSION,
147151
ProtocolCode.GET_JOINT_MIN_ANGLE,

pymycobot/mecharmsocket.py

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -124,17 +124,21 @@ def _mesg(self, genre, *args, **kwargs):
124124
# [254,...,255]
125125
# data = self._write(self._flatten(real_command), "socket")
126126
with self.lock:
127-
try_count = 0
128-
while try_count < 3:
127+
if genre == ProtocolCode.SET_SSID_PWD or genre == ProtocolCode.GET_SSID_PWD:
129128
self._write(self._flatten(real_command), "socket")
130129
data = self._read(genre, method='socket')
131-
if data is not None and data != b'':
132-
break
133-
try_count += 1
134130
else:
135-
return -1
131+
try_count = 0
132+
while try_count < 3:
133+
self._write(self._flatten(real_command), "socket")
134+
data = self._read(genre, method='socket')
135+
if data is not None and data != b'':
136+
break
137+
try_count += 1
138+
else:
139+
return -1
136140
if genre == ProtocolCode.SET_SSID_PWD:
137-
return None
141+
return 1
138142
res = self._process_received(data, genre)
139143
if res == []:
140144
return None

pymycobot/mycobot280.py

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -135,17 +135,21 @@ def _mesg(self, genre, *args, **kwargs):
135135
return self._res(real_command, has_reply, genre)
136136

137137
def _res(self, real_command, has_reply, genre):
138-
try_count = 0
139-
while try_count < 3:
138+
if genre == ProtocolCode.SET_SSID_PWD or genre == ProtocolCode.GET_SSID_PWD:
140139
self._write(self._flatten(real_command))
141140
data = self._read(genre)
142-
if data is not None and data != b'':
143-
break
144-
try_count += 1
145141
else:
146-
return -1
142+
try_count = 0
143+
while try_count < 3:
144+
self._write(self._flatten(real_command))
145+
data = self._read(genre)
146+
if data is not None and data != b'':
147+
break
148+
try_count += 1
149+
else:
150+
return -1
147151
if genre == ProtocolCode.SET_SSID_PWD:
148-
return None
152+
return 1
149153
res = self._process_received(data, genre)
150154
if res is not None and isinstance(res, list) and len(res) == 1 and genre not in [ProtocolCode.GET_BASIC_VERSION,
151155
ProtocolCode.GET_JOINT_MIN_ANGLE,

pymycobot/mycobot280socket.py

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -128,17 +128,21 @@ def _mesg(self, genre, *args, **kwargs):
128128
# data = self._write(self._flatten(real_command), "socket")
129129
# # if has_reply:
130130
# data = self._read(genre, method='socket')
131-
try_count = 0
132-
while try_count < 3:
131+
if genre == ProtocolCode.SET_SSID_PWD or genre == ProtocolCode.GET_SSID_PWD:
133132
self._write(self._flatten(real_command), "socket")
134133
data = self._read(genre, method='socket')
135-
if data is not None and data != b'':
136-
break
137-
try_count += 1
138134
else:
139-
return -1
135+
try_count = 0
136+
while try_count < 3:
137+
self._write(self._flatten(real_command), "socket")
138+
data = self._read(genre, method='socket')
139+
if data is not None and data != b'':
140+
break
141+
try_count += 1
142+
else:
143+
return -1
140144
if genre == ProtocolCode.SET_SSID_PWD:
141-
return None
145+
return 1
142146
res = self._process_received(data, genre)
143147
if res == []:
144148
return None

pymycobot/mycobot320.py

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -147,17 +147,21 @@ def _mesg(self, genre, *args, **kwargs):
147147
return self._res(real_command, has_reply, genre)
148148

149149
def _res(self, real_command, has_reply, genre):
150-
try_count = 0
151-
while try_count < 3:
150+
if genre == ProtocolCode.SET_SSID_PWD or genre == ProtocolCode.GET_SSID_PWD:
152151
self._write(self._flatten(real_command))
153152
data = self._read(genre)
154-
if data is not None and data != b'':
155-
break
156-
try_count += 1
157153
else:
158-
return -1
154+
try_count = 0
155+
while try_count < 3:
156+
self._write(self._flatten(real_command))
157+
data = self._read(genre)
158+
if data is not None and data != b'':
159+
break
160+
try_count += 1
161+
else:
162+
return -1
159163
if genre == ProtocolCode.SET_SSID_PWD:
160-
return None
164+
return 1
161165
res = self._process_received(data, genre)
162166
if res is not None and isinstance(res, list) and len(res) == 1 and genre not in [ProtocolCode.GET_BASIC_VERSION,
163167
ProtocolCode.GET_JOINT_MIN_ANGLE,

pymycobot/mycobot320socket.py

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -138,17 +138,21 @@ def _mesg(self, genre, *args, **kwargs):
138138
# data = self._write(self._flatten(real_command), "socket")
139139
# # if has_reply:
140140
# data = self._read(genre, method='socket')
141-
try_count = 0
142-
while try_count < 3:
141+
if genre == ProtocolCode.SET_SSID_PWD or genre == ProtocolCode.GET_SSID_PWD:
143142
self._write(self._flatten(real_command), "socket")
144143
data = self._read(genre, method='socket')
145-
if data is not None and data != b'':
146-
break
147-
try_count += 1
148144
else:
149-
return -1
145+
try_count = 0
146+
while try_count < 3:
147+
self._write(self._flatten(real_command), "socket")
148+
data = self._read(genre, method='socket')
149+
if data is not None and data != b'':
150+
break
151+
try_count += 1
152+
else:
153+
return -1
150154
if genre == ProtocolCode.SET_SSID_PWD:
151-
return None
155+
return 1
152156
res = self._process_received(data, genre)
153157
if res == []:
154158
return None

0 commit comments

Comments
 (0)