Unknown Values

From Phidgets Support
Revision as of 20:08, 28 July 2021 by Mparadis (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search


Most Phidgets will have a number of states where the value from the sensor is unknown. These are commonly seen in the time between when a sensor is attached and when it reports its first data, or when the sensor reading goes outside the valid range for that sensor. During these times, any attempts to poll the unknown value will result in an Unknown or Invalid Value error.

These errors can be easily detected in the flow of programs written in languages that throw exceptions such as C#, Java and Python. In languages like C, where error codes must be explicitly checked, it is imperative to check the error code when getting the value of any parameter to ensure it is valid.

When getting a parameter of unknown value, the value retrieved by the function will be seemingly nonsensical, and well outside the normal range for that value. This table describes the constants used to convey unknown values:

Name Value Description
PUNK_BOOL 2 Unknown Boolean
PUNK_INT8 127 Unknown Short (8-bit)
PUNK_UINT8 255 Unknown Short (8-bit unsigned)
PUNK_INT16 32,767 Unknown Short (16-bit)
PUNK_UINT16 65,535 Unknown Short (16-bit unsigned)
PUNK_INT32 2,147,483,647 Unknown Integer (32-bit)
PUNK_UINT32 4,294,967,295 Unknown Integer (32-bit unsigned)
PUNK_INT64 9,223,372,036,854,775,807 Unknown Integer (64-bit)
PUNK_UINT64 1,844,6744,073,709,551,615 Unknown Integer (64-bit unsigned)
PUNK_DBL 1e300 Unknown Double
PUNK_FLT 1e30 Unknown Float
PUNK_ENUM 2,147,483,647 Unknown Enumeration
PUNK_SIZE PUNK_UINT64 on 64-bit PUNK_UINT32 on 32-bit Unknown size_t