|
ra8-firmware 0.1.0
Bare-metal firmware for the Renesas RA8 family (RA8D2 / RA8P1)
|
Test-access surface for ra8_modem_at internal helpers (MC/DC). More...
Go to the source code of this file.
Enumerations | |
| enum | ra8_modem_line_kind_t : uint8_t { k_ra8_modem_line_kind_empty = 0U , k_ra8_modem_line_kind_echo = 1U , k_ra8_modem_line_kind_urc = 2U , k_ra8_modem_line_kind_final_ok = 3U , k_ra8_modem_line_kind_final_err = 4U , k_ra8_modem_line_kind_payload = 5U } |
| Result of processing a single completed line. More... | |
Functions | |
| ra8_modem_line_kind_t | priv_modem_classify (const char *line, const char *cmd_echo, const char *expected_response) |
| Classify a complete (NUL-terminated) line for the FSM. | |
| uint16_t | priv_modem_str_len (const char *s) |
| NUL-terminated string length, capped at UINT16_MAX. | |
| uint8_t | priv_modem_starts_with (const char *hay, const char *needle) |
| Return 1 iff hay begins with needle. | |
| uint8_t | priv_modem_str_eq (const char *a, const char *b) |
| Return 1 iff a and b are byte-for-byte equal. | |
| void | priv_modem_capture_line (const char *line, char *capture, size_t capture_len, size_t *used) |
| Append a NUL-terminated line into capture (with newline sep). | |
| uint8_t | priv_modem_reset_line_should_clear (const void *line_buf, uint16_t line_buf_len) |
Pure (state-free) reimplementation of internal_reset_line's line-227 buffer-clear guard. | |
| uint8_t | priv_modem_payload_prefix_matches (const char *line, const char *expected_response) |
| Pure sibling of the line-573 payload-prefix AND-decision. | |
| uint8_t | priv_modem_capture_should_clear (const void *capture, size_t capture_len) |
| Pure sibling of the line-664 capture-buffer-init AND-decision. | |
Test-access surface for ra8_modem_at internal helpers (MC/DC).
Not part of the public API. Tests under tests/ MAY include this header to drive compound boolean decisions that sit in TU-private helpers behind the public ra8_modem_at facade. See CLAUDE.md "Test access to internal symbols (MC/DC scope)".
Definition in file ra8_modem_at_internal.h.
| enum ra8_modem_line_kind_t : uint8_t |
Result of processing a single completed line.
Mirror of the TU-local enum in ra8_modem_at.c. Exposed so tests can read the return value of internal_classify().
Definition at line 32 of file ra8_modem_at_internal.h.
| void priv_modem_capture_line | ( | const char * | line, |
| char * | capture, | ||
| size_t | capture_len, | ||
| size_t * | used ) |
Append a NUL-terminated line into capture (with newline sep).
Promoted from TU-private static linkage so tests can drive the line-469 NULL+len AND-decision under -fcoverage-mcdc. Production callers must keep using the public facade.
| [in] | line | NUL-terminated line to append (must be non-NULL). |
| [in,out] | capture | Caller-owned buffer (NULL allowed; no-op). |
| [in] | capture_len | Capacity of capture in bytes. |
| [in,out] | used | Bytes already populated; updated on append. |
See implementation.
| [in] | line | See implementation. |
| [in] | capture | See implementation. |
| [in] | capture_len | See implementation. |
| [in] | used | See implementation. |
Definition at line 578 of file ra8_modem_at.c.
References internal_append_ch().
Referenced by internal_handle_line().
| uint8_t priv_modem_capture_should_clear | ( | const void * | capture, |
| size_t | capture_len ) |
Pure sibling of the line-664 capture-buffer-init AND-decision.
Returns true iff both capture is non-NULL and capture_len is greater than zero, mirroring the AND-decision in internal_wait_response at line 664 of ra8_modem_at.c ((capture != nullptr) && (capture_len > 0U)). The production decision controls a single byte-clear of capture[0] = '\\0'; all four input combinations are exposed here so MC/DC can be driven from a host test (the public send_cmd_capture API rejects capture_len == 0 at the entry guard before internal_wait_response is reached).
| [in] | capture | Caller-owned capture buffer (NULL allowed). |
| [in] | capture_len | Capacity of capture in bytes. |
| 1 | capture is non-NULL AND capture_len > 0. |
| 0 | Either condition fails. |
Pure sibling of the line-664 capture-buffer-init AND-decision.
Holds the AND-decision that gates the one-shot capture[0] = '\\0' initialisation in internal_wait_response. Promoted from inline-in-callsite to a TU-external helper so all four input combinations are reachable from a host test (the public send_cmd_capture API rejects capture_len == 0 at the entry guard, so the inline form was structurally limited to (NULL, 0) and (non-NULL, >0)).
| [in] | capture | Caller-owned capture buffer (NULL allowed). |
| [in] | capture_len | Capacity of capture in bytes. |
| 1 | Both conditions hold. |
| 0 | Either condition fails. |
Definition at line 304 of file ra8_modem_at.c.
Referenced by internal_wait_response().
| ra8_modem_line_kind_t priv_modem_classify | ( | const char * | line, |
| const char * | cmd_echo, | ||
| const char * | expected_response ) |
Classify a complete (NUL-terminated) line for the FSM.
Promoted from TU-private static linkage so tests can drive its line-344 compound decision (cmd_echo != nullptr) && (str_eq(line, cmd_echo) != 0U) under -fcoverage-mcdc. Production callers MUST keep using the public ra8_modem_at facade.
| [in] | line | NUL-terminated input line. |
| [in] | cmd_echo | Optional expected command echo (NULL = ignore). |
| [in] | expected_response | Optional expected response prefix. |
| k_ra8_modem_line_kind_empty | Line was empty. |
| k_ra8_modem_line_kind_echo | Line matched cmd_echo exactly. |
| other | Other classification (URC / final / payload). |
The expected-prefix and command-echo arguments are caller-supplied because they vary per command invocation. URC dispatch happens inside this helper so the caller does not need to know about it.
| [in] | line | NUL-terminated received line. |
| [in] | cmd_echo | Command we sent (for echo detection), may be NULL when not awaiting echo. |
| [in] | expected_response | Optional caller-specified prefix. |
| k_ra8_ok | Operation succeeded. |
Definition at line 438 of file ra8_modem_at.c.
References internal_classify_final(), internal_dispatch_urc(), k_ra8_modem_line_kind_echo, k_ra8_modem_line_kind_empty, k_ra8_modem_line_kind_final_err, k_ra8_modem_line_kind_final_ok, k_ra8_modem_line_kind_payload, k_ra8_modem_line_kind_urc, priv_modem_starts_with(), and priv_modem_str_eq().
Referenced by internal_pump_one(), and ra8_modem_at_poll().
| uint8_t priv_modem_payload_prefix_matches | ( | const char * | line, |
| const char * | expected_response ) |
Pure sibling of the line-573 payload-prefix AND-decision.
Returns true iff expected_response is non-NULL, non-empty, and line begins with expected_response. This mirrors the three-condition short-circuit AND in internal_handle_line at line 573 of ra8_modem_at.c ((expected_response != nullptr) && (expected_response[0] != '\0')
&& (priv_modem_starts_with(line, expected_response) !=
0U)). The production helper consults s_mod state to mutate seen_exp; this pure sibling exposes the boolean predicate alone so all four short-circuit MC/DC vectors are reachable from a host test.
| [in] | line | NUL-terminated input line (must be non-NULL). |
| [in] | expected_response | Optional NUL-terminated expected prefix. |
| 1 | All three conditions hold (line begins with the prefix). |
| 0 | Any one of the three conditions fails (short-circuited). |
Pure sibling of the line-573 payload-prefix AND-decision.
Holds the three-condition short-circuit AND that classifies a payload-kind line as matching the caller-supplied expected_response prefix. Promoted from inline-in-callsite to a TU-external helper so all four short-circuit MC/DC vectors can be driven from a host test (the public-API path through send_cmd / send_cmd_capture reaches only a subset of the four input combinations).
| [in] | line | NUL-terminated input line (must be non-NULL). |
| [in] | expected_response | Optional NUL-terminated expected prefix. |
| 1 | expected_response != NULL && expected_response[0] != '\0' && starts_with(line, expected_response). |
| 0 | Any one of the three conditions fails. |
Definition at line 271 of file ra8_modem_at.c.
References priv_modem_starts_with().
Referenced by internal_handle_line().
| uint8_t priv_modem_reset_line_should_clear | ( | const void * | line_buf, |
| uint16_t | line_buf_len ) |
Pure (state-free) reimplementation of internal_reset_line's line-227 buffer-clear guard.
Returns true iff line_buf is non-NULL and line_buf_len > 0 – the exact decision exercised by the production helper internal_reset_line at line 227. The state-reading wrapper passes through s_mod.cfg.line_buf / s_mod.cfg.line_buf_len, both of which are gated by the init validator. This pure sibling exists so tests can drive the AND under -fcoverage-mcdc with all four input combinations.
| [in] | line_buf | Caller-owned line buffer (NULL when absent). |
| [in] | line_buf_len | Capacity of line_buf in bytes. |
| true | Both arguments are non-NULL / non-zero (would clear). |
| false | Either argument signals "no buffer installed". |
Pure (state-free) reimplementation of internal_reset_line's line-227 buffer-clear guard.
Promoted as a free function so tests can drive both (line_buf, line_buf_len) input combinations directly under -fcoverage-mcdc on the production source. The state- reading wrapper internal_reset_line forwards to this helper with s_mod.cfg.line_buf and s_mod.cfg.line_buf_len.
| [in] | line_buf | Caller-owned buffer pointer (NULL allowed). |
| [in] | line_buf_len | Capacity of line_buf in bytes. |
| 1 | line_buf!=NULL and line_buf_len>0. |
| 0 | Either argument signals "no buffer". |
Definition at line 238 of file ra8_modem_at.c.
Referenced by internal_reset_line().
| uint8_t priv_modem_starts_with | ( | const char * | hay, |
| const char * | needle ) |
Return 1 iff hay begins with needle.
Promoted from TU-private static linkage so tests can drive the inner compare branch on the production source.
| [in] | hay | NUL-terminated haystack. |
| [in] | needle | NUL-terminated prefix. |
| 1 | hay begins with needle (or needle is empty). |
| 0 | needle differs from the leading bytes of hay. |
Return 1 iff hay begins with needle.
| [in] | hay | NUL-terminated haystack. |
| [in] | needle | NUL-terminated prefix. |
See implementation.
| k_ra8_ok | Operation succeeded. |
Definition at line 149 of file ra8_modem_at.c.
Referenced by internal_classify_final(), internal_dispatch_urc(), priv_modem_classify(), and priv_modem_payload_prefix_matches().
| uint8_t priv_modem_str_eq | ( | const char * | a, |
| const char * | b ) |
Return 1 iff a and b are byte-for-byte equal.
Promoted from TU-private static linkage so tests can drive the line-177 loop AND and the line-184 terminator AND on the production source under -fcoverage-mcdc.
| [in] | a | NUL-terminated string. |
| [in] | b | NUL-terminated string. |
| 1 | Both strings are byte-for-byte equal including length. |
| 0 | Strings differ in length or any byte. |
Return 1 iff a and b are byte-for-byte equal.
| [in] | a | First string. |
| [in] | b | Second string. |
See implementation.
| k_ra8_ok | Operation succeeded. |
Definition at line 177 of file ra8_modem_at.c.
Referenced by internal_classify_final(), internal_urc_replace(), and priv_modem_classify().
| uint16_t priv_modem_str_len | ( | const char * | s | ) |
NUL-terminated string length, capped at UINT16_MAX.
Promoted from TU-private static linkage so tests can drive its line-124 compound decision under -fcoverage-mcdc. Production callers must keep using the public facade.
| [in] | s | NUL-terminated input string (must be non-NULL). |
| 0 | s[0] is the NUL terminator (empty string). |
NUL-terminated string length, capped at UINT16_MAX.
| [in] | s | NUL-terminated input string (must be non-NULL). |
See implementation.
| k_ra8_ok | Operation succeeded. |
Definition at line 124 of file ra8_modem_at.c.
Referenced by ra8_modem_at_register_unsolicited_handler().