Code examples, Header file & crc-16 function, 4 code examples – PNI SeaTRAX User Manual
Page 63: 1 header file & crc-16 function
PNI Sensor Corporation
DOC#1018154 r02
SeaTRAX User Manual
Page 58
7.4
Code Examples
The following example files, CommProtocol.h, CommProtocol.cp, SeaTRAX.h and
SeaTRAX.cp would be used together for proper communication with a SeaTRAX module.
Note: The following files are not included in the sample codes and need to be created by the user:
Processes.h & TickGenerator.h. The comments in the code explain what is needed to be sent or
received from these functions so the user can write this section f
or the user’s platform. For example,
with the TickGenerator.h, the user needs to write a routing that generates 10 msec ticks.
7.4.1
Header File & CRC-16 Function
// type declarations
typedef struct
{
UInt8 AcquisitionMode, FlushFilter;
Float32 AcquireDelay, SampleDelay;
} __attribute__ ((packed)) AcqParams;
typedef struct
{
Float32 MagCalScore;
Float32 reserve1;
Float32 AccelCalScore;
Float32 DistError;
Float32 TiltError;
Float32 TiltRange;
} __attribute__ ((packed)) MagCalScore;
enum
{
// Frame IDs (Commands)
kGetModInfo = 1,
// 1
kGetModInfoResp,
// 2
kSetDataComponents,
// 3
kGetData,
// 4
kGetDataResp,
// 5
kSetConfig,
// 6
kGetConfig,
// 7
kGetConfigResp,
// 8
kSave,
// 9
kStartCal,
// 10
kStopCal,
// 11
kSetFilters,
// 12
kGetFilters,
// 13
kGetFiltersResp,
// 14
kPowerDown,
// 15
kSaveDone,
// 16
kUserCalSampCount,
// 17
kMagCalScore,
// 18