-
Notifications
You must be signed in to change notification settings - Fork 3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Get start timestamp and add it to header #34
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me, but we'll need to discuss the buffer changes, I don't understand the significance of the change you've made here to buffer.c
.
server/data_server.c
Outdated
if (!ts_captured) | ||
release_write_block(data_buffer, 0); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Interesting. If this is needed it's addressing an outstanding bug, so I'd expect the condition should be count == 0
, as a missing release_write_block
will happen any time the capture end on a timeout. Also, there is an indentation error here!
Maybe end_write
is papering over the cracks here and triggering the missing release_write_block
, because we haven't seen a problem with this before ... or have we?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, I see from the commit message that this is an outstanding bug. Then maybe there should be a guard in end_write
against this, either silently (or with a warning) perform the missing release, or just an assert fail.
while (!buffer->released_once && !buffer->shutdown) | ||
pwait_deadline(&buffer->mutex, &buffer->signal, &deadline); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmmmm. Think we'll need to talk about this, don't understand what this is all about, why it's needed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is what is making the reader wait for the start event, otherwise the header will be sent before the start timestamp was captured
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh I see. Hmm. Not sure I like this.
So we have two timeouts ticking away, one in the kernel interface, one in the buffer, but we're blocking the buffer timeout until the experiment has triggered.
Guess this is the right way.
f453437
to
f6fb2ad
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The driver macro can be tidied up a little, but the rest of my comments are mostly me thinking aloud; this is fine.
driver/panda_stream.c
Outdated
#define IRQ_STATUS_DMA_ACTIVE(status) ((bool) ((status) & 0x80)) | ||
#define IRQ_STATUS_COMPLETION(status) ((size_t) (((status) >> 1) & 0x0F)) | ||
#define IRQ_START_EVENT(status) ((bool) (status & 0x100)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Forgot: we need brackets around (status)
for macro safety!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also for consistency might be better to call this macro IRQ_STATUS_START_EVENT
to match the other status register interrogation macros.
@@ -282,6 +290,8 @@ static void start_hardware(struct stream_open *open) | |||
open->isr_block_index = 0; | |||
open->read_block_index = 0; | |||
open->read_offset = 0; | |||
// having a zeroed timestamp means the start event did not happen | |||
open->start_ts = (const struct timespec64){0}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, this makes sense, and ensures that each time we arm the timestamp is reset.
if (!ts_captured) | ||
release_write_block(data_buffer, 0); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm. On the face of it the condition !ts_captured
should be replaced with count == 0
, as each call to get_write_block
ought to be balanced by a call to release_write_block
, and this call will be omitted any time the loop above exits with count
equal to 0.
On the other hand, get_write_block
doesn't actually have any side effects, and calling release_write_block
will trigger an empty update to the reader. Still, I think I'd prefer a form that looks correct locally.
// We are using this to convert to a stardard timespec in a way that we are | ||
// compatible with 32-bit and 64-bit architectures, however, we will not | ||
// need it when we update to a newer glibc (which contains __timespec64) | ||
struct timespec64 { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it possible to switch on the architecture version and use that version if it exists? This is quite a nasty hack...!
while (!buffer->released_once && !buffer->shutdown) | ||
pwait_deadline(&buffer->mutex, &buffer->signal, &deadline); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh I see. Hmm. Not sure I like this.
So we have two timeouts ticking away, one in the kernel interface, one in the buffer, but we're blocking the buffer timeout until the experiment has triggered.
Guess this is the right way.
f6fb2ad
to
9a54961
Compare
It is worth mentioning that this change comes together with PandABlocks/PandABlocks-FPGA#110 |
9a54961
to
0e02a37
Compare
This bug was already present before, but because PCAP timeouts happens every 100ms, it was hard to reproduce, now that a buffer reader waits for the start of the capture, it is easier to get this bug.
0e02a37
to
a68304d
Compare
This requires that the readers wait for the start of the acquisition.
struct timespec
doesn't match the timespec we get from the kernel module, on top of that, it could have different sizes in 32-bit and 64-bit architecture, a cast between an intermediate structure was used to workaround this.This fixes #7