Skip to content

Commit

Permalink
don't expect response to remote control commands
Browse files Browse the repository at this point in the history
  • Loading branch information
robagar committed Jul 31, 2021
1 parent 49e2dac commit cadbf19
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions tello_asyncio/tello.py
Original file line number Diff line number Diff line change
Expand Up @@ -530,9 +530,13 @@ async def send(self, message, timeout=DEFAULT_RESPONSE_TIMEOUT, response_parser=
'''
if not self._transport.is_closing():
print(f'SEND {message}')

self._transport.sendto(message.encode())
if not self._expect_response(message):
return

response = self._loop.create_future()
self._protocol.pending.append((message, response, response_parser))
self._transport.sendto(message.encode())
error = None
try:
response_message, result = await asyncio.wait_for(response, timeout=timeout)
Expand All @@ -556,6 +560,10 @@ async def send(self, message, timeout=DEFAULT_RESPONSE_TIMEOUT, response_parser=
await self._abort()
raise error

def _expect_response(self, message):
# drone responds to everything except remote control commands
return not message.startswith('rc ')

_aborted = False
async def _abort(self):
if not self._aborted:
Expand Down Expand Up @@ -869,7 +877,7 @@ async def send_ext_command(self, command):
Sends a command like "EXT xxx" for the open source contoller, returning
the response.
See the `SDK 3.0 User Guide` <https://dl.djicdn.com/downloads/RoboMaster+TT/Tello_SDK_3.0_User_Guide_en.pdf>`_ for command details.
See the `SDK 3.0 User Guide <https://dl.djicdn.com/downloads/RoboMaster+TT/Tello_SDK_3.0_User_Guide_en.pdf>`_ for command details.
Requires SDK 3+ and the open source controller
Expand Down

0 comments on commit cadbf19

Please sign in to comment.