You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The updated Rev2 encoder is only tested with light values 0 and 1, which both produced the same result with the removed MapAsFlag. Add cases for rear-only (0x02) and both lights (0x03) so this protocol revision's new bitfield behavior is actually verified.
The existing Rev2 tests only pass light values 0 and 1, so they would also pass with the old MapAsFlag implementation and do not exercise this PR's rear-light bit (0x02) or combined state (0x03). Add a Rev2 encoder case for 0x02 or 0x03 that verifies byte 9 and the resulting checksum.
SetLights now sets the bit if abs(value) > 0.5, otherwise clears it. Updated RaceCarMessageEncoderTests to encode (Half)0b00000011 and revised expected bytes with inline comments.
Replaced _lightsBitArray and SetLights with direct bit manipulation using the new SetOutputBit method in OutputValuesGroup. SetOutputBit enables atomic setting/clearing of individual bits for numeric TValue types, simplifying light state management and removing redundant fields and methods.
Refactored light output bit setting for channels 2 and 3 in CaDARaceCar to use ExecuteLocked with a function, improving thread safety and encapsulation. Introduced static SetLights method for setting/clearing bits. Replaced SetOutputBit in OutputValuesGroup with ExecuteLocked for flexible value modification.
Reworked the XAML Grid to use inline RowDefinitions="*,Auto,Auto,*" and ColumnDefinitions="*,Auto, Auto, *" and removed nested inner Grid wrappers. Flattened child elements so Image and ColorImage controls are direct Grid children using Grid.Row, Grid.Column and Grid.RowSpan/Grid.ColumnSpan. Consolidated two lightbulb icons into a single ColorImage spanning columns 1–2 at row 2 and replaced the second lightbulb with an "online_prediction" icon spanning columns 1–2. ChannelSelectorRadioButton controls remain in column 3 for rows 0–3 but were moved into the flattened Grid. Result: simpler, more compact XAML with adjusted layout behavior via column/row spans.
Added targeted unit tests to verify light-flag encoding and final 16-byte payloads for RaceCar message encoders.
- RaceCarMessageEncoderRev2Tests.cs
- Added three [Theory] tests:
EncodeValues_WithZeroValuesAndFrontLightOn,
EncodeValues_WithZeroValuesAndRearLightOn,
EncodeValues_WithZeroValuesAndFrontLightAndRearLightOn.
- Parameterized with InlineData (deviceId, appId, light bits, expected v1/v2/v4/sequence).
- Tests create encoder via Create(deviceId, appId, sequence) and call EncodeValues([Zero, Zero, (Half)value]).
- Assert the produced payload is exactly 16 bytes and matches the expected sequence:
header 0xBB, 0x11, 0x11; deviceId (low, high); appId (low, high); v1, v2, light-flag byte (0x01 front, 0x10 rear, 0x11 both), v4; sequence; tail 0xCC, 0xB8, 0x92, 0xB0.
- Notes that sequence is not incremented when speed and steering are zero.
- Uses existing Create helper to pass deviceId/appId as little-endian byte pairs.
- RaceCarMessageEncoderTests.cs
- Added two [Fact] tests:
Encode_WithFrontLightValue_EncodesAndEncryptsValues and
Encode_WithRearLightValue_EncodesAndEncryptsValues.
- Each constructs an encoder, calls Encode([Zero, Zero, (Half)0b00000001]), asserts 16-byte length and that the encoded result ends with the expected channel/tail bytes (verifying encrypted channel data related to light flags).
These tests ensure correct placement of front/rear light bits in the control byte, exact payload structure, and that encryption/channel bytes reflect the light-flag state.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
I've added an additional channel in
CaDARacecar.Now it's possible to separately control the front light and the rear light.