Skip to content

Commit 3c517fe

Browse files
committed
fix 280、270、260 asynchronous parameter problem
1 parent 57d38b6 commit 3c517fe

File tree

6 files changed

+58
-26
lines changed

6 files changed

+58
-26
lines changed

pymycobot/mecharm270.py

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -124,13 +124,20 @@ def _mesg(self, genre, *args, **kwargs):
124124
"""
125125
real_command, has_reply, _async = super(
126126
MechArm270, self)._mesg(genre, *args, **kwargs)
127-
if self.thread_lock:
128-
with self.lock:
129-
result = self._res(real_command, has_reply, genre)
127+
if _async:
128+
if self.thread_lock:
129+
with self.lock:
130+
self._write(self._flatten(real_command))
131+
else:
132+
self._write(self._flatten(real_command))
133+
return None
130134
else:
131-
result = self._res(real_command, has_reply, genre)
132-
133-
return None if _async else result
135+
if self.thread_lock:
136+
with self.lock:
137+
result = self._res(real_command, has_reply, genre)
138+
else:
139+
result = self._res(real_command, has_reply, genre)
140+
return result
134141

135142
def _res(self, real_command, has_reply, genre):
136143
if genre == ProtocolCode.SET_SSID_PWD or genre == ProtocolCode.GET_SSID_PWD:

pymycobot/mecharmsocket.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -123,9 +123,14 @@ def _mesg(self, genre, *args, **kwargs):
123123
real_command, has_reply, _async = super(
124124
MechArmSocket, self)._mesg(genre, *args, **kwargs)
125125
# [254,...,255]
126-
with self.lock:
127-
result = self._res(real_command, has_reply, genre)
128-
return None if _async else result
126+
if _async:
127+
with self.lock:
128+
self._write(self._flatten(real_command), "socket")
129+
return None
130+
else:
131+
with self.lock:
132+
result = self._res(real_command, has_reply, genre)
133+
return result
129134

130135
def _res(self, real_command, has_reply, genre):
131136
if genre == ProtocolCode.SET_SSID_PWD or genre == ProtocolCode.GET_SSID_PWD:

pymycobot/mycobot280.py

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -129,13 +129,20 @@ def _mesg(self, genre, *args, **kwargs):
129129
"""
130130
real_command, has_reply, _async = super(
131131
MyCobot280, self)._mesg(genre, *args, **kwargs)
132-
if self.thread_lock:
133-
with self.lock:
134-
result = self._res(real_command, has_reply, genre)
132+
if _async:
133+
if self.thread_lock:
134+
with self.lock:
135+
self._write(self._flatten(real_command))
136+
else:
137+
self._write(self._flatten(real_command))
138+
return None
135139
else:
136-
result = self._res(real_command, has_reply, genre)
137-
138-
return None if _async else result
140+
if self.thread_lock:
141+
with self.lock:
142+
result = self._res(real_command, has_reply, genre)
143+
else:
144+
result = self._res(real_command, has_reply, genre)
145+
return result
139146

140147
def _res(self, real_command, has_reply, genre):
141148
if genre == ProtocolCode.SET_SSID_PWD or genre == ProtocolCode.GET_SSID_PWD:

pymycobot/mycobot280socket.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -125,9 +125,14 @@ def _mesg(self, genre, *args, **kwargs):
125125
real_command, has_reply, _async = super(
126126
MyCobot280Socket, self)._mesg(genre, *args, **kwargs)
127127
# [254,...,255]
128-
with self.lock:
129-
result = self._res(real_command, has_reply, genre)
130-
return None if _async else result
128+
if _async:
129+
with self.lock:
130+
self._write(self._flatten(real_command), "socket")
131+
return None
132+
else:
133+
with self.lock:
134+
result = self._res(real_command, has_reply, genre)
135+
return result
131136

132137
def _res(self, real_command, has_reply, genre):
133138
if genre == ProtocolCode.SET_SSID_PWD or genre == ProtocolCode.GET_SSID_PWD:

pymycobot/mypalletizer260.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -120,10 +120,14 @@ def _mesg(self, genre, *args, **kwargs):
120120
real_command, has_reply, _async = super(MyPalletizer260, self)._mesg(
121121
genre, *args, **kwargs
122122
)
123-
with self.lock:
124-
result = self._res(real_command, has_reply, genre)
125-
126-
return None if _async else result
123+
if _async:
124+
with self.lock:
125+
self._write(self._flatten(real_command))
126+
return None
127+
else:
128+
with self.lock:
129+
result = self._res(real_command, has_reply, genre)
130+
return result
127131

128132
def _res(self, real_command, has_reply, genre):
129133
self._write(self._flatten(real_command))

pymycobot/mypalletizersocket.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -86,10 +86,14 @@ def _mesg(self, genre, *args, **kwargs):
8686
real_command, has_reply, _async = super(
8787
MyPalletizerSocket, self)._mesg(genre, *args, **kwargs)
8888
# [254,...,255]
89-
with self.lock:
90-
result = self._res(real_command, has_reply, genre)
91-
92-
return None if _async else result
89+
if _async:
90+
with self.lock:
91+
self._write(self._flatten(real_command), "socket")
92+
return None
93+
else:
94+
with self.lock:
95+
result = self._res(real_command, has_reply, genre)
96+
return result
9397

9498
def _res(self, real_command, has_reply, genre):
9599
self._write(self._flatten(real_command), "socket")

0 commit comments

Comments
 (0)