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/instructions/python_development.instructions.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ After creating or modifying any Python file, run these checks:
1. **Formatting**: `black tools/ --config tools/pyproject.toml`
2. **Style (ruff)**: `ruff check tools/ --fix --config tools/pyproject.toml`
3. **Type checking**: `python -m mypy tools/ --strict`
4. **Linting**: `python -m pylint tools/`
4. **Linting**: `python -m pylint tools/ --rcfile=tools/pyproject.toml`
5. **Style (flake8)**: `python -m flake8 tools/ --config tools/.flake8`
6. **Spelling**: `codespell tools/ --toml tools/pyproject.toml`
7. **Tests**: `python -m tools.run_tests`
Expand Down
7 changes: 5 additions & 2 deletions src/J2735_internal_DE_AllowedManeuvers.h
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,9 @@

#include "J2735_internal_common.h"

_Static_assert(J2735_BW_ALLOWED_MANEUVERS <= 56U,
"BIT STRING must fit in a single 56-bit J2735_READ_BITS call");

/* ============================================================================================== */
/* INTERNAL: Bit Position Constants */
/* */
Expand Down Expand Up @@ -153,15 +156,15 @@
/* PUBLIC API: AllowedManeuvers Accessors */
/* ============================================================================================== */
/**
* @brief Check if AllowedManeuvers is in extended form.
* @brief Check if AllowedManeuvers has an extension.
*
* AllowedManeuvers is a fixed-size BIT STRING with 12 bits.
* It does not have an extension marker, so this always returns 0 (false).
*
* @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) ((void)(buf), 0)
#define J2735_ALLOWED_MANEUVERS_HAS_EXTENSION(buf) ((void)(buf), 0)

/**
* @brief Get wire size of AllowedManeuvers in bits.
Expand Down
7 changes: 5 additions & 2 deletions src/J2735_internal_DE_BrakeAppliedStatus.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,9 @@

#include "J2735_internal_common.h"

_Static_assert(J2735_BW_BRAKE_APPLIED_STATUS <= 56U,
"BIT STRING must fit in a single 56-bit J2735_READ_BITS call");

/* ============================================================================================== */
/* INTERNAL: Bit Position Constants */
/* */
Expand Down Expand Up @@ -139,15 +142,15 @@
/* PUBLIC API: BrakeAppliedStatus Accessors */
/* ============================================================================================== */
/**
* @brief Check if BrakeAppliedStatus is in extended form.
* @brief Check if BrakeAppliedStatus has an extension.
*
* BrakeAppliedStatus is a fixed-size BIT STRING with 5 bits.
* It does not have an extension marker, so this always returns 0 (false).
*
* @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) ((void)(buf), 0)
#define J2735_BRAKE_APPLIED_STATUS_HAS_EXTENSION(buf) ((void)(buf), 0)

/**
* @brief Get wire size of BrakeAppliedStatus in bits.
Expand Down
21 changes: 12 additions & 9 deletions src/J2735_internal_DE_ExteriorLights.h
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@
* @internal
* @brief Root size of ExteriorLights in bits.
*/
#define J2735_INTERNAL_ROOT_SIZE_EXTERIOR_LIGHTS 9U
#define J2735_INTERNAL_ROOT_SIZE_BITS_EXTERIOR_LIGHTS 9U

/**
* @internal
Expand All @@ -103,6 +103,9 @@ _Static_assert(J2735_INTERNAL_MAX_WIRE_BITS_EXTERIOR_LIGHTS ==
J2735_INTERNAL_EXT_SIZE_EXTERIOR_LIGHTS),
"MAX_WIRE_BITS must equal ext_marker + nsnnwn + ext_size");

_Static_assert(J2735_INTERNAL_MAX_WIRE_BITS_EXTERIOR_LIGHTS <= 56U,
"BIT STRING must fit in a single 56-bit J2735_READ_BITS call");

/* ============================================================================================== */
/* INTERNAL: Bit Position Constants */
/* */
Expand Down Expand Up @@ -157,7 +160,7 @@ _Static_assert(J2735_INTERNAL_MAX_WIRE_BITS_EXTERIOR_LIGHTS ==
*
* @param[in] raw17 Value previously returned by J2735_INTERNAL_RAW_READ_EXTERIOR_LIGHTS().
* @return Non-zero (true) if extended form, zero (false) if root form.
* @note Internal use only. Use J2735_EXTERIOR_LIGHTS_IS_EXTENDED() for public API.
* @note Internal use only. Use J2735_EXTERIOR_LIGHTS_HAS_EXTENSION() for public API.
*/
#define J2735_INTERNAL_IS_EXTENSION_EXTERIOR_LIGHTS(raw17) \
(((raw17) >> (J2735_INTERNAL_MAX_WIRE_BITS_EXTERIOR_LIGHTS - 1U)) != 0U)
Expand Down Expand Up @@ -194,8 +197,8 @@ _Static_assert(J2735_INTERNAL_MAX_WIRE_BITS_EXTERIOR_LIGHTS ==
((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)) & \
((1ULL << J2735_INTERNAL_ROOT_SIZE_EXTERIOR_LIGHTS) - 1ULL))))
J2735_INTERNAL_ROOT_SIZE_BITS_EXTERIOR_LIGHTS)) & \
((1ULL << J2735_INTERNAL_ROOT_SIZE_BITS_EXTERIOR_LIGHTS) - 1ULL))))

/**
* @internal
Expand All @@ -217,7 +220,7 @@ _Static_assert(J2735_INTERNAL_MAX_WIRE_BITS_EXTERIOR_LIGHTS ==
* constants.
* @return 0 or 1 as uint8_t.
* @warning For non-extended messages, bit_pos >= 9 reads undefined garbage bits.
* Caller should verify IS_EXTENDED before accessing extension-only flags.
* Caller should verify HAS_EXTENSION before accessing extension-only flags.
* @note Internal use only. Use J2735_EXTERIOR_LIGHTS_GET_*() accessors for public API.
*/
#define J2735_INTERNAL_GET_ONE_EXTERIOR_LIGHTS(raw17, bit_pos) \
Expand All @@ -231,7 +234,7 @@ _Static_assert(J2735_INTERNAL_MAX_WIRE_BITS_EXTERIOR_LIGHTS ==
/* PUBLIC API: ExteriorLights Accessors */
/* ============================================================================================== */
/**
* @brief Check if ExteriorLights is in extended form.
* @brief Check if ExteriorLights has an extension.
*
* Extended form includes 9 flags (bits 0-8).
* Root form has only 9 flags (bits 0-8).
Expand All @@ -240,7 +243,7 @@ _Static_assert(J2735_INTERNAL_MAX_WIRE_BITS_EXTERIOR_LIGHTS ==
* @pre @p buf must point to valid ExteriorLights encoding with +7 byte padding.
* @return Non-zero (true) if extended (9 flags), zero (false) if root (9 flags).
*/
#define J2735_EXTERIOR_LIGHTS_IS_EXTENDED(buf) \
#define J2735_EXTERIOR_LIGHTS_HAS_EXTENSION(buf) \
J2735_INTERNAL_IS_EXTENSION_EXTERIOR_LIGHTS(J2735_INTERNAL_RAW_READ_EXTERIOR_LIGHTS(buf))

/**
Expand All @@ -255,7 +258,7 @@ _Static_assert(J2735_INTERNAL_MAX_WIRE_BITS_EXTERIOR_LIGHTS ==
#define J2735_EXTERIOR_LIGHTS_SIZE(buf) \
(J2735_INTERNAL_IS_EXTENSION_EXTERIOR_LIGHTS(J2735_INTERNAL_RAW_READ_EXTERIOR_LIGHTS(buf)) \
? J2735_INTERNAL_MAX_WIRE_BITS_EXTERIOR_LIGHTS \
: (J2735_INTERNAL_EXTENSION_MARKER_BITS + J2735_INTERNAL_ROOT_SIZE_EXTERIOR_LIGHTS))
: (J2735_INTERNAL_EXTENSION_MARKER_BITS + J2735_INTERNAL_ROOT_SIZE_BITS_EXTERIOR_LIGHTS))

/**
* @brief Get all ExteriorLights as a single uint16_t value.
Expand All @@ -268,7 +271,7 @@ _Static_assert(J2735_INTERNAL_MAX_WIRE_BITS_EXTERIOR_LIGHTS ==
* @param[in] buf Pointer to the start of the ExteriorLights UPER encoding (const uint8_t*).
* @pre @p buf must point to valid ExteriorLights encoding with +7 byte padding.
* @return Right-aligned flag value (uint16_t). Bit 0 of result = first named bit.
* @note Use J2735_EXTERIOR_LIGHTS_IS_EXTENDED() to determine if bit 9 is meaningful.
* @note Use J2735_EXTERIOR_LIGHTS_HAS_EXTENSION() to determine if bit 9 is meaningful.
*/
#define J2735_EXTERIOR_LIGHTS_GET(buf) \
J2735_INTERNAL_GET_ALL_EXTERIOR_LIGHTS(J2735_INTERNAL_RAW_READ_EXTERIOR_LIGHTS(buf))
Expand Down
7 changes: 5 additions & 2 deletions src/J2735_internal_DE_GNSSstatus.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,9 @@

#include "J2735_internal_common.h"

_Static_assert(J2735_BW_GNSS_STATUS <= 56U,
"BIT STRING must fit in a single 56-bit J2735_READ_BITS call");

/* ============================================================================================== */
/* INTERNAL: Bit Position Constants */
/* */
Expand Down Expand Up @@ -144,15 +147,15 @@
/* PUBLIC API: GNSSstatus Accessors */
/* ============================================================================================== */
/**
* @brief Check if GNSSstatus is in extended form.
* @brief Check if GNSSstatus has an extension.
*
* GNSSstatus is a fixed-size BIT STRING with 8 bits.
* It does not have an extension marker, so this always returns 0 (false).
*
* @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) ((void)(buf), 0)
#define J2735_GNSS_STATUS_HAS_EXTENSION(buf) ((void)(buf), 0)

/**
* @brief Get wire size of GNSSstatus in bits.
Expand Down
7 changes: 5 additions & 2 deletions src/J2735_internal_DE_LaneDirection.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,9 @@

#include "J2735_internal_common.h"

_Static_assert(J2735_BW_LANE_DIRECTION <= 56U,
"BIT STRING must fit in a single 56-bit J2735_READ_BITS call");

/* ============================================================================================== */
/* INTERNAL: Bit Position Constants */
/* */
Expand Down Expand Up @@ -133,15 +136,15 @@
/* PUBLIC API: LaneDirection Accessors */
/* ============================================================================================== */
/**
* @brief Check if LaneDirection is in extended form.
* @brief Check if LaneDirection has an extension.
*
* LaneDirection is a fixed-size BIT STRING with 2 bits.
* It does not have an extension marker, so this always returns 0 (false).
*
* @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) ((void)(buf), 0)
#define J2735_LANE_DIRECTION_HAS_EXTENSION(buf) ((void)(buf), 0)

/**
* @brief Get wire size of LaneDirection in bits.
Expand Down
7 changes: 5 additions & 2 deletions src/J2735_internal_DE_LaneSharing.h
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,9 @@

#include "J2735_internal_common.h"

_Static_assert(J2735_BW_LANE_SHARING <= 56U,
"BIT STRING must fit in a single 56-bit J2735_READ_BITS call");

/* ============================================================================================== */
/* INTERNAL: Bit Position Constants */
/* */
Expand Down Expand Up @@ -148,15 +151,15 @@
/* PUBLIC API: LaneSharing Accessors */
/* ============================================================================================== */
/**
* @brief Check if LaneSharing is in extended form.
* @brief Check if LaneSharing has an extension.
*
* LaneSharing is a fixed-size BIT STRING with 10 bits.
* It does not have an extension marker, so this always returns 0 (false).
*
* @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) ((void)(buf), 0)
#define J2735_LANE_SHARING_HAS_EXTENSION(buf) ((void)(buf), 0)

/**
* @brief Get wire size of LaneSharing in bits.
Expand Down
22 changes: 13 additions & 9 deletions src/J2735_internal_DE_PersonalAssistive.h
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@
* @internal
* @brief Root size of PersonalAssistive in bits.
*/
#define J2735_INTERNAL_ROOT_SIZE_PERSONAL_ASSISTIVE 6U
#define J2735_INTERNAL_ROOT_SIZE_BITS_PERSONAL_ASSISTIVE 6U

/**
* @internal
Expand All @@ -100,6 +100,9 @@ _Static_assert(J2735_INTERNAL_MAX_WIRE_BITS_PERSONAL_ASSISTIVE ==
J2735_INTERNAL_EXT_SIZE_PERSONAL_ASSISTIVE),
"MAX_WIRE_BITS must equal ext_marker + nsnnwn + ext_size");

_Static_assert(J2735_INTERNAL_MAX_WIRE_BITS_PERSONAL_ASSISTIVE <= 56U,
"BIT STRING must fit in a single 56-bit J2735_READ_BITS call");

/* ============================================================================================== */
/* INTERNAL: Bit Position Constants */
/* */
Expand Down Expand Up @@ -151,7 +154,7 @@ _Static_assert(J2735_INTERNAL_MAX_WIRE_BITS_PERSONAL_ASSISTIVE ==
*
* @param[in] raw14 Value previously returned by J2735_INTERNAL_RAW_READ_PERSONAL_ASSISTIVE().
* @return Non-zero (true) if extended form, zero (false) if root form.
* @note Internal use only. Use J2735_PERSONAL_ASSISTIVE_IS_EXTENDED() for public API.
* @note Internal use only. Use J2735_PERSONAL_ASSISTIVE_HAS_EXTENSION() for public API.
*/
#define J2735_INTERNAL_IS_EXTENSION_PERSONAL_ASSISTIVE(raw14) \
(((raw14) >> (J2735_INTERNAL_MAX_WIRE_BITS_PERSONAL_ASSISTIVE - 1U)) != 0U)
Expand Down Expand Up @@ -188,8 +191,8 @@ _Static_assert(J2735_INTERNAL_MAX_WIRE_BITS_PERSONAL_ASSISTIVE ==
((uint8_t)((raw14) & ((1ULL << J2735_INTERNAL_EXT_SIZE_PERSONAL_ASSISTIVE) - 1ULL))) \
: /* Non-ext: bits 12..7 = 6 bits */ \
((uint8_t)(((raw14) >> (J2735_INTERNAL_MAX_WIRE_BITS_PERSONAL_ASSISTIVE - 1U - \
J2735_INTERNAL_ROOT_SIZE_PERSONAL_ASSISTIVE)) & \
((1ULL << J2735_INTERNAL_ROOT_SIZE_PERSONAL_ASSISTIVE) - 1ULL))))
J2735_INTERNAL_ROOT_SIZE_BITS_PERSONAL_ASSISTIVE)) & \
((1ULL << J2735_INTERNAL_ROOT_SIZE_BITS_PERSONAL_ASSISTIVE) - 1ULL))))

/**
* @internal
Expand All @@ -211,7 +214,7 @@ _Static_assert(J2735_INTERNAL_MAX_WIRE_BITS_PERSONAL_ASSISTIVE ==
* constants.
* @return 0 or 1 as uint8_t.
* @warning For non-extended messages, bit_pos >= 6 reads undefined garbage bits.
* Caller should verify IS_EXTENDED before accessing extension-only flags.
* Caller should verify HAS_EXTENSION before accessing extension-only flags.
* @note Internal use only. Use J2735_PERSONAL_ASSISTIVE_GET_*() accessors for public API.
*/
#define J2735_INTERNAL_GET_ONE_PERSONAL_ASSISTIVE(raw14, bit_pos) \
Expand All @@ -227,7 +230,7 @@ _Static_assert(J2735_INTERNAL_MAX_WIRE_BITS_PERSONAL_ASSISTIVE ==
/* PUBLIC API: PersonalAssistive Accessors */
/* ============================================================================================== */
/**
* @brief Check if PersonalAssistive is in extended form.
* @brief Check if PersonalAssistive has an extension.
*
* Extended form includes 6 flags (bits 0-5).
* Root form has only 6 flags (bits 0-5).
Expand All @@ -236,7 +239,7 @@ _Static_assert(J2735_INTERNAL_MAX_WIRE_BITS_PERSONAL_ASSISTIVE ==
* @pre @p buf must point to valid PersonalAssistive encoding with +7 byte padding.
* @return Non-zero (true) if extended (6 flags), zero (false) if root (6 flags).
*/
#define J2735_PERSONAL_ASSISTIVE_IS_EXTENDED(buf) \
#define J2735_PERSONAL_ASSISTIVE_HAS_EXTENSION(buf) \
J2735_INTERNAL_IS_EXTENSION_PERSONAL_ASSISTIVE(J2735_INTERNAL_RAW_READ_PERSONAL_ASSISTIVE(buf))

/**
Expand All @@ -251,7 +254,8 @@ _Static_assert(J2735_INTERNAL_MAX_WIRE_BITS_PERSONAL_ASSISTIVE ==
#define J2735_PERSONAL_ASSISTIVE_SIZE(buf) \
(J2735_INTERNAL_IS_EXTENSION_PERSONAL_ASSISTIVE(J2735_INTERNAL_RAW_READ_PERSONAL_ASSISTIVE(buf)) \
? J2735_INTERNAL_MAX_WIRE_BITS_PERSONAL_ASSISTIVE \
: (J2735_INTERNAL_EXTENSION_MARKER_BITS + J2735_INTERNAL_ROOT_SIZE_PERSONAL_ASSISTIVE))
: (J2735_INTERNAL_EXTENSION_MARKER_BITS + \
J2735_INTERNAL_ROOT_SIZE_BITS_PERSONAL_ASSISTIVE))

/**
* @brief Get all PersonalAssistive as a single uint8_t value.
Expand All @@ -264,7 +268,7 @@ _Static_assert(J2735_INTERNAL_MAX_WIRE_BITS_PERSONAL_ASSISTIVE ==
* @param[in] buf Pointer to the start of the PersonalAssistive UPER encoding (const uint8_t*).
* @pre @p buf must point to valid PersonalAssistive encoding with +7 byte padding.
* @return Right-aligned flag value (uint8_t). Bit 0 of result = first named bit.
* @note Use J2735_PERSONAL_ASSISTIVE_IS_EXTENDED() to determine if bit 6 is meaningful.
* @note Use J2735_PERSONAL_ASSISTIVE_HAS_EXTENSION() to determine if bit 6 is meaningful.
*/
#define J2735_PERSONAL_ASSISTIVE_GET(buf) \
J2735_INTERNAL_GET_ALL_PERSONAL_ASSISTIVE(J2735_INTERNAL_RAW_READ_PERSONAL_ASSISTIVE(buf))
Expand Down
Loading
Loading