Skip to content

common.linear_map ValueError handling #40

@vesuvisian

Description

@vesuvisian

I've got a bit of KLV metadata that I'm trying to parse, but I've run into an edge case that needs handled. Basically, since my sensor isn't actually flying, it's returning dummy data. For instance, it's first value is b'\x02\x08\x00\x00\x00\x00\x00\x00\x00\x00', which is a precision timestamp corresponding to the UTC epoch. That's fine, but when the parser gets to sensor latitude, the corresponding bytes are b'\x0D\x04\x80\x00\x00\x00'. That '\x80\x00\x00\x00' becomes an integer of -2147483648, which is outside the allowed domain of (-(2**31-1), 2**31-1). Providing such an extreme value is the sensor's way of signaling that it doesn't exist, but unfortunately this raises a generic ValueError (which was really difficult to trace down, requiring me to understand the code and go through it step by step). When such a domain error is encountered, I would propose that instead of raising a ValueError, the value is reported as None.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions