Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/copilot-instructions.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ You are an embedded systems expert specializing in V2X protocols and bare-metal
The following actions require explicit user approval before execution:

- **File Deletion**: Do not delete existing files. If you believe a file should be removed, notify the user and wait for approval.
- **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.
- **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.

### Terminal Output

Expand Down
14 changes: 14 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,21 @@ jobs:
for /f "delims=" %%i in ('"%ProgramFiles(x86)%\Microsoft Visual Studio\Installer\vswhere.exe" -latest -property installationPath') do set VSDIR=%%i
call "%VSDIR%\VC\Auxiliary\Build\vcvars64.bat"
cl /std:c11 /W4 /WX /O2 /Isrc /Fe:build\J2735_run_tests.exe ^
tests\J2735_internal_DE_AllowedManeuvers_test.c ^
tests\J2735_internal_DE_BrakeAppliedStatus_test.c ^
tests\J2735_internal_DE_ExteriorLights_test.c ^
tests\J2735_internal_DE_GNSSstatus_test.c ^
tests\J2735_internal_DE_LaneDirection_test.c ^
tests\J2735_internal_DE_LaneSharing_test.c ^
tests\J2735_internal_DE_PersonalAssistive_test.c ^
tests\J2735_internal_DE_PersonalDeviceUsageState_test.c ^
tests\J2735_internal_DE_PublicSafetyAndRoadWorkerActivity_test.c ^
tests\J2735_internal_DE_PublicSafetyDirectingTrafficSubType_test.c ^
tests\J2735_internal_DE_TrafficLightOperationStatus_test.c ^
tests\J2735_internal_DE_TransitStatus_test.c ^
tests\J2735_internal_DE_UserSizeAndBehaviour_test.c ^
tests\J2735_internal_DE_VehicleEventFlags_test.c ^
tests\J2735_internal_DE_VerticalAccelerationThreshold_test.c ^
tests\J2735_internal_DF_ApproachOrLane_test.c ^
tests\J2735_internal_DF_BSMcoreData_test.c ^
tests\J2735_internal_DF_IntersectionReferenceID_test.c ^
Expand Down
9 changes: 5 additions & 4 deletions .github/workflows/python.yml
Original file line number Diff line number Diff line change
Expand Up @@ -62,19 +62,20 @@ permissions:
env:
PYTHON_VERSION: "3.12"
# Coverage thresholds
COVERAGE_MAX_MISSING_LINES: "10" # Max lines to show before truncating
COVERAGE_THRESHOLD_GOOD: "90" # ✅ Green: >= 90%
COVERAGE_THRESHOLD_WARN: "70" # ⚠️ Yellow: >= 70%
COVERAGE_MAX_MISSING_LINES: "10" # Max lines to show before truncating
# File paths
COVERAGE_SOURCE: "tools"
COVERAGE_JSON_FILE: "coverage.json"
COVERAGE_OUTPUT_FILE: "coverage_output.txt"
TEST_OUTPUT_FILE: "test_output.txt"
COVERAGE_RCFILE: "tools/pyproject.toml"
COVERAGE_SOURCE: "tools"
STATIC_ANALYSIS_OUTPUT_FILE: "static_analysis_summary.txt"
TEST_OUTPUT_FILE: "test_output.txt"
# Artifact names
ARTIFACT_TEST_RESULTS: "test-results"
ARTIFACT_COVERAGE_RESULTS: "coverage-results"
ARTIFACT_STATIC_ANALYSIS: "python-static-analysis-results"
ARTIFACT_TEST_RESULTS: "test-results"

jobs:
# ===========================================================================
Expand Down
17 changes: 17 additions & 0 deletions src/J2735_api.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,30 @@
#ifndef J2735_API_H
#define J2735_API_H

#include "J2735_internal_DE_AllowedManeuvers.h"
#include "J2735_internal_DE_BrakeAppliedStatus.h"
#include "J2735_internal_DE_ExteriorLights.h"
#include "J2735_internal_DE_GNSSstatus.h"
#include "J2735_internal_DE_LaneDirection.h"
#include "J2735_internal_DE_LaneSharing.h"
#include "J2735_internal_DE_PersonalAssistive.h"
#include "J2735_internal_DE_PersonalDeviceUsageState.h"
#include "J2735_internal_DE_PublicSafetyAndRoadWorkerActivity.h"
#include "J2735_internal_DE_PublicSafetyDirectingTrafficSubType.h"
#include "J2735_internal_DE_TrafficLightOperationStatus.h"
#include "J2735_internal_DE_TransitStatus.h"
#include "J2735_internal_DE_UserSizeAndBehaviour.h"
#include "J2735_internal_DE_VehicleEventFlags.h"
#include "J2735_internal_DE_VerticalAccelerationThreshold.h"
#include "J2735_internal_DF_ApproachOrLane.h"
#include "J2735_internal_DF_BSMcoreData.h"
#include "J2735_internal_DF_IntersectionReferenceID.h"
#include "J2735_internal_DF_PathPrediction.h"

#include "J2735_internal_common.h"
#include "J2735_internal_constants.h"
#include "J2735_internal_inline.h"

#include "J2735_toolkit.h"

#endif /* J2735_API_H */
17 changes: 6 additions & 11 deletions src/J2735_internal_DE_AllowedManeuvers.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
*
* Fixed BIT STRING with size 12.
*
* Wire Format (13 bits total):
* Wire Format (12 bits total):
* ┌──────────────────────────────────────────────────────────────┐
* │ Bits 0-11 │
* ├──────────────────────────────────────────────────────────────┤
Expand All @@ -49,14 +49,10 @@
* ──────────────────────────────────────────────────────────────────────────────────────────
* Max wire size = 12 bits ≤ 56-bit READ_BITS limit.
* We read all 12 bits in ONE call, then use bit arithmetic to extract:
* - Extension bit at position 11 (MSB of 12-bit value)
* - Flags at positions 0-11 (extended) or shifted for non-extended
* - Flags at positions 0-11
*
* 12-bit read layout (left-justified from bit 0):
* Non-extended: [Ext=0][F0..F11][-1 garbage bits]
* bit11 10..-1 -2..0
* Extended: [Ext=1][nsnnwn:7][F0..F11]
* bit11 10..12 11..0
* [F0..F11] (12 flag bits, no extension marker)
*
* @todo Update the Doxygen to indicate [in] and [out] parameters
*/
Expand Down Expand Up @@ -113,7 +109,7 @@
* @note Internal use only. Not part of the public API.
*/
#define J2735_INTERNAL_RAW_READ_ALLOWED_MANEUVERS(buf) \
J2735_READ_BITS((buf), 0U, J2735_INTERNAL_MAX_WIRE_BITS_ALLOWED_MANEUVERS)
J2735_READ_BITS((buf), 0U, J2735_INTERNAL_ROOT_SIZE_ALLOWED_MANEUVERS)

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

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

/**
* @brief Get all AllowedManeuvers as a single uint16_t value.
Expand Down
16 changes: 6 additions & 10 deletions src/J2735_internal_DE_BrakeAppliedStatus.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
*
* Fixed BIT STRING with size 5.
*
* Wire Format (6 bits total):
* Wire Format (5 bits total):
* ┌──────────────────────────────────────────────────────────────┐
* │ Bits 0-4 │
* ├──────────────────────────────────────────────────────────────┤
Expand All @@ -42,14 +42,10 @@
* ──────────────────────────────────────────────────────────────────────────────────────────
* Max wire size = 5 bits ≤ 56-bit READ_BITS limit.
* We read all 5 bits in ONE call, then use bit arithmetic to extract:
* - Extension bit at position 4 (MSB of 5-bit value)
* - Flags at positions 0-4 (extended) or shifted for non-extended
* - Flags at positions 0-4
*
* 5-bit read layout (left-justified from bit 0):
* Non-extended: [Ext=0][F0..F4][-1 garbage bits]
* bit4 3..-1 -2..0
* Extended: [Ext=1][nsnnwn:7][F0..F4]
* bit4 3..5 4..0
* [F0..F4] (5 flag bits, no extension marker)
*
* @todo Update the Doxygen to indicate [in] and [out] parameters
*/
Expand Down Expand Up @@ -99,7 +95,7 @@
* @note Internal use only. Not part of the public API.
*/
#define J2735_INTERNAL_RAW_READ_BRAKE_APPLIED_STATUS(buf) \
J2735_READ_BITS((buf), 0U, J2735_INTERNAL_MAX_WIRE_BITS_BRAKE_APPLIED_STATUS)
J2735_READ_BITS((buf), 0U, J2735_INTERNAL_ROOT_SIZE_BRAKE_APPLIED_STATUS)

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

/**
* @brief Get wire size of BrakeAppliedStatus in bits.
Expand All @@ -166,7 +162,7 @@
* @return Always 5U.
*/
#define J2735_BRAKE_APPLIED_STATUS_SIZE(buf) \
(J2735_INTERNAL_EXTENSION_MARKER_BITS + J2735_INTERNAL_ROOT_SIZE_BRAKE_APPLIED_STATUS)
((void)(buf), J2735_INTERNAL_ROOT_SIZE_BRAKE_APPLIED_STATUS)

/**
* @brief Get all BrakeAppliedStatus as a single uint8_t value.
Expand Down
6 changes: 4 additions & 2 deletions src/J2735_internal_DE_ExteriorLights.h
Original file line number Diff line number Diff line change
Expand Up @@ -179,15 +179,17 @@ _Static_assert(J2735_INTERNAL_MAX_WIRE_BITS_EXTERIOR_LIGHTS ==
* @return Right-aligned flag bits as uint16_t:
* - 9 significant bits (0x0000-0x01FF) if non-extended
* - 9 significant bits (0x0000-0x01FF) if extended
* @note Uses 1ULL for bit shifts to prevent undefined behavior if size >= 32 bits.
* The compiler optimizes the truncation to uint16_t.
* @note Internal use only. Use J2735_EXTERIOR_LIGHTS_GET() for public API.
*/
#define J2735_INTERNAL_GET_ALL_EXTERIOR_LIGHTS(raw17) \
(J2735_INTERNAL_IS_EXTENSION_EXTERIOR_LIGHTS(raw17) ? /* Extended: low 9 bits */ \
((uint16_t)((raw17) & ((1U << J2735_INTERNAL_EXT_SIZE_EXTERIOR_LIGHTS) - 1U))) \
((uint16_t)((raw17) & ((1ULL << J2735_INTERNAL_EXT_SIZE_EXTERIOR_LIGHTS) - 1ULL))) \
: /* Non-ext: bits 15..7 = 9 bits */ \
((uint16_t)(((raw17) >> (J2735_INTERNAL_MAX_WIRE_BITS_EXTERIOR_LIGHTS - 1U - \
J2735_INTERNAL_ROOT_SIZE_EXTERIOR_LIGHTS)) & \
((1U << J2735_INTERNAL_ROOT_SIZE_EXTERIOR_LIGHTS) - 1U))))
((1ULL << J2735_INTERNAL_ROOT_SIZE_EXTERIOR_LIGHTS) - 1ULL))))

/**
* @internal
Expand Down
17 changes: 6 additions & 11 deletions src/J2735_internal_DE_GNSSstatus.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
*
* Fixed BIT STRING with size 8.
*
* Wire Format (9 bits total):
* Wire Format (8 bits total):
* ┌──────────────────────────────────────────────────────────────┐
* │ Bits 0-7 │
* ├──────────────────────────────────────────────────────────────┤
Expand All @@ -45,14 +45,10 @@
* ──────────────────────────────────────────────────────────────────────────────────────────
* Max wire size = 8 bits ≤ 56-bit READ_BITS limit.
* We read all 8 bits in ONE call, then use bit arithmetic to extract:
* - Extension bit at position 7 (MSB of 8-bit value)
* - Flags at positions 0-7 (extended) or shifted for non-extended
* - Flags at positions 0-7
*
* 8-bit read layout (left-justified from bit 0):
* Non-extended: [Ext=0][F0..F7][-1 garbage bits]
* bit7 6..-1 -2..0
* Extended: [Ext=1][nsnnwn:7][F0..F7]
* bit7 6..8 7..0
* [F0..F7] (8 flag bits, no extension marker)
*
* @todo Update the Doxygen to indicate [in] and [out] parameters
*/
Expand Down Expand Up @@ -105,7 +101,7 @@
* @note Internal use only. Not part of the public API.
*/
#define J2735_INTERNAL_RAW_READ_GNSS_STATUS(buf) \
J2735_READ_BITS((buf), 0U, J2735_INTERNAL_MAX_WIRE_BITS_GNSS_STATUS)
J2735_READ_BITS((buf), 0U, J2735_INTERNAL_ROOT_SIZE_GNSS_STATUS)

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

/**
* @brief Get wire size of GNSSstatus in bits.
Expand All @@ -171,8 +167,7 @@
* @param[in] buf Pointer to the start of the GNSSstatus UPER encoding (const uint8_t*).
* @return Always 8U.
*/
#define J2735_GNSS_STATUS_SIZE(buf) \
(J2735_INTERNAL_EXTENSION_MARKER_BITS + J2735_INTERNAL_ROOT_SIZE_GNSS_STATUS)
#define J2735_GNSS_STATUS_SIZE(buf) ((void)(buf), J2735_INTERNAL_ROOT_SIZE_GNSS_STATUS)

/**
* @brief Get all GNSSstatus as a single uint8_t value.
Expand Down
17 changes: 6 additions & 11 deletions src/J2735_internal_DE_LaneDirection.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
*
* Fixed BIT STRING with size 2.
*
* Wire Format (3 bits total):
* Wire Format (2 bits total):
* ┌──────────────────────────────────────────────────────────────┐
* │ Bits 0-1 │
* ├──────────────────────────────────────────────────────────────┤
Expand All @@ -39,14 +39,10 @@
* ──────────────────────────────────────────────────────────────────────────────────────────
* Max wire size = 2 bits ≤ 56-bit READ_BITS limit.
* We read all 2 bits in ONE call, then use bit arithmetic to extract:
* - Extension bit at position 1 (MSB of 2-bit value)
* - Flags at positions 0-1 (extended) or shifted for non-extended
* - Flags at positions 0-1
*
* 2-bit read layout (left-justified from bit 0):
* Non-extended: [Ext=0][F0..F1][-1 garbage bits]
* bit1 0..-1 -2..0
* Extended: [Ext=1][nsnnwn:7][F0..F1]
* bit1 0..2 1..0
* [F0..F1] (2 flag bits, no extension marker)
*
* @todo Update the Doxygen to indicate [in] and [out] parameters
*/
Expand Down Expand Up @@ -93,7 +89,7 @@
* @note Internal use only. Not part of the public API.
*/
#define J2735_INTERNAL_RAW_READ_LANE_DIRECTION(buf) \
J2735_READ_BITS((buf), 0U, J2735_INTERNAL_MAX_WIRE_BITS_LANE_DIRECTION)
J2735_READ_BITS((buf), 0U, J2735_INTERNAL_ROOT_SIZE_LANE_DIRECTION)

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

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

/**
* @brief Get all LaneDirection as a single uint8_t value.
Expand Down
17 changes: 6 additions & 11 deletions src/J2735_internal_DE_LaneSharing.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
*
* Fixed BIT STRING with size 10.
*
* Wire Format (11 bits total):
* Wire Format (10 bits total):
* ┌──────────────────────────────────────────────────────────────┐
* │ Bits 0-9 │
* ├──────────────────────────────────────────────────────────────┤
Expand All @@ -47,14 +47,10 @@
* ──────────────────────────────────────────────────────────────────────────────────────────
* Max wire size = 10 bits ≤ 56-bit READ_BITS limit.
* We read all 10 bits in ONE call, then use bit arithmetic to extract:
* - Extension bit at position 9 (MSB of 10-bit value)
* - Flags at positions 0-9 (extended) or shifted for non-extended
* - Flags at positions 0-9
*
* 10-bit read layout (left-justified from bit 0):
* Non-extended: [Ext=0][F0..F9][-1 garbage bits]
* bit9 8..-1 -2..0
* Extended: [Ext=1][nsnnwn:7][F0..F9]
* bit9 8..10 9..0
* [F0..F9] (10 flag bits, no extension marker)
*
* @todo Update the Doxygen to indicate [in] and [out] parameters
*/
Expand Down Expand Up @@ -109,7 +105,7 @@
* @note Internal use only. Not part of the public API.
*/
#define J2735_INTERNAL_RAW_READ_LANE_SHARING(buf) \
J2735_READ_BITS((buf), 0U, J2735_INTERNAL_MAX_WIRE_BITS_LANE_SHARING)
J2735_READ_BITS((buf), 0U, J2735_INTERNAL_ROOT_SIZE_LANE_SHARING)

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

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

/**
* @brief Get all LaneSharing as a single uint16_t value.
Expand Down
Loading