Exceptions¶
All exceptions inherit from AlphaSignError for easy catch-all handling.
from alphasign.exceptions import (
AlphaSignError,
ConnectionError,
PacketError,
ChecksumError,
ProtocolError,
NAKError,
TimeoutError,
InvalidParameterError,
)
Hierarchy¶
AlphaSignError
├── ConnectionError — Serial port problems
├── PacketError — Packet construction failures
├── ChecksumError — Received checksum mismatch
├── ProtocolError — Unexpected protocol response
├── NAKError — Sign returned NAK
├── TimeoutError — Read operation timed out
└── InvalidParameterError — Bad argument to a command
NAKError¶
Carries error_status — the Serial Error Status Register byte returned by the sign.
from alphasign.exceptions import NAKError
from alphasign.protocol import SerialErrorStatus
try:
sign.send(pkt)
except NAKError as e:
print(f"Status register: 0x{e.error_status:02X}")
if e.error_status & SerialErrorStatus.CHECKSUM_ERROR:
print("Checksum error!")
SerialErrorStatus bit masks¶
from alphasign.protocol import SerialErrorStatus
SerialErrorStatus.ILLEGAL_COMMAND # 0x20
SerialErrorStatus.CHECKSUM_ERROR # 0x10
SerialErrorStatus.BUFFER_OVERFLOW # 0x08
SerialErrorStatus.SERIAL_TIMEOUT # 0x04
SerialErrorStatus.BIT_FRAMING # 0x02
SerialErrorStatus.PARITY # 0x01
SerialErrorStatus.DEFAULT # 0x40 (bit 6 always 1)