Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

alevy
Copy link
Member

@alevy alevy commented Aug 3, 2024

Pull Request Overview

This pull request implements the receive path for Segger RTT. Unfortunately, RTT has no
mechanism of notifying (e.g. via an interrupt) for the availability of
RX data so, instead, when the waiting for outstanding data, the
implementation just polls the RTT buffer every 100 milliseconds---fast
enough to be unnoticeable to a human but infrequent enough to interrupt
most computations.

Testing Strategy

Testing by typing into the the RTT console for the sma_q3 and seeing stuff happen as expected. This is not good comprehensive testing yet.

TODO or Help Wanted

N/A

Documentation Updated

  • Updated the relevant files in /docs, or no updates are required.

Formatting

  • Ran make prepush.

@alevy alevy force-pushed the segger_rtt_rx branch 2 times, most recently from 004b34f to 0734b05 Compare August 5, 2024 17:44
bradjc
bradjc previously approved these changes Aug 5, 2024
@alevy alevy force-pushed the segger_rtt_rx branch 3 times, most recently from 5670dd9 to 048a54b Compare August 8, 2024 04:39
@github-actions github-actions bot removed the component label Aug 8, 2024
@alevy alevy marked this pull request as ready for review August 8, 2024 04:46
config.down_buffer[read_position.get() as usize].get();
self.rx_cursor.set(self.rx_cursor.get() + 1);
read_position.set((read_position.get() + 1) % config.down_buffer.length);
fence(Ordering::SeqCst);
Copy link
Member

Choose a reason for hiding this comment

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

Just trying to reason about why this fence is required in addition to the one below: I'm assuming that it's to protect against compiler reorderings where the read_position is updated before the buffer contents were actually read?

In this case, I think the fence should be moved in between the down_buffer read, and updating of the cursor / read position.

Then the last fence after this loop takes care of flushing the final write.

Also, I think this should have a fence before the initial write_position.get() in the while-loop conditional.

Copy link
Member Author

Choose a reason for hiding this comment

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

Agree. Done

@lschuermann
Copy link
Member

Looks good to me other than the comment on fence above.

Implements the receive path for Segger RTT. Unfortunately, RTT has no
mechanism of notifying (e.g. via an interrupt) for the availability of
RX data so, instead, when the waiting for outstanding data, the
implementation just polls the RTT buffer every 100 milliseconds---fast
enough to be unnoticable to a human but infrequent enough to interrupt
most computations.
@lschuermann lschuermann added the last-call Final review period for a pull request. label Aug 8, 2024
@lschuermann
Copy link
Member

Unit testing: there is no reason not to unit test the buffer management/implementation here, so I'll do it. I bet I've made some mistake that's not caught by typing in a 4 character word.

@alevy I think this looks good and I'm happy to merge imminently, but feel free to remove last-call if this is still something you want to address.

@alevy alevy added this pull request to the merge queue Aug 9, 2024
Merged via the queue into tock:master with commit 900c141 Aug 9, 2024
12 checks passed
@alevy alevy deleted the segger_rtt_rx branch August 9, 2024 17:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
last-call Final review period for a pull request.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants