⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 garmin.c

📁 这是经典的卫星编程应用程序
💻 C
📖 第 1 页 / 共 5 页
字号:
#include "g7to.h"
static const LONGdouble CONVERT = 11930464.7111111111;  /* 2^31 / 180 */

INT dsplines=0;
INT dsppixels=0;
//=====================================================================
// Data from Garmin Beta Document
//
//=====================================================================
INT  SPWptNo=0;
BYTE *StreetPilotWptName;
BYTE *StreetPilotLnk_ident;
INT go_on=1;
//
// Defines of Known Product_ID's
//
#define GPSIIP               73
#define GPS12_12XLA          77
#define GPS12                87
#define GPS12_12XLB          96
#define GPSIIP_1             97
#define GPS12CX             116
#define GPS12XL_J           105  // Japanese
#define GPS12XL_C           106  // Chinese
#define GPS38_40_45_45XL_A   31
#define GPS38_40_45_45XL_B   41
#define GPSII                59
#define GPS38_C              56
#define GPS38_J              62
#define GPSIIIPILOT          71
#define GPSIII_ID            72
#define STREETPILOT          67
#define STREETPILOTCOLORMAP 118
#define GPS3P               119

// Garmin GPS Family for Icons
//
INT Ggps=0;
#define     G12XL           1
#define     GPSIII          2
#define     GPSIIIP         3
#define     SPILOT          4
#define     SPILOTCOLOR     5

//=====================================================================
//
// Garmin symbol numbers
//
//=====================================================================
enum
{
//
// * indicates those in the GPS III revision 2.05 and greater
//
//---------------------------------------------------------------
// Symbols for marine (group 0...0-8191...bits 15-13=000).
//---------------------------------------------------------------
	sym_anchor =			0,	// 0x0000 * white anchor symbol 
	sym_bell =				1,	// 0x0001 * white bell symbol 
	sym_diamond_grn =		2,	// 0x0002   green diamond symbol 
	sym_diamond_red =		3,	// 0x0003   red diamond symbol 
	sym_dive1 =				4,	// 0x0004   diver down flag 1 
	sym_dive2 =				5,	// 0x0005   diver down flag 2 
	sym_dollar =			6,	// 0x0006 * white dollar symbol 
	sym_fish =				7,	// 0x0007 * white fish symbol 
	sym_fuel =				8,	// 0x0008 * white fuel symbol 
	sym_horn =				9,	// 0x0009   white horn symbol 
	sym_house =			   10,	// 0x000a * white house symbol 
	sym_knife =			   11,	// 0x000b * white knife & fork symbol 
	sym_light =			   12,	// 0x000c   white light symbol 
	sym_mug =			   13,	// 0x000d * white mug symbol 
	sym_skull =			   14,	// 0x000e * white skull and crossbones symbol
	sym_square_grn =	   15,	// 0x000f   green square symbol 
	sym_square_red =	   16,	// 0x0010   red square symbol 
	sym_wbuoy =			   17,	// 0x0011   white buoy waypoint symbol 
	sym_wpt_dot =		   18,	// 0x0012 * waypoint dot 
	sym_wreck =			   19,	// 0x0013   white wreck symbol 
	sym_null =			   20,	// 0x0014   null symbol (transparent) 
	sym_mob =			   21,	// 0x0015 * man overboard symbol 
//------------------------------------------------------
// Marine navaid symbols
//------------------------------------------------------
	sym_buoy_ambr =		   22,	// 0x0016   amber map buoy symbol 
	sym_buoy_blck =		   23,	// 0x0017   black map buoy symbol 
	sym_buoy_blue =		   24,	// 0x0018   blue map buoy symbol 
	sym_buoy_grn =		   25,	// 0x0019   green map buoy symbol 
	sym_buoy_grn_red =	   26,	// 0x001a   green/red map buoy symbol 
	sym_buoy_grn_wht =	   27,	// 0x001b   green/white map buoy symbol 
	sym_buoy_orng =		   28,	// 0x001c   orange map buoy symbol 
	sym_buoy_red =		   29,	// 0x001d   red map buoy symbol 
	sym_buoy_red_grn =	   30,	// 0x001e   red/green map buoy symbol 
	sym_buoy_red_wht =	   31,	// 0x001f   red/white map buoy symbol 
	sym_buoy_violet =	   32,	// 0x0020   violet map buoy symbol 
	sym_buoy_wht =		   33,	// 0x0021   white map buoy symbol 
	sym_buoy_wht_grn =	   34,	// 0x0022   white/green map buoy symbol 
	sym_buoy_wht_red =	   35,	// 0x0023   white/red map buoy symbol 
	sym_dot =			   36,	// 0x0024   white dot symbol 
	sym_rbcn =			   37,	// 0x0025   radio beacon symbol 
//------------------------------------------------------
// ... leave space for more navaids (up to 128 total)
//------------------------------------------------------
	sym_boat_ramp =		  150,	// 0x0096 * boat ramp symbol 
	sym_camp =			  151,	// 0x0097 * campground symbol 
	sym_restrooms =		  152,	// 0x0098 * restrooms symbol 
	sym_showers =		  153,	// 0x0099 * shower symbol 
	sym_drinking_wtr =	  154,	// 0x009a * drinking water symbol 
	sym_phone =			  155,	// 0x009b * telephone symbol 
	sym_1st_aid =		  156,	// 0x009c * first aid symbol 
	sym_info =			  157,	// 0x009d * information symbol 
	sym_parking =		  158,	// 0x009e * parking symbol 
	sym_park =			  159,	// 0x009f * park symbol 
	sym_picnic =		  160,	// 0x00a0 * picnic symbol 
	sym_scenic =		  161,	// 0x00a1 * scenic area symbol 
	sym_skiing =		  162,	// 0x00a2 * skiing symbol 
	sym_swimming =		  163,	// 0x00a3 * swimming symbol 
	sym_dam =			  164,	// 0x00a4 * dam symbol 
	sym_controlled =	  165,	// 0x00a5   controlled area symbol 
	sym_danger =		  166,	// 0x00a6   danger symbol 
	sym_restricted =	  167,	// 0x00a7   restricted area symbol 
	sym_null_2 =		  168,	// 0x00a8   null symbol 
	sym_ball =			  169,	// 0x00a9 * ball symbol 
	sym_car =			  170,	// 0x00aa * car symbol 
	sym_deer =			  171,	// 0x00ab * deer symbol 
	sym_shpng_cart =	  172,	// 0x00ac * shopping cart symbol 
	sym_lodging =		  173,	// 0x00ad * lodging symbol 
	sym_mine =            174,  // 0x00ae * mine symbol
//---------------------------------------------------------------
// Symbols for land (group 1...8192-16383...bits 15-13=001).
//---------------------------------------------------------------
	sym_is_hwy =		 8192,	// 0x2000   interstate hwy symbol 
	sym_us_hwy =		 8193,	// 0x2001   us hwy symbol 
	sym_st_hwy =		 8194,	// 0x2002   state hwy symbol 
	sym_mi_mrkr =		 8195,	// 0x2003   mile marker symbol 
	sym_trcbck =		 8196,	// 0x2004 * TracBack (feet) symbol 
	sym_golf =			 8197,	// 0x2005 * golf symbol 
	sym_sml_cty =		 8198,	// 0x2006 * small city symbol 
	sym_med_cty =		 8199,	// 0x2007 * medium city symbol 
	sym_lrg_cty =		 8200,	// 0x2008 * large city symbol 
	sym_freeway =		 8201,	// 0x2009   intl freeway hwy symbol 
	sym_ntl_hwy =		 8202,	// 0x200a   intl national hwy symbol 
	sym_cap_cty =		 8203,	// 0x200b   capitol city symbol (star) 
	sym_amuse_pk =		 8204,	// 0x200c   amusement park symbol 
	sym_bowling =		 8205,	// 0x200d   bowling symbol 
	sym_car_rental =	 8206,	// 0x200e   car rental symbol 
	sym_car_repair =	 8207,	// 0x200f   car repair symbol 
	sym_fastfood =		 8208,	// 0x2010   fast food symbol 
	sym_fitness =		 8209,	// 0x2011   fitness symbol 
	sym_movie =			 8210,	// 0x2012   movie symbol 
	sym_museum =		 8211,	// 0x2013   museum symbol 
	sym_pharmacy =		 8212,	// 0x2014   pharmacy symbol 
	sym_pizza =			 8213,	// 0x2015   pizza symbol 
	sym_post_ofc =		 8214,	// 0x2016   post office symbol 
	sym_rv_park =		 8215,	// 0x2017   RV park symbol 
	sym_school =		 8216,	// 0x2018   school symbol 
	sym_stadium =		 8217,	// 0x2019   stadium symbol 
	sym_store =			 8218,	// 0x201a   dept. store symbol 
	sym_zoo =			 8219,	// 0x201b   zoo symbol 
//---------------------------------------------------------------
// Symbols for aviation (group 2...16383-24575...bits 15-13=010).
//---------------------------------------------------------------
	sym_airport =		16384,	// 0x4000 * airport symbol 
	sym_int =			16385,	// 0x4001   intersection symbol 
	sym_ndb =			16386,	// 0x4002   non-directional beacon symbol 
	sym_vor =			16387,	// 0x4003   VHF omni-range symbol 
	sym_heliport =		16388,	// 0x4004 * heliport symbol 
	sym_private =		16389,	// 0x4005 * private field symbol 
	sym_soft_fld =		16390,	// 0x4006 * soft field symbol 
	sym_tall_tower =	16391,	// 0x4007 * tall tower symbol 
	sym_short_tower =	16392,	// 0x4008 * short tower symbol 
	sym_glider =		16393,	// 0x4009 * glider symbol 
	sym_ultralight =	16394,	// 0x400a * ultralight symbol 
	sym_parachute =		16395,	// 0x400b * parachute symbol 
	sym_vortac =		16396,	// 0x400c   VOR/TACAN symbol 
	sym_vordme =		16397,	// 0x400d   VOR-DME symbol 
	sym_faf =			16398,	// 0x400e   first approach fix 
	sym_lom =			16399,	// 0x400f   localizer outer marker 
	sym_map =			16400,	// 0x4010   missed approach point 
	sym_tacan =			16401,	// 0x4011   TACAN symbol 
	sym_seaplane =		16402,	// 0x4012 * Seaplane Base 
};
//---------------------------------------------------------------
//D103_Wpt_Type symbols:
//---------------------------------------------------------------
enum
{
	smbl_dot = 				0,	//   0x00 dot symbol 
	smbl_house =			1,	//   0x01 house symbol 
	smbl_gas =				2,	//   0x02 gas symbol 
	smbl_car =				3,	//   0x03 car symbol 
	smbl_fish =				4,	//   0x04 fish symbol 
	smbl_boat =				5,	//   0x05 boat symbol 
	smbl_anchor =			6,	//   0x06 anchor symbol 
	smbl_wreck =			7,	//   0x07 wreck symbol 
	smbl_exit =				8,	//   0x08 exit symbol 
	smbl_skull =			9,	//   0x09 skull symbol 
	smbl_flag =			   10,	//   0x0a flag symbol 
	smbl_camp =			   11,	//   0x0b camp symbol 
	smbl_duck =			   12,	//   0x0c duck symbol 
	smbl_deer =			   13,	//   0x0d deer symbol 
	smbl_buoy =			   14,	//   0x0e buoy symbol 
	smbl_back_track =	   15 	//   0x0f back track symbol 
};

//=====================================================================
//  Default Packet IDs
//
enum {
	Pid_Ack_Byte		=   6, // 0x06
	Pid_Nak_Byte		=  21, // 0x15
	Pid_Protocol_Array	= 253, // 0xfd
	Pid_Product_Rget	= 254, // 0xfe
	Pid_Product_Data	= 255  // 0xff
};

//=====================================================================
// L001 - Link Protocol 1
//
enum {
	Pid_Command_data	=  10, // 0x0a
	Pid_Xfer_Cmplt		=  12, // 0x0c
	Pid_Date_Time_Data	=  14, // 0x0e
	Pid_Position_Data	=  17, // 0x11
	Pid_Prx_Wpt_Data	=  19, // 0x13
	Pid_Records			=  27, // 0x1b
	Pid_Rte_Hdr			=  29, // 0x1d
	Pid_Rte_Wpt_Data	=  30, // 0x1e
	Pid_Almanac_Data	=  31, // 0x1f
	Pid_Trk_Data		=  34, // 0x22
	Pid_Wpt_Data		=  35, // 0x23
	Pid_Pvt_Data		=  51, // 0x33  // also seen on GPS III with DeLorme
//  ????                =  65, // 0x41  // seen on GPS III with DeLorme
	Pid_Display_Data    =  69, // 0x45  // GPS III only (so far)
};

//=====================================================================
// L002 - Link Protocol 2
//
enum {
	Pid_Almanac_Data2	=   4, // 0x04
	Pid_Command_Data2	=  11, // 0x0b
	Pid_Xfer_Cmplt2		=  12, // 0x0c
	Pid_Date_Time_Data2	=  20, // 0x14
	Pid_Position_Data2	=  24, // 0x18
	Pid_Records2		=  35, // 0x23
	Pid_Rte_Hdr2		=  37, // 0x25
	Pid_Rte_Wpt_Data2	=  39, // 0x27
	Pid_Wpt_Data2		=  43  // 0x2b
};

//=====================================================================
// A000 - Product Data Protocol
//
//typedef struct
//{
//	INT product_ID;
//	INT software_version;
//	byte a[1];  // fake for below ...
// char product_description[]; null-terminated string
// ... zero or more additional null-terminated strings
//} Product_Data_Type;

//=====================================================================
// A010 - Device Command Protocol 1
//
enum
{
	Cmnd_Abort_Transfer	=  0, // 0x00	abort current transfer
	Cmnd_Transfer_Alm 	=  1, // 0x01	transfer almanac
	Cmnd_Transfer_Posn 	=  2, // 0x02	transfer position   added by crh
	Cmnd_Transfer_Prx 	=  3, // 0x03	transfer proximity waypoints
	Cmnd_Transfer_Rte 	=  4, // 0x04	transfer routes
	Cmnd_Transfer_Time	=  5, // 0x05	transfer date/time  added by crh
	Cmnd_Transfer_Trk 	=  6, // 0x06	transfer track log
	Cmnd_Transfer_Wpt 	=  7, // 0x07	transfer waypoints
	Cmnd_Turn_Off_Pwr   =  8, // 0x08	Turn unit off
	Cmnd_Send_Voltages  = 17, // 0x11	Send voltage readings (some units)
	Cmnd_Send_Display   = 32, // 0x20   Send GPS III display
	Cmnd_Start_Pvt_Data = 49, // 0x31	start transmitting PVT
	Cmnd_Stop_Pvt_Data	= 50  // 0x32	stop transmitting PVT data
};

//=====================================================================
// A011 - Device Command Protocol 2 (I added the '2' below crh 3/23/98)
//
enum
{
	Cmnd_Abort_Transfer2=  0, // 0x00	abort current transfer
	Cmnd_Transfer_Alm2 	=  4, // 0x04	transfer almanac
	Cmnd_Transfer_Rte2	=  8, // 0x08	transfer routes
	Cmnd_Transfer_Time2 = 20, // 0x14   transfer time
	Cmnd_Transfer_Wpt2	= 21, // 0x15	transfer waypoints
	Cmnd_Turn_Off_Pwr2  = 26  // 0x19   Turn unit off
};
//=====================================================================
// Index into Protocols Array for the various protocol id's
//
//   For example, the III is index 72 which has the following data:
//
//  Product_ID		:  72	Garmin's product ID for the III
//	Product_Ver		:   0	(0 indicates all versions of the III)
//	link			:   1	Link version L001
//	Command			:  10	Command version A010
//	WaypDataRecord	: 104	Waypoint data	D104
//	RouteRecord		: 201	RouteRecord		D201
//	RouteTrkRecord	: 104	RouteTrack		D104
//	TrackDataRecord	: 300	TrackRecord		D300
//	ProxDataRecord  :  -1	ProximityData is not supported on this model gps
//	AlmanacRecord	: 501	AlmanacData		D501
//

INT WaypointType;

//=====================================================================
// Current product info			Examples		Range allowed by doc
//=====================================================================
extern INT D105orD106;			// 1 if current waypoint is from/to a StreetPilot

extern INT Product_ID;			// 72  GPS III 	... 
extern INT Product_Ver;			// 000 - all	...

extern INT PhysicalProtocol;	// 000 = P000	P000

extern INT LinkProtocol;		// 001 = L001	L001,L002
 
extern INT CommandProtocol;		// 010 = A010	A010,A011

extern INT WaypXferProtocol;	// 100 = A100	A100
extern INT WaypDataRecord;		// 104 = D104	D100,D101,D102,D103,D104,D105,D106,D150
								//				D151,D152,D154,D155

extern INT RouteXferProtocol;	// 200 = A200	A200
extern INT RouteHdrType;		// 201 = D201	D200,D201,D202
extern INT RouteDataRecord;		// 104 = D104	D100,D101,D102,D103,D104,D105,D106,D150
								//				D151,D152,D154,D155

extern INT TrackXferProtocol;	// 300 = A300	A300
extern INT TrackDataRecord;		// 300 = D300	D300

extern INT ProxXferProtocol;	// 000 = None	A400
extern INT ProxDataRecord;		// 000 = None	D101,D102,D152,D400,D403,D450

extern INT AlmanacXferProtocol;	// 500 = A500	A500
extern INT AlmanacDataRecord;	// 501 = D501	D500,D501,D550,D551

extern INT UTCXferProtocol;		// 600 = A600	A600
extern INT UTCDataRecord;		// 600 = D600	D600

extern INT PositionXferProtocol;// 700 = A700	A700
extern INT PositionDataRecord;	// 700 = D700	D700

extern INT PVTXferProtocol;		// 000 = None	A800
extern INT PVTDataRecord;		// 000 = None	D800

//=====================================================================
// Product ID vs Protocols supported.  These products do not currently
//  support PVT data transfer (A800-D800).  They do not support the
//  Protocol Capability Protocol, either
//
INT Protocols[55][12] = {
// ID Ver Link Cmnd        Wpt          Rte        Trk       Prx          Alm
// -- --- ---- ----        ---        --------   --------  --------       ---
 { 13,  0,   1,  10,       100,       201, 100,  300, 300, 400, 400,      500},
 { 14,  0,   1,  10,       100,       200, 100,  300, 300, 400, 400,      500},
 { 15,  0,   1,  10,       151,       200, 151,  300, 300, 400, 400,      500},
 { 18,  0,   1,  10,       100,       201, 100,  300, 300, 400, 400,      500},
 { 20,  0,   2,  11,       150,       201, 150,   -1,  -1, 400, 450,      550},
 { 22,  0,   1,  10,       152,       201, 152,  300, 300, 400, 152,      500},
 { 23,  0,   1,  10,       100,       201, 100,  300, 300, 400, 400,      500},
 { 24,  0,   1,  10,       100,       201, 100,  300, 300, 400, 400,      500},
 { 29,-400,  1,  10,       101,       201, 101,  300, 300, 400, 101,      500},
 { 29, 400,  1,  10,       102,       200, 102,  300, 300, 400, 102,      500},
 { 31,  0,   1,  10,       100,       201, 100,  300, 300,  -1,  -1,      500},
 { 33,  0,   2,  11,       150,       201, 150,   -1,  -1, 400, 450,      550},
 { 34,  0,   2,  11,       150,       201, 150,   -1,  -1, 400, 450,      550},
 { 35,  0,   1,  10,       100,       201, 100,  300, 300, 400, 400,      500},
 { 36,-300,  1,  10,       152,       201, 152,  300, 300, 400, 152,      500},
 { 36, 300,  1,  10,       152,       201, 152,  300, 300,  -1,  -1,      500},
 { 39,  0,   1,  10,       151,       201, 151,  300, 300,  -1,  -1,      500},
 { 41,  0,   1,  10,       100,       201, 100,  300, 300,  -1,  -1,      500},
 { 42,  0,   1,  10,       100,       201, 100,  300, 300, 400, 400,      500},
 { 44,  0,   1,  10,       101,       201, 101,  300, 300, 400, 101,      500},
 { 45,  0,   1,  10,       152,       201, 152,  300, 300,  -1,  -1,      500},
 { 47,  0,   1,  10,       100,       201, 100,  300, 300,  -1,  -1,      500},
 { 48,  0,   1,  10,       154,       201, 154,  300, 300,  -1,  -1,      501},
 { 49,  0,   1,  10,       102,       201, 102,  300, 300, 400, 102,      501},
 { 50,  0,   1,  10,       152,       201, 152,  300, 300,  -1,  -1,      501},
 { 52,  0,   2,  11,       150,       201, 150,   -1,  -1, 400, 450,      550},
 { 53,  0,   1,  10,       152,       201, 152,  300, 300,  -1,  -1,      501},
 { 55,  0,   1,  10,       100,       201, 100,  300, 300,  -1,  -1,      500},
 { 56,  0,   1,  10,       100,       201, 100,  300, 300,  -1,  -1,      500},
 { 59,  0,   1,  10,       100,       201, 100,  300, 300,  -1,  -1,      500},
 { 61,  0,   1,  10,       100,       201, 100,  300, 300,  -1,  -1,      500},
 { 62,  0,   1,  10,       100,       201, 100,  300, 300,  -1,  -1,      500},
 { 64,  0,   2,  11,       150,       201, 150,   -1,  -1, 400, 450,      551},
 { 71,  0,   1,  10,       155,       201, 155,  300, 300,  -1,  -1,      501},
 { 72,  0,   1,  10,       104,       201, 104,  300, 300,  -1,  -1,      501},
 { 73,  0,   1,  10,       103,       201, 103,  300, 300,  -1,  -1,      501},

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -