Skip to content

mavproxy_cmdlong.py: add possibility of retrying commands #1670

Draft
peterbarker wants to merge 2 commits into
ArduPilot:masterfrom
peterbarker:pr/COMMAND_INT.command_opaque_id-ardupilot
Draft

mavproxy_cmdlong.py: add possibility of retrying commands #1670
peterbarker wants to merge 2 commits into
ArduPilot:masterfrom
peterbarker:pr/COMMAND_INT.command_opaque_id-ardupilot

Conversation

@peterbarker
Copy link
Copy Markdown
Contributor

Copy link
Copy Markdown
Contributor

@cclauss cclauss left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Type hints please on new functions and methods.

The number of retries should always be an integer.

z)

class PendingCommand():
def __init__(self, command, retries=None, retry_interval=5):
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
def __init__(self, command, retries=None, retry_interval=5):
def __init__(self, command, retries: int = 0, retry_interval: int = 5) -> None:

self.last_send_time = 0
self.retry_interval = retry_interval

def timeout_expired(self):
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
def timeout_expired(self):
def timeout_expired(self) -> bool:

now = time.time()
return now - self.last_send_time > self.retry_interval

def send(self, mav):
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
def send(self, mav):
def send(self, mav) -> None:

self.send_count += 1
self.last_send_time = time.time()

def dead(self):
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
def dead(self):
def dead(self) -> None:

def dead(self):
if not self.timeout_expired:
return False
if self.retries is None:
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if self.retries is None:
if not self.retries:

return True
return False

def run_COMMAND_INT_OR_LONG(self, command, retries=None):
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
def run_COMMAND_INT_OR_LONG(self, command, retries=None):
def run_COMMAND_INT_OR_LONG(self, command, retries: int = 0) -> None:

self.command_queue[command.command_opaque_id] = p
p.send(self.master.mav)

def handle_COMMAND_ACK(self, m):
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
def handle_COMMAND_ACK(self, m):
def handle_COMMAND_ACK(self, m) -> None:

return
del self.command_queue[m.command_opaque_id]

def retry_commands(self):
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
def retry_commands(self):
def retry_commands(self) -> None:

continue
del self.command_queue[opaque_id]

def idle_task(self):
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
def idle_task(self):
def idle_task(self) -> None:

self.retry_commands()
self.last_command_retry_ms = now

def mavlink_packet(self, m):
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
def mavlink_packet(self, m):
def mavlink_packet(self, m) -> None:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants