Skip to content

Commit ab8dbd9

Browse files
authored
Merge branch 'main' into refactor_spec
2 parents 9ab2cad + a5b8d03 commit ab8dbd9

56 files changed

Lines changed: 6321 additions & 107 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/copilot-instructions.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ You are an embedded systems expert specializing in V2X protocols and bare-metal
77
The following actions require explicit user approval before execution:
88

99
- **File Deletion**: Do not delete existing files. If you believe a file should be removed, notify the user and wait for approval.
10-
- **Git State Changes**: Do not execute Git commands that modify repository state (e.g., `commit`, `push`, `checkout`, `reset`, `rebase`, `merge`). Read-only commands like `git log`, `git status`, and `git diff` are allowed.
10+
- **Git State Changes**: Do not execute Git commands that modify repository state (e.g., `add`, `commit`, `push`, `checkout`, `reset`, `rebase`, `merge`). Read-only commands like `git log`, `git status`, and `git diff` are allowed.
1111

1212
### Terminal Output
1313

.github/workflows/ci.yml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,21 @@ jobs:
153153
for /f "delims=" %%i in ('"%ProgramFiles(x86)%\Microsoft Visual Studio\Installer\vswhere.exe" -latest -property installationPath') do set VSDIR=%%i
154154
call "%VSDIR%\VC\Auxiliary\Build\vcvars64.bat"
155155
cl /std:c11 /W4 /WX /O2 /Isrc /Fe:build\J2735_run_tests.exe ^
156+
tests\J2735_internal_DE_AllowedManeuvers_test.c ^
157+
tests\J2735_internal_DE_BrakeAppliedStatus_test.c ^
158+
tests\J2735_internal_DE_ExteriorLights_test.c ^
159+
tests\J2735_internal_DE_GNSSstatus_test.c ^
160+
tests\J2735_internal_DE_LaneDirection_test.c ^
161+
tests\J2735_internal_DE_LaneSharing_test.c ^
162+
tests\J2735_internal_DE_PersonalAssistive_test.c ^
163+
tests\J2735_internal_DE_PersonalDeviceUsageState_test.c ^
164+
tests\J2735_internal_DE_PublicSafetyAndRoadWorkerActivity_test.c ^
165+
tests\J2735_internal_DE_PublicSafetyDirectingTrafficSubType_test.c ^
166+
tests\J2735_internal_DE_TrafficLightOperationStatus_test.c ^
167+
tests\J2735_internal_DE_TransitStatus_test.c ^
168+
tests\J2735_internal_DE_UserSizeAndBehaviour_test.c ^
156169
tests\J2735_internal_DE_VehicleEventFlags_test.c ^
170+
tests\J2735_internal_DE_VerticalAccelerationThreshold_test.c ^
157171
tests\J2735_internal_DF_ApproachOrLane_test.c ^
158172
tests\J2735_internal_DF_BSMcoreData_test.c ^
159173
tests\J2735_internal_DF_IntersectionReferenceID_test.c ^

.github/workflows/python.yml

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -66,19 +66,20 @@ permissions:
6666
env:
6767
PYTHON_VERSION: "3.12"
6868
# Coverage thresholds
69+
COVERAGE_MAX_MISSING_LINES: "10" # Max lines to show before truncating
6970
COVERAGE_THRESHOLD_GOOD: "90" # ✅ Green: >= 90%
7071
COVERAGE_THRESHOLD_WARN: "70" # ⚠️ Yellow: >= 70%
71-
COVERAGE_MAX_MISSING_LINES: "10" # Max lines to show before truncating
7272
# File paths
73-
COVERAGE_SOURCE: "tools"
7473
COVERAGE_JSON_FILE: "coverage.json"
7574
COVERAGE_OUTPUT_FILE: "coverage_output.txt"
76-
TEST_OUTPUT_FILE: "test_output.txt"
75+
COVERAGE_RCFILE: "tools/pyproject.toml"
76+
COVERAGE_SOURCE: "tools"
7777
STATIC_ANALYSIS_OUTPUT_FILE: "static_analysis_summary.txt"
78+
TEST_OUTPUT_FILE: "test_output.txt"
7879
# Artifact names
79-
ARTIFACT_TEST_RESULTS: "test-results"
8080
ARTIFACT_COVERAGE_RESULTS: "coverage-results"
8181
ARTIFACT_STATIC_ANALYSIS: "python-static-analysis-results"
82+
ARTIFACT_TEST_RESULTS: "test-results"
8283

8384
jobs:
8485
# ===========================================================================

src/J2735_api.h

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,30 @@
2424
#ifndef J2735_API_H
2525
#define J2735_API_H
2626

27+
#include "J2735_internal_DE_AllowedManeuvers.h"
28+
#include "J2735_internal_DE_BrakeAppliedStatus.h"
29+
#include "J2735_internal_DE_ExteriorLights.h"
30+
#include "J2735_internal_DE_GNSSstatus.h"
31+
#include "J2735_internal_DE_LaneDirection.h"
32+
#include "J2735_internal_DE_LaneSharing.h"
33+
#include "J2735_internal_DE_PersonalAssistive.h"
34+
#include "J2735_internal_DE_PersonalDeviceUsageState.h"
35+
#include "J2735_internal_DE_PublicSafetyAndRoadWorkerActivity.h"
36+
#include "J2735_internal_DE_PublicSafetyDirectingTrafficSubType.h"
37+
#include "J2735_internal_DE_TrafficLightOperationStatus.h"
38+
#include "J2735_internal_DE_TransitStatus.h"
39+
#include "J2735_internal_DE_UserSizeAndBehaviour.h"
2740
#include "J2735_internal_DE_VehicleEventFlags.h"
41+
#include "J2735_internal_DE_VerticalAccelerationThreshold.h"
42+
#include "J2735_internal_DF_ApproachOrLane.h"
2843
#include "J2735_internal_DF_BSMcoreData.h"
2944
#include "J2735_internal_DF_IntersectionReferenceID.h"
3045
#include "J2735_internal_DF_PathPrediction.h"
46+
3147
#include "J2735_internal_common.h"
3248
#include "J2735_internal_constants.h"
3349
#include "J2735_internal_inline.h"
50+
3451
#include "J2735_toolkit.h"
3552

3653
#endif /* J2735_API_H */

src/J2735_internal_DE_AllowedManeuvers.h

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838
*
3939
* Fixed BIT STRING with size 12.
4040
*
41-
* Wire Format (13 bits total):
41+
* Wire Format (12 bits total):
4242
* ┌──────────────────────────────────────────────────────────────┐
4343
* │ Bits 0-11 │
4444
* ├──────────────────────────────────────────────────────────────┤
@@ -49,14 +49,10 @@
4949
* ──────────────────────────────────────────────────────────────────────────────────────────
5050
* Max wire size = 12 bits ≤ 56-bit READ_BITS limit.
5151
* We read all 12 bits in ONE call, then use bit arithmetic to extract:
52-
* - Extension bit at position 11 (MSB of 12-bit value)
53-
* - Flags at positions 0-11 (extended) or shifted for non-extended
52+
* - Flags at positions 0-11
5453
*
5554
* 12-bit read layout (left-justified from bit 0):
56-
* Non-extended: [Ext=0][F0..F11][-1 garbage bits]
57-
* bit11 10..-1 -2..0
58-
* Extended: [Ext=1][nsnnwn:7][F0..F11]
59-
* bit11 10..12 11..0
55+
* [F0..F11] (12 flag bits, no extension marker)
6056
*
6157
* @todo Update the Doxygen to indicate [in] and [out] parameters
6258
*/
@@ -113,7 +109,7 @@
113109
* @note Internal use only. Not part of the public API.
114110
*/
115111
#define J2735_INTERNAL_RAW_READ_ALLOWED_MANEUVERS(buf) \
116-
J2735_READ_BITS((buf), 0U, J2735_INTERNAL_MAX_WIRE_BITS_ALLOWED_MANEUVERS)
112+
J2735_READ_BITS((buf), 0U, J2735_INTERNAL_ROOT_SIZE_ALLOWED_MANEUVERS)
117113

118114
/* ============================================================================================== */
119115
/* INTERNAL: Extension Bit Check */
@@ -169,7 +165,7 @@
169165
* @param[in] buf Pointer to the start of the AllowedManeuvers UPER encoding (const uint8_t*).
170166
* @return Always 0 (false) - this type is not extensible.
171167
*/
172-
#define J2735_ALLOWED_MANEUVERS_IS_EXTENDED(buf) (0)
168+
#define J2735_ALLOWED_MANEUVERS_IS_EXTENDED(buf) ((void)(buf), 0)
173169

174170
/**
175171
* @brief Get wire size of AllowedManeuvers in bits.
@@ -179,8 +175,7 @@
179175
* @param[in] buf Pointer to the start of the AllowedManeuvers UPER encoding (const uint8_t*).
180176
* @return Always 12U.
181177
*/
182-
#define J2735_ALLOWED_MANEUVERS_SIZE(buf) \
183-
(J2735_INTERNAL_EXTENSION_MARKER_BITS + J2735_INTERNAL_ROOT_SIZE_ALLOWED_MANEUVERS)
178+
#define J2735_ALLOWED_MANEUVERS_SIZE(buf) ((void)(buf), J2735_INTERNAL_ROOT_SIZE_ALLOWED_MANEUVERS)
184179

185180
/**
186181
* @brief Get all AllowedManeuvers as a single uint16_t value.

src/J2735_internal_DE_BrakeAppliedStatus.h

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
*
3232
* Fixed BIT STRING with size 5.
3333
*
34-
* Wire Format (6 bits total):
34+
* Wire Format (5 bits total):
3535
* ┌──────────────────────────────────────────────────────────────┐
3636
* │ Bits 0-4 │
3737
* ├──────────────────────────────────────────────────────────────┤
@@ -42,14 +42,10 @@
4242
* ──────────────────────────────────────────────────────────────────────────────────────────
4343
* Max wire size = 5 bits ≤ 56-bit READ_BITS limit.
4444
* We read all 5 bits in ONE call, then use bit arithmetic to extract:
45-
* - Extension bit at position 4 (MSB of 5-bit value)
46-
* - Flags at positions 0-4 (extended) or shifted for non-extended
45+
* - Flags at positions 0-4
4746
*
4847
* 5-bit read layout (left-justified from bit 0):
49-
* Non-extended: [Ext=0][F0..F4][-1 garbage bits]
50-
* bit4 3..-1 -2..0
51-
* Extended: [Ext=1][nsnnwn:7][F0..F4]
52-
* bit4 3..5 4..0
48+
* [F0..F4] (5 flag bits, no extension marker)
5349
*
5450
* @todo Update the Doxygen to indicate [in] and [out] parameters
5551
*/
@@ -99,7 +95,7 @@
9995
* @note Internal use only. Not part of the public API.
10096
*/
10197
#define J2735_INTERNAL_RAW_READ_BRAKE_APPLIED_STATUS(buf) \
102-
J2735_READ_BITS((buf), 0U, J2735_INTERNAL_MAX_WIRE_BITS_BRAKE_APPLIED_STATUS)
98+
J2735_READ_BITS((buf), 0U, J2735_INTERNAL_ROOT_SIZE_BRAKE_APPLIED_STATUS)
10399

104100
/* ============================================================================================== */
105101
/* INTERNAL: Extension Bit Check */
@@ -155,7 +151,7 @@
155151
* @param[in] buf Pointer to the start of the BrakeAppliedStatus UPER encoding (const uint8_t*).
156152
* @return Always 0 (false) - this type is not extensible.
157153
*/
158-
#define J2735_BRAKE_APPLIED_STATUS_IS_EXTENDED(buf) (0)
154+
#define J2735_BRAKE_APPLIED_STATUS_IS_EXTENDED(buf) ((void)(buf), 0)
159155

160156
/**
161157
* @brief Get wire size of BrakeAppliedStatus in bits.
@@ -166,7 +162,7 @@
166162
* @return Always 5U.
167163
*/
168164
#define J2735_BRAKE_APPLIED_STATUS_SIZE(buf) \
169-
(J2735_INTERNAL_EXTENSION_MARKER_BITS + J2735_INTERNAL_ROOT_SIZE_BRAKE_APPLIED_STATUS)
165+
((void)(buf), J2735_INTERNAL_ROOT_SIZE_BRAKE_APPLIED_STATUS)
170166

171167
/**
172168
* @brief Get all BrakeAppliedStatus as a single uint8_t value.

src/J2735_internal_DE_ExteriorLights.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -179,15 +179,17 @@ _Static_assert(J2735_INTERNAL_MAX_WIRE_BITS_EXTERIOR_LIGHTS ==
179179
* @return Right-aligned flag bits as uint16_t:
180180
* - 9 significant bits (0x0000-0x01FF) if non-extended
181181
* - 9 significant bits (0x0000-0x01FF) if extended
182+
* @note Uses 1ULL for bit shifts to prevent undefined behavior if size >= 32 bits.
183+
* The compiler optimizes the truncation to uint16_t.
182184
* @note Internal use only. Use J2735_EXTERIOR_LIGHTS_GET() for public API.
183185
*/
184186
#define J2735_INTERNAL_GET_ALL_EXTERIOR_LIGHTS(raw17) \
185187
(J2735_INTERNAL_IS_EXTENSION_EXTERIOR_LIGHTS(raw17) ? /* Extended: low 9 bits */ \
186-
((uint16_t)((raw17) & ((1U << J2735_INTERNAL_EXT_SIZE_EXTERIOR_LIGHTS) - 1U))) \
188+
((uint16_t)((raw17) & ((1ULL << J2735_INTERNAL_EXT_SIZE_EXTERIOR_LIGHTS) - 1ULL))) \
187189
: /* Non-ext: bits 15..7 = 9 bits */ \
188190
((uint16_t)(((raw17) >> (J2735_INTERNAL_MAX_WIRE_BITS_EXTERIOR_LIGHTS - 1U - \
189191
J2735_INTERNAL_ROOT_SIZE_EXTERIOR_LIGHTS)) & \
190-
((1U << J2735_INTERNAL_ROOT_SIZE_EXTERIOR_LIGHTS) - 1U))))
192+
((1ULL << J2735_INTERNAL_ROOT_SIZE_EXTERIOR_LIGHTS) - 1ULL))))
191193

192194
/**
193195
* @internal

src/J2735_internal_DE_GNSSstatus.h

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
*
3535
* Fixed BIT STRING with size 8.
3636
*
37-
* Wire Format (9 bits total):
37+
* Wire Format (8 bits total):
3838
* ┌──────────────────────────────────────────────────────────────┐
3939
* │ Bits 0-7 │
4040
* ├──────────────────────────────────────────────────────────────┤
@@ -45,14 +45,10 @@
4545
* ──────────────────────────────────────────────────────────────────────────────────────────
4646
* Max wire size = 8 bits ≤ 56-bit READ_BITS limit.
4747
* We read all 8 bits in ONE call, then use bit arithmetic to extract:
48-
* - Extension bit at position 7 (MSB of 8-bit value)
49-
* - Flags at positions 0-7 (extended) or shifted for non-extended
48+
* - Flags at positions 0-7
5049
*
5150
* 8-bit read layout (left-justified from bit 0):
52-
* Non-extended: [Ext=0][F0..F7][-1 garbage bits]
53-
* bit7 6..-1 -2..0
54-
* Extended: [Ext=1][nsnnwn:7][F0..F7]
55-
* bit7 6..8 7..0
51+
* [F0..F7] (8 flag bits, no extension marker)
5652
*
5753
* @todo Update the Doxygen to indicate [in] and [out] parameters
5854
*/
@@ -105,7 +101,7 @@
105101
* @note Internal use only. Not part of the public API.
106102
*/
107103
#define J2735_INTERNAL_RAW_READ_GNSS_STATUS(buf) \
108-
J2735_READ_BITS((buf), 0U, J2735_INTERNAL_MAX_WIRE_BITS_GNSS_STATUS)
104+
J2735_READ_BITS((buf), 0U, J2735_INTERNAL_ROOT_SIZE_GNSS_STATUS)
109105

110106
/* ============================================================================================== */
111107
/* INTERNAL: Extension Bit Check */
@@ -161,7 +157,7 @@
161157
* @param[in] buf Pointer to the start of the GNSSstatus UPER encoding (const uint8_t*).
162158
* @return Always 0 (false) - this type is not extensible.
163159
*/
164-
#define J2735_GNSS_STATUS_IS_EXTENDED(buf) (0)
160+
#define J2735_GNSS_STATUS_IS_EXTENDED(buf) ((void)(buf), 0)
165161

166162
/**
167163
* @brief Get wire size of GNSSstatus in bits.
@@ -171,8 +167,7 @@
171167
* @param[in] buf Pointer to the start of the GNSSstatus UPER encoding (const uint8_t*).
172168
* @return Always 8U.
173169
*/
174-
#define J2735_GNSS_STATUS_SIZE(buf) \
175-
(J2735_INTERNAL_EXTENSION_MARKER_BITS + J2735_INTERNAL_ROOT_SIZE_GNSS_STATUS)
170+
#define J2735_GNSS_STATUS_SIZE(buf) ((void)(buf), J2735_INTERNAL_ROOT_SIZE_GNSS_STATUS)
176171

177172
/**
178173
* @brief Get all GNSSstatus as a single uint8_t value.

src/J2735_internal_DE_LaneDirection.h

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
*
2929
* Fixed BIT STRING with size 2.
3030
*
31-
* Wire Format (3 bits total):
31+
* Wire Format (2 bits total):
3232
* ┌──────────────────────────────────────────────────────────────┐
3333
* │ Bits 0-1 │
3434
* ├──────────────────────────────────────────────────────────────┤
@@ -39,14 +39,10 @@
3939
* ──────────────────────────────────────────────────────────────────────────────────────────
4040
* Max wire size = 2 bits ≤ 56-bit READ_BITS limit.
4141
* We read all 2 bits in ONE call, then use bit arithmetic to extract:
42-
* - Extension bit at position 1 (MSB of 2-bit value)
43-
* - Flags at positions 0-1 (extended) or shifted for non-extended
42+
* - Flags at positions 0-1
4443
*
4544
* 2-bit read layout (left-justified from bit 0):
46-
* Non-extended: [Ext=0][F0..F1][-1 garbage bits]
47-
* bit1 0..-1 -2..0
48-
* Extended: [Ext=1][nsnnwn:7][F0..F1]
49-
* bit1 0..2 1..0
45+
* [F0..F1] (2 flag bits, no extension marker)
5046
*
5147
* @todo Update the Doxygen to indicate [in] and [out] parameters
5248
*/
@@ -93,7 +89,7 @@
9389
* @note Internal use only. Not part of the public API.
9490
*/
9591
#define J2735_INTERNAL_RAW_READ_LANE_DIRECTION(buf) \
96-
J2735_READ_BITS((buf), 0U, J2735_INTERNAL_MAX_WIRE_BITS_LANE_DIRECTION)
92+
J2735_READ_BITS((buf), 0U, J2735_INTERNAL_ROOT_SIZE_LANE_DIRECTION)
9793

9894
/* ============================================================================================== */
9995
/* INTERNAL: Extension Bit Check */
@@ -149,7 +145,7 @@
149145
* @param[in] buf Pointer to the start of the LaneDirection UPER encoding (const uint8_t*).
150146
* @return Always 0 (false) - this type is not extensible.
151147
*/
152-
#define J2735_LANE_DIRECTION_IS_EXTENDED(buf) (0)
148+
#define J2735_LANE_DIRECTION_IS_EXTENDED(buf) ((void)(buf), 0)
153149

154150
/**
155151
* @brief Get wire size of LaneDirection in bits.
@@ -159,8 +155,7 @@
159155
* @param[in] buf Pointer to the start of the LaneDirection UPER encoding (const uint8_t*).
160156
* @return Always 2U.
161157
*/
162-
#define J2735_LANE_DIRECTION_SIZE(buf) \
163-
(J2735_INTERNAL_EXTENSION_MARKER_BITS + J2735_INTERNAL_ROOT_SIZE_LANE_DIRECTION)
158+
#define J2735_LANE_DIRECTION_SIZE(buf) ((void)(buf), J2735_INTERNAL_ROOT_SIZE_LANE_DIRECTION)
164159

165160
/**
166161
* @brief Get all LaneDirection as a single uint8_t value.

src/J2735_internal_DE_LaneSharing.h

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
*
3737
* Fixed BIT STRING with size 10.
3838
*
39-
* Wire Format (11 bits total):
39+
* Wire Format (10 bits total):
4040
* ┌──────────────────────────────────────────────────────────────┐
4141
* │ Bits 0-9 │
4242
* ├──────────────────────────────────────────────────────────────┤
@@ -47,14 +47,10 @@
4747
* ──────────────────────────────────────────────────────────────────────────────────────────
4848
* Max wire size = 10 bits ≤ 56-bit READ_BITS limit.
4949
* We read all 10 bits in ONE call, then use bit arithmetic to extract:
50-
* - Extension bit at position 9 (MSB of 10-bit value)
51-
* - Flags at positions 0-9 (extended) or shifted for non-extended
50+
* - Flags at positions 0-9
5251
*
5352
* 10-bit read layout (left-justified from bit 0):
54-
* Non-extended: [Ext=0][F0..F9][-1 garbage bits]
55-
* bit9 8..-1 -2..0
56-
* Extended: [Ext=1][nsnnwn:7][F0..F9]
57-
* bit9 8..10 9..0
53+
* [F0..F9] (10 flag bits, no extension marker)
5854
*
5955
* @todo Update the Doxygen to indicate [in] and [out] parameters
6056
*/
@@ -109,7 +105,7 @@
109105
* @note Internal use only. Not part of the public API.
110106
*/
111107
#define J2735_INTERNAL_RAW_READ_LANE_SHARING(buf) \
112-
J2735_READ_BITS((buf), 0U, J2735_INTERNAL_MAX_WIRE_BITS_LANE_SHARING)
108+
J2735_READ_BITS((buf), 0U, J2735_INTERNAL_ROOT_SIZE_LANE_SHARING)
113109

114110
/* ============================================================================================== */
115111
/* INTERNAL: Extension Bit Check */
@@ -165,7 +161,7 @@
165161
* @param[in] buf Pointer to the start of the LaneSharing UPER encoding (const uint8_t*).
166162
* @return Always 0 (false) - this type is not extensible.
167163
*/
168-
#define J2735_LANE_SHARING_IS_EXTENDED(buf) (0)
164+
#define J2735_LANE_SHARING_IS_EXTENDED(buf) ((void)(buf), 0)
169165

170166
/**
171167
* @brief Get wire size of LaneSharing in bits.
@@ -175,8 +171,7 @@
175171
* @param[in] buf Pointer to the start of the LaneSharing UPER encoding (const uint8_t*).
176172
* @return Always 10U.
177173
*/
178-
#define J2735_LANE_SHARING_SIZE(buf) \
179-
(J2735_INTERNAL_EXTENSION_MARKER_BITS + J2735_INTERNAL_ROOT_SIZE_LANE_SHARING)
174+
#define J2735_LANE_SHARING_SIZE(buf) ((void)(buf), J2735_INTERNAL_ROOT_SIZE_LANE_SHARING)
180175

181176
/**
182177
* @brief Get all LaneSharing as a single uint16_t value.

0 commit comments

Comments
 (0)