Signal Hound | Error Handling
Error Handling
All API functions return the type bbStatus. bbStatus is an enumerated type representing the success of a
given function call. The return values can be found in bb_api.h. There are three types of returned status
codes.
1) No error : Represented with value bbNoError.
2) Error, interrupting function execution : Represented by a return value suffixed with “Err”. All
Error statuses are negative.
3) Warning : Each function may return a warning code. The system will still function but potentially
in an undesirable state.
The best way to address issues is to check the return values of the API functions. An API function is
provided to return a string representation of given status code for easy debugging.
Device Connection Errors
The API issues errors when fatal connection issues are present during normal operation of the device.
The two major errors in this category are bbPacketFramingErr and bbDeviceConnectionErr. These
errors are reported on fetch routines, as these routines contain most major device I/O.
bbPacketFramingErr – Packet framing issues can occur in low power settings or when large interrupts
occur on the PC (typically large system interrupts). This error can be handled by manually cycling the
device power, or programmatically by using the preset routine.
bbDeviceConnectionErr – Device connection errors are the result of major USB issues most commonly
being the device has lost power (unplugged). These errors should be handled by completely closing the
software and cycling the device power, or, if you wish for the software to remain open, call the function
bbCloseDevice before cycling the device power and re-opening the device as usual.
Appendix
Code Examples
This section contains some C examples for interacting with a device. Each example will have a short
description describing the code in detail.
Common
All API functions return a status code responsible for reporting errors, warnings or success. It can be
helpful to write a macro or function for checking these status codes.
#define CHECK_BB_STATUS(status) \
if(status != bbNoError) { \
mylogErrorRoutine(bbGetErrorString(status)); \
doErrorHandlingRoutine(); \
}