Garmin Fleet Management Controller  2.19.0
garmin_types.h
Go to the documentation of this file.
1 /*********************************************************************
2 *
3 * HEADER NAME:
4 * garmin_types.h - Data structures, types, and constants common
5 * to Garmin protocols
6 *
7 * Copyright 2008-2009 by Garmin Ltd. or its subsidiaries.
8 *---------------------------------------------------------------------
9 * $NoKeywords$
10 *********************************************************************/
11 #ifndef GARMIN_TYPES_H
12 #define GARMIN_TYPES_H
13 
14 #include "util_macros.h"
15 #include <limits.h>
16 
18 #define MIN_PACKET_SIZE ( 1 + 1 + 1 + 0 + 1 + 1 + 1 )
19 
21 #define MAX_PAYLOAD_SIZE ( 255 )
22 
31 #define MAX_PACKET_SIZE ( 1 + 1 + 2 * 1 + 2 * MAX_PAYLOAD_SIZE + 2 * 1 + 1 + 1 )
32 
34 #define SIZE_OF_HEADER ( 1 + 1 + 1 )
35 
37 #define SIZE_OF_FOOTER (1 + 1 )
38 
39 #define ID_ETX_BYTE 3
40 #define ID_ACK_BYTE 6
41 #define ID_DLE_BYTE 16
42 #define ID_NAK_BYTE 21
43 
44 #ifndef TRUE
45 #define TRUE 1
46 #define FALSE 0
47 #endif
48 /*--------------------------------------------------------------------
49  FUNDAMENTAL TYPES
50 --------------------------------------------------------------------*/
52 typedef unsigned char boolean;
53 
55 typedef signed char sint8;
57 typedef signed short int sint16;
59 typedef signed long int sint32;
60 
62 typedef unsigned char uint8;
64 typedef unsigned short int uint16;
66 typedef unsigned long int uint32;
67 
70 typedef float float32;
71 
74 typedef double float64;
75 
76 // Verify that the primitive types have the correct size. The C
77 // standard indicates that sizeof() returns units of char, so we must
78 // also verify that a char is 8 bits. If any of these asserts fail, the
79 // app would not be conforming to the protocol, and changes would be needed.
80 _compiler_assert( CHAR_BIT == 8, _FMI_H_ );
81 _compiler_assert( sizeof( boolean ) == 1, _FMI_H_ );
82 _compiler_assert( sizeof( uint8 ) == 1, _FMI_H_ );
83 _compiler_assert( sizeof( sint8 ) == 1, _FMI_H_ );
84 _compiler_assert( sizeof( uint16 ) == 2, _FMI_H_ );
85 _compiler_assert( sizeof( sint16 ) == 2, _FMI_H_ );
86 _compiler_assert( sizeof( uint32 ) == 4, _FMI_H_ );
87 _compiler_assert( sizeof( sint32 ) == 4, _FMI_H_ );
88 _compiler_assert( sizeof( float32 ) == 4, _FMI_H_ );
89 _compiler_assert( sizeof( float64 ) == 8, _FMI_H_ );
90 
97 typedef uint32 time_type;
98 
101 typedef uint8 id_type;
102 
105  {
109  };
110 
113  {
116  };
117 
125  {
128  };
129 
136  {
139  };
140 
144  {
147  };
148 
151  {
152  struct _date
153  {
157  } date;
158  struct _time
159  {
163  } time;
164  };
165 
166 #endif
uint8 second
second (0-59)
Definition: garmin_types.h:162
uint8 minute
minute (0-59)
Definition: garmin_types.h:161
Basic utility macros for low-level functions.
uint8 id_type
Garmin packet ID.
Definition: garmin_types.h:101
Time portion of data type.
Definition: garmin_types.h:158
uint8 size
Size of payload.
Definition: garmin_types.h:108
unsigned char boolean
8-bit value representing FALSE (0) or TRUE (nonzero)
Definition: garmin_types.h:52
signed short int sint16
16-bit signed integer
Definition: garmin_types.h:57
Date & time data type with separate fields for month, day, year, hour, minute, and second...
Definition: garmin_types.h:150
double float64
64-bit IEEE-format floating point data. (1 sign bit, 11 exponent bits, and 52 mantissa bits) ...
Definition: garmin_types.h:74
sint32 lat
latitude in semicircles
Definition: garmin_types.h:126
float64 lat
latitude in radians, positive is north
Definition: garmin_types.h:137
uint8 dle
DLE byte.
Definition: garmin_types.h:106
float float32
32-bit IEEE-format floating point data. (1 sign bit, 8 exponent bits, and 23 mantissa bits) ...
Definition: garmin_types.h:70
Indicates a latitude and longitude in radians.
Definition: garmin_types.h:135
uint8 etx
ETX byte.
Definition: garmin_types.h:115
sint32 week_number_days
Days since December 31st, 1989 to beginning of week (i.e., this is a Sunday)
Definition: garmin_types.h:145
signed long int sint32
32-bit signed integer
Definition: garmin_types.h:59
uint8 dle
DLE byte.
Definition: garmin_types.h:114
unsigned short int uint16
16-bit unsigned integer
Definition: garmin_types.h:64
_compiler_assert(CHAR_BIT==8, _FMI_H_)
uint16 year
Real year (1990 means 1990!)
Definition: garmin_types.h:156
signed char sint8
8-bit signed integer
Definition: garmin_types.h:55
Indicates a latitude and longitude in semicircles.
Definition: garmin_types.h:124
uint8 month
month (1-12)
Definition: garmin_types.h:154
unsigned char uint8
8-bit unsigned integer
Definition: garmin_types.h:62
The packet header (the bytes before the payload)
Definition: garmin_types.h:104
uint8 id
Garmin packet ID.
Definition: garmin_types.h:107
float64 lon
longitude in radians, positive is east
Definition: garmin_types.h:138
sint32 time_of_week
Seconds since 12:00 AM Sunday.
Definition: garmin_types.h:146
unsigned long int uint32
32-bit unsigned integer
Definition: garmin_types.h:66
sint32 lon
longitude in semicircles
Definition: garmin_types.h:127
uint32 time_type
Absolute time (number of seconds since 12/31/1989 12:00 am UTC)
Definition: garmin_types.h:97
Date portion of data type.
Definition: garmin_types.h:152
sint16 hour
hour (0-65535), range required for correct ETE conversion
Definition: garmin_types.h:160
The packet footer (the bytes after the payload and checksum)
Definition: garmin_types.h:112
Encapsulates the fields of a GPS time for conversion.
Definition: garmin_types.h:143