|
11 | 11 | // hardware test. |
12 | 12 | // |
13 | 13 | // What this proves: |
14 | | -// 1. Round-trip correctness: a payload sent via set_raw() comes back byte-identical via |
15 | | -// get_raw(), when cast back to the caller's typed struct (rs2_temporal_filter_dpp_config) |
16 | | -// - exactly the caller-casts-the-void* contract of the real rs2_set/get_composite_option |
17 | | -// API. |
| 14 | +// 1. Round-trip correctness: a payload sent via set_raw(void*, size) comes back |
| 15 | +// byte-identical in the SDK-allocated vector returned by get_raw(), once memcpy'd into |
| 16 | +// the caller's typed struct (rs2_temporal_filter_dpp_config) - exactly the contract of |
| 17 | +// the real rs2_set_composite_option(data, data_size) / rs2_get_composite_option() |
| 18 | +// (which returns an rs2_raw_data_buffer, since the caller has no generic way to know an |
| 19 | +// arbitrary option_id's wire size in advance - mirrors rs2_get_safety_preset). |
18 | 20 | // 2. Atomicity: set_raw() performs EXACTLY ONE set_xu() call, and get_raw() performs |
19 | 21 | // EXACTLY ONE get_xu() call - i.e. the whole payload always travels as a single UVC |
20 | 22 | // transaction, never as separate per-field writes/reads. This is the non-negotiable |
@@ -120,11 +122,19 @@ try |
120 | 122 | sent.smooth_delta = 20; |
121 | 123 | sent.persistency_index = 3; |
122 | 124 |
|
123 | | - // Caller casts to/from void* - exactly the contract of rs2_set/get_composite_option. |
| 125 | + // Caller casts to/from void* - exactly the contract of rs2_set/get_composite_option. SET |
| 126 | + // still takes a caller-owned buffer (the caller/producer already knows sizeof() of what |
| 127 | + // it's sending). GET returns an SDK-owned, correctly-sized vector - the caller has no |
| 128 | + // generic way to know a given option_id's wire size in advance - mirroring |
| 129 | + // rs2_get_safety_preset/rs2::safety_sensor::get_safety_preset. |
124 | 130 | control.set_raw( dev, &sent, sizeof( sent ) ); |
125 | 131 |
|
| 132 | + std::vector< uint8_t > bytes = control.get_raw( dev ); |
| 133 | + if( bytes.size() != sizeof( rs2_temporal_filter_dpp_config ) ) |
| 134 | + throw std::runtime_error( "get_raw returned an unexpected payload size" ); |
| 135 | + |
126 | 136 | rs2_temporal_filter_dpp_config received{}; |
127 | | - control.get_raw( dev, &received, sizeof( received ) ); |
| 137 | + std::memcpy( &received, bytes.data(), sizeof( received ) ); |
128 | 138 |
|
129 | 139 | // 1) Round-trip correctness. |
130 | 140 | bool round_trip_ok = ( received.enabled == sent.enabled ) |
|
0 commit comments