STAR
Cal STAR — firmware, DAQ server, and engine design
Loading...
Searching...
No Matches
send_policy.h
Go to the documentation of this file.
1
#pragma once
2
3
#include <stddef.h>
4
#include <stdint.h>
5
6
//-----------------------------------------------------------------------------
7
// When a sensor board ships the chunks it has queued.
8
//
9
// A packet used to go out only once SENSOR_MAX_CHUNKS_BEFORE_SEND chunks were
10
// queued. That is ~120 ms on a 75 Hz PT board, but an LC board scanning two
11
// load cells at 20 SPS + SINC4 finishes a chunk every ~0.8 s, so nine of them
12
// held each reading back 7-12 s. The GUI then saw nothing between bursts and
13
// blanked the readout as if the board had dropped off, and the server's clock
14
// sync, which refuses batches older than [time_sync] max_batch_age_s, stamped
15
// the whole burst at its arrival time.
16
//
17
// So a batch also goes out once its OLDEST chunk is max_age_ms old: fast boards
18
// still fill a packet first, slow boards send every chunk as it completes.
19
// oldest_ms and now_ms are the board's millis(); unsigned subtraction keeps
20
// the age right across the 49.7-day wrap.
21
//-----------------------------------------------------------------------------
22
inline
bool
sensorBatchReady
(
size_t
queued,
size_t
max_chunks,
23
uint32_t oldest_ms, uint32_t now_ms,
24
uint32_t max_age_ms) {
25
if
(queued == 0)
26
return
false
;
27
if
(queued >= max_chunks)
28
return
true
;
29
return
static_cast<
uint32_t
>
(now_ms - oldest_ms) >= max_age_ms;
30
}
sensorBatchReady
bool sensorBatchReady(size_t queued, size_t max_chunks, uint32_t oldest_ms, uint32_t now_ms, uint32_t max_age_ms)
Definition
send_policy.h:22
firmware
Hotfire_Code
common
send_policy.h
Generated by
1.15.0