drivers.Elt_ch4.check_string

Serial-frame validator helper for the ELT CH4 (methane) sensor.

Standalone development utility for debugging the ASCII-to-numeric conversion of ELT CH4 sensor serial output. The module simulates a raw byte stream as it would be received by SensorBase.SensorBase.GenericSensor-style consumers via the production driver in drivers.Elt_ch4.Elt_ch4, and verifies that numeric values are correctly extracted from the ASCII payload.

This is a pure validation helper — it has no side effects on hardware and is not used in production. It is safe to import and execute in unit tests and doctests without a serial port present.

Example

>>> from drivers.Elt_ch4.check_string import convert_elt_data
>>> convert_elt_data("__1500_ppm")
string char:_ False
string char:_ False
string char:1 True
1
...
Sensor Val:1500

Note

Mirrors the parsing logic of drivers.Elt_ch4.Elt_ch4.Elt_ch4.convert_elt_data() but prints intermediate state to stdout for human inspection rather than returning a value.

Functions

convert_elt_data(→ None)

Parse an ASCII sensor frame and print the extracted ppm value.

main()

Run convert_elt_data() against a canned ELT byte payload.

Module Contents

drivers.Elt_ch4.check_string.convert_elt_data(string_data: str) None[source]

Parse an ASCII sensor frame and print the extracted ppm value.

Debugging counterpart to drivers.Elt_ch4.Elt_ch4.Elt_ch4.convert_elt_data(). Iterates over each character in string_data, prints whether the character is numeric, accumulates the digits into a single integer, and prints the resulting ppm value. Useful for verifying frame layout when bringing up a new sensor unit.

Parameters:

string_data (str) – UTF-8 decoded ASCII payload from the ELT sensor’s serial output (e.g. "__1500_ppm").

Returns:

The parsed value is printed to stdout; nothing is returned to the caller.

Return type:

None

Raises:

ValueError – If string_data contains no numeric characters, because int("") cannot be evaluated when computing final_sensor_value.

Example

>>> convert_elt_data("12")
string char:1 True
1
string char:2 True
2
Sensor Val:12

Note

Like the production parser, digits are concatenated rather than tokenised: "1 2" becomes 12, not 1 and 2.

drivers.Elt_ch4.check_string.main()[source]

Run convert_elt_data() against a canned ELT byte payload.

Reconstructs a representative ELT CH4 serial frame from a list of single-byte bytes objects, decodes the stream as UTF-8, and forwards the resulting string to convert_elt_data() for parsing. Acts as the script entry point so the file can be run with python check_string.py.

Parameters:

None.

Returns:

Output is produced via print inside convert_elt_data().

Return type:

None

Raises:

Example

>>> main()
string char:_ False
string char:_ False
string char:1 True
1
string char:5 True
5
string char:0 True
0
string char:0 True
0
string char:_ False
string char:p False
string char:p False
string char:m False
Sensor Val:1500

Note

The alternative list_raw_data definition kept as a comment documents a real-world capture that intentionally exercises the non-printable byte path; it is left in place for future regression checks.