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

📄 g7to.c

📁 这是经典的卫星编程应用程序
💻 C
📖 第 1 页 / 共 5 页
字号:
	Pid_Trk_Data		=  34, // 0x22
	Pid_Wpt_Data		=  35, // 0x23
	Pid_Pvt_Data		=  51, // 0x33
	Pid_Protocol_Array	= 253  // 0xfd
};

//=====================================================================
// 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
//
// Product_Data_Type Product_Data;

//=====================================================================
// A010 - Device Command Protocol 1
//
enum
{
	Cmnd_Abort_Transfer	=  0,	// abort current transfer
	Cmnd_Transfer_Alm 	=  1,	// transfer almanac
	Cmnd_Transfer_Pos 	=  2,	// transfer position   added by crh
	Cmnd_Transfer_Prx 	=  3,	// transfer proximity waypoints
	Cmnd_Transfer_Rte 	=  4,	// transfer routes
	Cmnd_Transfer_Date	=  5,	// transfer date/time  added by crh
	Cmnd_Transfer_Trk 	=  6,	// transfer track log
	Cmnd_Transfer_Wpt 	=  7,	// transfer waypoints
	Cmnd_Power_Off      =  8,   // Turn unit off
	Cmnd_Send_Voltages  = 17,   // Send voltage readings (some units)
	Cmnd_Start_Pvt_Data = 49,	// start transmitting PVT
	Cmnd_Stop_Pvt_Data	= 50	// stop transmitting PVT data
};

//=====================================================================
// A011 - Device Command Protocol 2 (I added the '2' below crh 3/23/98)
//
enum
{
	Cmnd_Abort_Transfer2 =  0,	// abort current transfer
	Cmnd_Transfer_Alm2   =  4,	// transfer almanac
	Cmnd_Transfer_Rte2   =  8,	// transfer routes
	Cmnd_Transfer_Wpt2   = 21	// transfer waypoints
};
//=====================================================================
// 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)
//	LinkProtocol		:   1	Link version L001
//	Command				:  10	Command version A010
//	WaypDataRecord		: 104	Waypoint data	D104
//	RouteHdrType		: 201	RouteRecord		D201
//	RouteDataRecord		: 104	RouteTrack		D104
//	TrackDataRecord		: 300	TrackRecord		D300
//	ProxDataRecord		:  -1	ProximityData is not supported on this model gps
//	AlmanacDataRecord	: 501	AlmanacData		D501
//

//=====================================================================
//=====================================================================
//
//P000 - Physical Protocol Layer

//A000 - Product Data Protocol
//A001 - Protocol Capability Protocol

//=====================================================================
//A010 - Device Command Protocol 1
//A011 - Device Command Protocol 2

//=====================================================================
//A100 - Waypoint Transfer Protocol
//D100_Wpt_Type
//D101_Wpt_Type
//D102_Wpt_Type
//D103_Wpt_Type
//D104_Wpt_Type
//D105_Wpt_Type
//D106_Wpt_Type
//D150_Wpt_Type
//D151_Wpt_Type
//D152_Wpt_Type
//D154_Wpt_Type
//D155_Wpt_Type

//=====================================================================
//A200 - Route Transfer Protocol
//D200_Rte_Hdr_Type 
//D201_Rte_Hdr_Type 
//D202_Rte_Hdr_Type 
//D100_Wpt_Type
//D101_Wpt_Type
//D102_Wpt_Type
//D103_Wpt_Type
//D104_Wpt_Type
//D105_Wpt_Type
//D106_Wpt_Type
//D150_Wpt_Type
//D151_Wpt_Type
//D152_Wpt_Type
//D154_Wpt_Type
//D155_Wpt_Type

//=====================================================================
//A300 - Track Log Transfer Protocol
//D300_Trk_Point_Type

//=====================================================================
//A400 - Proximity Waypoint Transfer Protocol
//D101_Wpt_Type
//D102_Wpt_Type
//D152_Wpt_Type
//D400_Prx_Wpt_Type
//D403_Prx_Wpt_Type
//D450_Prx_Wpt_Type

//=====================================================================
//A500 - Almanac Transfer Protocol
//D500_Almanac_Type
//D501_Almanac_Type
//D550_Almanac_Type
//D551_Almanac_Type

//=====================================================================
//A600 - Date and Time Initialization Protocol
//D600_Date_Time_Type 

//=====================================================================
//A700 - Position Initialization Protocol
//D700_Position_Type

//=====================================================================
//A800 - PVT Data Protocol
//D800_Pvt_Data_Type 

//=====================================================================
//L001 - Link Protocol 1
//L002 - Link Protocol 2

//=====================================================================
// Current product info			Examples           Range allowed by doc
//=====================================================================
INT D105orD106=0;				// 1 if current waypoint is to/from a D105 or D106 record

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

INT ProductDataProtocol=0;      // 000 - A000		A000  ALL GPS's support this

INT PhysicalProtocol;			// 000 - P000		P000

INT	LinkProtocol=-1;			// 001 = L001		L001,L002

INT	CommandProtocol;			// 010 = A010		A010,A011

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

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

INT TrackXferProtocol;          // 300 = A300       A300
INT TrackDataRecord;            // 300 = D300       D300,D301 if TrackHdrType=310
INT TrackHdrType;               // 310 = D310       D301

INT ProxXferProtocol;			//  -1 = None		A400
INT	ProxDataRecord;				//  -1 = None		D101,D102,D152,D400,D403,D450


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

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

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

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

INT haveProtocolArray=0;		// set to 1 if the GPS sends a protocol array

extern INT Protocols[55][12];
extern INT ProtocolIndex;	// index into above table which holds the valid

//=====================================================================
// File names
//
char	*fname_in_all;	 	// current input file
char	*fname_out_all;		// current output file
char	*os;
//
// File Stream designators
//
FILE	*in;
FILE	*out;
FILE	*trks_out;			// used when sending internal track rcords to a file
FILE	*Gdebug_out;		// send serial debug info to this file

long	port_speed=0;		// Serial port baud rate
long	via;				// Set to 1 if point is a Via in sa6
INT		default_Garmin_icon=18;// default icon used in icon type conversion
INT		default_G12_icon=0; // 
INT		default_SA5_icon=46;
INT		default_GM2_icon=-1;
INT		default_SA52_icon=-1;
INT		default_LWR_icon=0;
INT		Gdebug=0;			// ==1, record input & output RS232
char    outfmt[10];			// holds protocol output format
long	interval;			// used in get position command
INT		Garmin_NAKS_Sent=0;	// number of NAKs sent to Garmin GPS this session
INT		Lowr_NAKS_Sent=0;	// number of NAKs sent to Lowrance GPS this session
unsigned char recordtype;	// record type being sent
unsigned INT valid_records=0;	// number of valid records from input file
double	minlat,maxlat;		// min/max latitude.  SA4 Center of map calc
double  minlon,maxlon;		// min/max longitude.  SA4 Center of map calc
double  minla,minlo;        // used in toDMSxx
double  NoProximity=0;		// number of proximity waypoints found
INT		proximity=0;		// processing a proximity waypoint
INT		doAsyncStat=0;		// if 1 print stats from rs232 port
INT		new_com=0;			// if 1 a new com port has been input
INT		no_N=1;				// set to 0 if a 'N' record is read
INT		total_dist=0;		// flag to total distance of track line
double	track_d=0.0;		// distance of current track segment
double	sum_dist=0.0;		// total distance of all track segments
INT		satnum;				// satellite number for doAlmanac
INT		COMtimeout=0;		// Set to 1 on a receiver timeout
INT		PVTvar=0;			// used in getting PVT data
INT		sa_fileout=0;		// 1 if any output file has suffix .sa(3/4/5)
//
// SA output drawing options
//
INT		draw_route_1_19_obj=1;// if 1 route waypoints are plotted on sa output
INT		draw_route_0=1;		// if 1 route 0 is drawn in sa4 output
INT		draw_route_0_obj=1;	// if 1 route 0 waypoints are plotted on sa4 output
INT		draw_track_lines=1;	// if 1 track lines are plotted on sa output
INT		draw_route_0_line=1;// if the output is to an SA5 file lines are drawn
                            // for route 0
INT		draw_route_1_19_lines=1;// if 1 draw lines between route points
							//  in routes 1-19 when output is SA4
INT		draw_prox_circles=1;// if 1 prox waypoints are plotted on sa output
INT		draw_waypoints=1;	// if 1 waypoints are plotted on sa output

INT		route_lines=0;		// Number of lines needed to draw routes
INT 	route_pushed=0;		// set to 1 when a route 0-19 is read
							//  from a SA file

INT		gotID=0;			// set to 1 when the connected GPS has been
							//  ID'd
unsigned	INT maxtrkptrs;	// maximum no of track points
unsigned	INT maxiconptrs;// maximum no of icons
//
// used in resending last message
//
BYTE 	*LastLowrGPSMsg;
BYTE 	*LastGarminGPSMsg;
short	LastLowrLen;
short	LastGarminLen;
//
// Global variables
//
int		UTM=0;					// Set to 1 if output is to be UTM
INT		dataread=0;				// Set to 1 when data is read from a GPS
char	*Text;					// Used in 'pushing' items
INT		route0=0;				// nth point in route 0
INT		Sused=0;				// Sxxxxx already used up to here
long	ZeroL=0L;				// a long 0
char	*infiles[20];			// array of input files
INT		current_in=0;			// index into infiles[] for current file
INT		input_files=0;			// number of input files
INT		in_file=0;				// file system file input found
char	*outfiles[20];			// array of output files
INT		output_files=0;			// number of output files
char	**waypoint_push;		// array of pointer to save waypoints
int		waypoints=0;			// Number of waypoints read into memory
char	**track_push;			// array of pointer to save track waypoints
char	**icon_push;			// array of pointer to save track waypoints
unsigned INT tracks=0;			// Number of track entries pushed into memory
unsigned INT icons=0;			// Number of icon entries pushed into memory
char 	**proximity_push;		// array of pointer to save proximity
INT		proximityp=0;			// Number of proximity waypoints read
INT		next_is_new=0;			// set to 1 when a 'N' record is read
								// and set to 0 when a 'T' record is read

INT 	*routeXpts;				// # of waypoints in route number 'x' is
								//    held in routeXpts[x]
char	*route_push[MAXROUTES+1][MAXPOINTS+1];// array of pointers to save route
INT		routes=0;				// Number of route points in route 1-> MAXROUTE
char	*route_comment;			// route name of current route 
INT		route_number=-1;		// route number of current route
INT		route_points=0;			// route number of current route
INT		route_point=0;			// point number in current route
char	*routename1;			// used in sa3 -> text for routes
INT		in_route;				// set to 1 if reading a route
char	rtn[4];					// ASCII of current route number
INT		in_track;				// set to 1 if reading a track
INT		first_track;			// set to 1 if outputting first track point
								//  after an 'N' record
INT		first_track_push=1;		// pushing the first track
INT		first_icon_push=1;		// pushing the first icon
INT		first_waypoint_push=1;	// pushing the first waypoint
INT		first_proximity_push=1;	// pushing the first proximity waypoint
INT		trk_seg=0;				// number of track segments read
INT		*trks;					// elements in xth track seg
short	**deltas;				// holds track deltas for Lowrance units
INT		cur_trk=0;				// track element currently being read
INT		nosort=0;				//  if 0 waypoints are sorted on input

INT 	symb=0;					// 1 = reading SA Symbol
								// 2 = reading SA Line
								// 3 = reading SA Circle
INT		mapCir=0;				// number of circles read from map

char	*drive;					// used by fnsplit
char	*dir;					// used by fnsplit
char	*file;					// used by fnsplit
char	*ext;					// used by fnsplit
INT		flags;					// used by fnsplit

INT		opterr = 1;				// argument expansion variable
INT		optind = 1;				// argument expansion variable
INT		optopt;					// argument expansion variable
char	*optarg;				// argument expansion variable

INT		IOaddr=0x3f8;			// COM port I/O address
INT		IRQnumber=4;			// COM port IRQ
INT		nocmdline=0;			// set to 1 if sa3->text is to have
								//   command lines

INT		firstR=0;				// used in nav.exe route processing
INT		firstW=0;				// used in nav.exe route processing

INT		input=0;				// we have valid input to process
INT		output=0;				// we have valid output	to process

INT		pwr=0;					// power off to GPS flag
INT		light=-1;				// Backlight on (1) off (0)
INT		contrast_val=-1;		// Set Contrast value
double  InternalVolts;			// Internal (AA) voltage returned by Garmin
double  ExternalVolts;			// External voltage returned by Garmin

BYTE	p1[]	= "\x06\x02\x1b\x00";	// Get 1st packet

⌨️ 快捷键说明

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