Skip to content

Add a que for multimessages#64

Open
kellergoech wants to merge 3 commits into
RaulSMS:masterfrom
kellergoech:patch-3
Open

Add a que for multimessages#64
kellergoech wants to merge 3 commits into
RaulSMS:masterfrom
kellergoech:patch-3

Conversation

@kellergoech

Copy link
Copy Markdown

The que will buffer messages when these are triggered while sending of another message is still active. The que will be overwritten by new messages when sending is not active.
-> Therefore the application which uses this function does not need to care about the state of the send buffer.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

This PR adds a send-queue mechanism to the J1939-21 transport-protocol path so multi-packet messages triggered while another transfer is active can be buffered and sent later, reducing the need for application-side flow control.

Changes:

  • Introduced a new _snd_que structure to buffer pending multi-packet sends.
  • Refactored multi-packet send initialization into a new helper (_put_multi_msg).
  • Added queue-draining logic to async_job_thread to start a queued transfer once sending becomes idle.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread j1939/j1939_21.py
"num_packages": num_packets,
"data": data,
"state": self.SendBufferState.SENDING_BM,
"deadline": time.time() + self._minimum_tp_bam_dt_interval,
Comment thread j1939/j1939_21.py
"num_packages": num_packets,
"data": data,
"state": self.SendBufferState.WAITING_CTS,
"deadline": time.time() + self.Timeout.T3,
Comment thread j1939/j1939_21.py
Comment on lines +213 to +217
if not bool(self._snd_buffer):
for key, value in self._snd_que.items():
self._put_multi_msg(**value)
self._snd_que.pop(key)
break
Comment thread j1939/j1939_21.py
Comment on lines +177 to +184
self._snd_que[pgn.value] = {'buffer_hash': buffer_hash,
'pdu_specific': pdu_specific,
'priority': priority,
'src_address':src_address,
'pgn': pgn,
'data': data,
'dest_address': dest_address}
return False

@khauersp khauersp left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Copilot may have raised some good points, it seems the tests are running significantly slower than normal. Also, can we add some tests to verify the changes work as anticipated?

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.

3 participants