Skip to content

Commit

Permalink
fixed Python2-Python3 and msgpack0.5.6-msgpack1.0.0 compatibility issues
Browse files Browse the repository at this point in the history
  • Loading branch information
Coppelia committed Feb 28, 2020
1 parent 1b522e5 commit 03fa6c6
Show file tree
Hide file tree
Showing 7 changed files with 14 additions and 6 deletions.
2 changes: 1 addition & 1 deletion generate/simxStubs/doc-list.htm
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ <h1>B0-based remote API function list</h1>
#py endif
#py endfor
#py od=collections.OrderedDict(sorted(allCmds.items()))
#py for k, v in od.iteritems():
#py for k, v in od.items():
#py s=v[0]+" "*(2+ml-len(v[0]))+v[1]
`s`
#py endfor
Expand Down
2 changes: 1 addition & 1 deletion generate/simxStubs/doc.htm
Original file line number Diff line number Diff line change
Expand Up @@ -368,7 +368,7 @@ <h1>B0-based remote API, Python</h1>
#py allCmds[cmd.name]=cmdHtmlStr
#py endfor
#py od=collections.OrderedDict(sorted(allCmds.items()))
#py for k, v in od.iteritems():
#py for k, v in od.items():
`v`
#py endfor
#py #-----------------------------------------------------------------------------------------------
Expand Down
4 changes: 2 additions & 2 deletions generate/simxStubs/python/stub.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ def _pingCallback(self,msg):
self._pongReceived=True

def _handleReceivedMessage(self,msg):
msg=msgpack.unpackb(msg)
msg=msgpack.unpackb(msg,raw=True)
msg[0]=msg[0].decode('ascii')
if msg[0] in self._allSubscribers:
cbMsg=msg[1]
Expand All @@ -73,7 +73,7 @@ def _handleReceivedMessage(self,msg):
def _handleFunction(self,funcName,reqArgs,topic):
if topic==self._serviceCallTopic:
packedData=msgpack.packb([[funcName,self._clientId,topic,0],reqArgs])
rep = msgpack.unpackb(self._serviceClient.call(packedData))
rep = msgpack.unpackb(self._serviceClient.call(packedData),raw=True)
if len(rep)==1:
rep.append(None)
return rep
Expand Down
4 changes: 2 additions & 2 deletions python/b0RemoteApi.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ def _pingCallback(self,msg):
self._pongReceived=True

def _handleReceivedMessage(self,msg):
msg=msgpack.unpackb(msg)
msg=msgpack.unpackb(msg,raw=True)
msg[0]=msg[0].decode('ascii')
if msg[0] in self._allSubscribers:
cbMsg=msg[1]
Expand All @@ -70,7 +70,7 @@ def _handleReceivedMessage(self,msg):
def _handleFunction(self,funcName,reqArgs,topic):
if topic==self._serviceCallTopic:
packedData=msgpack.packb([[funcName,self._clientId,topic,0],reqArgs])
rep = msgpack.unpackb(self._serviceClient.call(packedData))
rep = msgpack.unpackb(self._serviceClient.call(packedData),raw=True)
if len(rep)==1:
rep.append(None)
return rep
Expand Down
2 changes: 2 additions & 0 deletions python/sendMovementSequence-mov.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ def waitForMovementExecuted(id):
client.simxSpinOnce()

def executedMovId_callback(msg):
if type(msg[1])==bytes:
msg[1]=msg[1].decode('ascii') # python2/python3 differences
client.executedMovId=msg[1]

# Subscribe to stringSignalName string signal:
Expand Down
2 changes: 2 additions & 0 deletions python/sendMovementSequence-pts.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ def waitForMovementExecuted(id):
client.simxSpinOnce()

def executedMovId_callback(msg):
if type(msg[1])==bytes:
msg[1]=msg[1].decode('ascii') # python2/python3 differences
client.executedMovId=msg[1]

# Subscribe to stringSignalName string signal:
Expand Down
4 changes: 4 additions & 0 deletions python/sendSimultan2MovementSequences-mov.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,13 @@ def waitForMovementExecuted2(id):
client.simxSpinOnce()

def executedMovId1_callback(msg):
if type(msg[1])==bytes:
msg[1]=msg[1].decode('ascii') # python2/python3 differences
client.executedMovId1=msg[1]

def executedMovId2_callback(msg):
if type(msg[1])==bytes:
msg[1]=msg[1].decode('ascii') # python2/python3 differences
client.executedMovId2=msg[1]

# Subscribe to stringSignalName1 and stringSignalName2 string signals:
Expand Down

0 comments on commit 03fa6c6

Please sign in to comment.