haniwers.v1.port.model#

Data structures representing port management information.

Contains the core data classes for port testing and diagnostics:

  • DetectorData: OSECHI detector sensor readings

  • FlashInfo: ESP32 flash chip information

  • TestResult: Port connectivity test results

Module Contents#

Classes#

DetectorData

One line of data from OSECHI detector.

FlashInfo

ESP32 flash chip information from esptool.

TestResult

Result of a port connectivity test.

API#

class haniwers.v1.port.model.DetectorData#

One line of data from OSECHI detector.

Format: “top mid btm adc tmp atm hmd” Example: “2 0 0 936 27.37 100594.35 41.43”

Fields: top: Top layer hit count (0-10) mid: Middle layer hit count (0-10) btm: Bottom layer hit count (0-10) adc: ADC value (0-1023, 10-bit) tmp: Temperature in °C (15-35) atm: Atmospheric pressure in Pa (95000-105000) hmd: Humidity in % (0-100)

top: int#

None

mid: int#

None

btm: int#

None

adc: int#

None

tmp: float#

None

atm: float#

None

hmd: float#

None

classmethod from_line(line: str) haniwers.v1.port.model.DetectorData#

Parse a line of detector data.

Args: line: Space-separated values string

Returns: DetectorData instance

Raises: ValueError: If line format is invalid

Example: >>> data = DetectorData.from_line(“2 0 0 936 27.37 100594.35 41.43”) >>> data.tmp 27.37

is_valid() bool#

Check if values are within expected ranges.

Returns: True if all values are reasonable, False otherwise

class haniwers.v1.port.model.FlashInfo#

ESP32 flash chip information from esptool.

Stores flash chip details obtained via esptool flash_id command.

Fields: manufacturer: Flash chip manufacturer ID (hex string) device: Flash chip device ID (hex string) flash_size: Detected flash size (e.g., “8MB”) flash_voltage: Flash voltage setting (e.g., “3.3V”) chip_type: ESP32 chip variant (e.g., “ESP32-D0WD-V3”) crystal: Crystal frequency (e.g., “40MHz”) mac_address: MAC address of the chip

manufacturer: Optional[str]#

None

device: Optional[str]#

None

flash_size: Optional[str]#

None

flash_voltage: Optional[str]#

None

chip_type: Optional[str]#

None

crystal: Optional[str]#

None

mac_address: Optional[str]#

None

is_healthy() bool#

Check if flash chip communication is successful.

Returns: True if flash chip responds normally, False otherwise

A manufacturer ID of “ff” indicates communication failure.

get_diagnosis() str#

Get diagnostic message based on flash chip status.

Returns: Human-readable diagnostic message with recommendations

class haniwers.v1.port.model.TestResult#

Result of a port connectivity test.

Stores whether the test succeeded and why.

Fields: success: True if test passed, False otherwise message: Human-readable result message response_time: Time to receive data in seconds (optional) data_sample: First line of data received (optional) error_type: Error category if failed (optional)

success: bool#

None

message: str#

None

response_time: Optional[float]#

None

data_sample: Optional[str]#

None

error_type: Optional[str]#

None

classmethod success_result(response_time: float, data_sample: str) haniwers.v1.port.model.TestResult#

Create a successful test result.

Args: response_time: Time taken to receive data (seconds) data_sample: First line of valid data

Returns: TestResult with success=True

classmethod failure_result(error_type: str, message: str) haniwers.v1.port.model.TestResult#

Create a failed test result.

Args: error_type: Category of error (timeout, permission, etc.) message: Human-readable error explanation

Returns: TestResult with success=False

format_for_display() str#

Format result for user-friendly display.

Returns: Multi-line formatted string with all relevant info