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

📄 g7to.c

📁 这是经典的卫星编程应用程序
💻 C
📖 第 1 页 / 共 5 页
字号:
BYTE	p2[]	= "\x06\x02\x0c\x00";	// Get last packet
BYTE	rte2[]	= "\x06\x02\x1d\x00";	// Get next route packet
BYTE	alm2[]	= "\x06\x02\x1f\x00";	// Get next almanac packet
BYTE	trk2[]	= "\x06\x02\x22\x00";	// Get next track packet
BYTE	wpt2[]	= "\x06\x02\x23\x00";	// Get next waypoint packet
BYTE	ack1[]	= "\x06\x02\xff\x00";	// ack for received mod/ver info

BYTE	Gabort[]= "\x0a\x02\x00\x00";	// Abort Transfer
BYTE	alm1[]	= "\x0a\x02\x01\x00";	// Send almanac
BYTE	GPSPos[]= "\x0a\x02\x02\x00";	// send position
BYTE	pwpt1[]	= "\x0a\x02\x03\x00";	// send Proximity waypoints
BYTE	rte1[]	= "\x0a\x02\x04\x00";	// send routes
BYTE	display[]="\x0a\x02\x20\x00";	// send GPS III display
BYTE	GPStime[]="\x0a\x02\x05\x00";	// send UTC time
BYTE	trk1[]	= "\x0a\x02\x06\x00";	// send tracks
BYTE	wpt1[]	= "\x0a\x02\x07\x00";	// send waypoints
BYTE	pwroff[]= "\x0a\x02\x08\x00";	// Power off command
BYTE	VoltsM[]= "\x0a\x02\x11\x00";	// send voltages
BYTE	PVTon[] = "\x0a\x02\x31\x00";	// start sending PVT records
BYTE	PVToff[]= "\x0a\x02\x32\x00";	// stop sending PVT records

BYTE	almt[]	= "\x0c\x02\x01\x00";	// Almanac data base terminator
BYTE	prxt[]	= "\x0c\x02\x03\x00";	// Proximity data base terminator
BYTE	rtet[]	= "\x0c\x02\x04\x00";	// Route data base terminator
BYTE	trkt[]	= "\x0c\x02\x06\x00";	// Track data base terminator
BYTE	wptt[]	= "\x0c\x02\x07\x00";	// Waypoint data base terminator

BYTE	nak1[]	= "\x15\x02\xff\x00";	// nak for received mod/ver info

BYTE	bgnxfr[]= "\x1b\x02\x00\x00";   // 0000 filled in with number

BYTE	lighton[]=  "\x0f\x01\x00";		// send light on (some units)
BYTE	lightoff[]= "\x0f\x01\x01";		// send light off (some units)
BYTE	lightiiP[]= "\x0f\x01\x80";		// send light on II+
BYTE	contrast[]= "\x0b\x01\x08";		// set contrast
BYTE	m1[]	  = "\xfe\x01\x20";		// Get the model and version number

BYTE	*SerialMessage;
BYTE	*SerialMessageOut;
BYTE	*message;

INT	lx=0;  /* 1=95lx, 2=100lx */

unsigned INT SWVersion;		/* version * 100				     */
INT		VersionSubStrings=0;
char	VersionString[99];	/* model/version in string format    */
char	*VersionSubString[10];// version substrings

BYTE newTrack=255;  		/* 255 no track records this session */
                    		/*  0 sending tracks                 */
		    				/*  1 sending first track            */
struct RECORD record;

INT 	ok=-1;

unsigned INT len;				/* misc length param	 			 */
INT		tog45=0;			/* 1 = sending data to GPS 45		 */
INT		toLowr=0;			/* 1 = sending data to Lowrance GPS */
INT		ComPort=COM1;
INT		AlmanacEOF;
INT		RouteEOF;
INT		TrackEOF;
INT		ProxWaypointEOF;
INT		WaypointEOF;

struct PREFS gPrefs;

INT		com_open=0;
BYTE	output_format;

/*
 * Structures
 */
#if __BORLANDC__
struct 	ftime ft;
#else
struct	mftime ft;
#endif

INT two=2;
INT ObjCode=0;
double  setlat=1000.0;
double  setlon=1000.0;
double  lastlat=0.0;
double  lastlon=0.0;

INT	setmag;

INT 	Last_ObjSize=-1;
INT 	Last_ObjColor=-1;
INT 	Last_TextSize=-1;
INT 	Last_TextColor=-1;
INT 	Last_TextAlign=-1;

INT 	Last_LineColor=-1;
INT 	Last_LineWidth=-1;
INT 	Last_LineStyle=-1;

INT		Last_CirLineDraw=-1;
INT		Last_CirFillArea=-1;
INT		Last_CirLineColor=-1;
INT		Last_CirLineWidth=-1;
INT 	Last_CirFillColor=-1;
INT 	Last_CirFillStyle=-1;

char LowrProducts[20][17] = {
			"Unknown",
 			"GlobalMap Sport",
 			"AirMap",
 			"AccuMap",
 			"GlobalNav 310",
 			"Eagle View",
 			"Eagle Explorer",
 			"GlobalNav 200",
 			"Expedition II",
 			"GlobalNav 212",
 			"GlobalMap 12",
			"Unknown",
			"AccuMap 12",
			"Unknown",
			"GlobalMap 100",
			"Unknown",
			"Unknown",
			"Unknown",
			"Unknown",
			"Unknown"
};
char days[7][4] = {
	"Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat" 
};

char months[13][4] = { "Bad",
	"Jan", "Feb", "Mar", "Apr", "May", "Jun", 
	"Jul", "Aug", "Sep", "Oct", "Nov", "Dec" 
};

unsigned char *genConst;

//===================================================================
//This format is used by DeLorme Map'n'Go 3.0 and Street Atlas 4.0 to
//store GPS tracks.  The file is composed of equal length records.  Each
//record is 56 bytes long.
//
//The format of the record is:
//
//	4 bytes - status (unsigned long) 
//	4 bytes - ????? 
//	8 bytes - latitude (floating point double, decimal degrees) 
//	8 bytes - longitude (floating point double, decimal degrees) 
//	8 bytes - altitude (floating point double, meters) 
//	8 bytes - heading (floating point double, decimal degrees) 
//	8 bytes - speed (floating point double, MPH) 
//	4 bytes - time (unsigned long, C 'time_t' type) 
//	4 bytes - ????? 
//
//The following 'C' structure can be used to access the data in each record.

struct SA_gpl_record
{
	unsigned long status;
	unsigned long dummy;
	double        latitude;
	double        longitude;
	double        altitude;
	double        heading;
	double        speed;
	unsigned long time;  	// in <time.h format
	unsigned long dummy3;
} SA_gpl_record;


//===================================================================
INT		LowrType=0;		// 1=Track 1,  2=Track 2, 3=Waypoints
						// 4=Routes,   5=Icons

INT		g45type=0;		// 1=Tracks,  2=Waypoints, 3=Routes
						// 4=iD,      5=tIme,      6=Position
						// 7=Almanac, 8=proXimity waypoints 
						// 9=Voltages 10=Light on, 11=Light off

INT intype=0;			// 	1=txt/gd7 		2=GARMIN GPS i/o 3=SA3
						//  4=almanac data	5=Navigate route 6=SA4
						//  7=unused        8=SA gpl file    9=SA6
						// 10=Fugawi wpt   11=Fugawi track	12=OZI_OWP
						// 13=             14=CSV           15=LOWRANCE GPS i/o
						// 16=OZI Plot     17=OZI Waypoint  18=OZI Route
						//  99=GERROR

long	numrecords;		// number of input records in file
unsigned INT s4o_trk_recs;  // number of line objects in SA4 file
INT 	firstwaypoint=1;
INT 	firstPwaypoint=1;
INT 	firsttrackpoint=1;


char	*p;				// general pointer for string functions
char	*buf;			// general string

unsigned long LatConst=0x6ae187b1L;
unsigned long LonConst=0x494ae39bL;
double	LatC,LonC;

INT	sa3number=0;  	/* number of 'items' written to a SA file */
INT	Id=0x100,
		MagC=4,
		Mapfeatures=0x3fff;

char	*MapTitle;

INT	nameonlytxt=0;
INT	nameonly=0; 	// Handles comment and symbol display options
						
						// 0  - all items written
						// 1  - comment not written on regular waypoints
						// 2  - comment not written on route waypoints
						// 4  - the symbol display  parameter not written
						// 8  - route name is not written on first route point
						//16  - (nn:nn) not written on routes

INT	noname=0;		// 1 = no text info is output into SA files
INT	ShowGrids=1, NumObjs;
INT	ObjColor=0,TextColor=2,TextSize=0,ObjSize=0,TextAlign=2;
INT	LineWidth=1,LineColor=0,LineStyle=0;
INT	Route_LineWidth=1,Route_LineColor=0,Route_LineStyle=0;

INT	CirLineWidth=0,CirLineColor=0,CirFillStyle=0;
INT	CirLineDraw=1,CirFillArea=0,CirFillColor=0;

INT	ItemType,
		Item;

unsigned char MtLen;
unsigned long Const1=0x1a2b3c4dL;

BYTE	*bin;
INT	optchar;
INT	navmode=0,		// 1 = navigate.exe output
    	tmode=0,		// 1 = text output desired
    	g6=0,	 		// 1 = garmin64 output
    	s3o=0,			// 1 = output is sa3 file
		s4o=0,			// 1 = output is sa4 file
    	s5o=0,			// 1 = output is sa5 file
    	s6o=0,			// 1 = output is sa6 file
		gpl_out=0,		// 1 = output is to SA .gpl file
		csv_out=0,		// 1 = output is a comma separated file
		TextFileOutput=0, // 1 = output is to a text file
		GarDownWP=0,	// 1 = Waypoint name length is set to be 6 chars on output
		getGarminDisp=0,// 1 = output GPS III/SP display to a file
		DisplayIsLowrance=0,// if set to 1 then Lowrance display is output to .bmp
							//   instead of a Garmin Display
		oziwpt=0,		// 1 = output is a OziExplorer Saved wpt file
		ozievt=0,		// 1 = output is a OziExplorer Exported wpt file
		oziplt=0,		// 1 = output is a Ozi track (plot) file
		ozirte=0,		// 1 = output is a Ozi route file
		fugawiwpt=0,	// 1 = output is a FUGAWI wpt file
		fugawitrk=0,	// 1 = output is a FUGAWI trk file
		igctrackout=0,  // 1 = output is "B" record in an IGC file
		waypoint2trk=0;	// 1 = output waypoints as a track file


char align[8][3]={"nw","n","ne","w","e","sw","s","se"};
char sizes[5][3]={"vs","s","m","l","vl"};
char colors[5][7]={"black","red","blue","green","yellow"};
char width[5][3]={"vt","t","m","k","vk"};
char style[3][3]={"n","ha","*h"};
char noyes[2][2]={"n","y"};

double ReadLatLonVal(char *LL)
{
    char *str, *p;
    double lastlat;

//printf("LL: '%s'\n",LL);
    switch(DMSMode) {
// Wddd MM SS.ss  (DMS)
        case DMS:
            str=strdup(LL);
            p=strtok(str," ");
            if(p!=NULL) lastlat=atof(p);
            p=strtok(NULL," ");
            if(p!=NULL) lastlat+=atof(p)/60.0;
            p=strtok(NULL," ");
            if(p!=NULL) lastlat+=atof(p)/3600.0;
            free(str);
            break;
// Wddd MM.mmmm  (DM)
        case DMM:
            str=strdup(LL);
            p=strtok(str," ");
            if(p!=NULL) lastlat=atof(p);
            p=strtok(NULL," ");
            if(p!=NULL) lastlat+=atof(p)/60.0;
            free(str);
            break;
// DDD.ddddd
        case DDD:
            lastlat=atof(LL);
            break;
    } // switch(DMSMode)
//printf("LE: '%lf'\n",lastlat);
    return lastlat;
} // double ReadLatLonVal(
/* getstrings:
 * char *getstrings(s1,s2,s3)
 * char *s1, *s2;
 * INT  s3;
 *
 *  Works somewhat like strtok(3).  In fact, if s3 is 0 this routine
 *  operates *exactly* like strtok3.
 *
 *  When s3 is 1, the static variable ch is bumped up by the value
 *   of s3.  This will allow a linear array of characters separated by
 *   a NULL to be decoded.
 *
 *  Example:
 *
 *
 *char a[100]="One\0Two\0Three\0Four\0Five";
 *main() {
 *
 *	INT i;
 *	char *p;
 *
 *	for(i=0;i<30;i++) printf("%c  ",a[i]);
 *
 *	p=getstring(a,"\0",0);
 *	printf("'\n%s'\n",p);
 *
 *	p=getstring(NULL,"",1);
 *	printf("'%s'\n",p);
 *
 *	p=getstring(NULL,"",1);
 *	printf("'%s'\n",p);
 *
 *	p=getstring(NULL,"",1);
 *	printf("'%s'\n",p);
 *
 *	p=getstring(NULL,"",1);
 *	printf("'%s'\n",p);
 *
 *	p=getstring(NULL,"",1);
 *	printf("'%s'\n",p);
 * 
 *}
 *	will print:
 *			'One'
 *			'Two'
 *			'Three'
 *			'Four'
 *			'Five'
 *			'(null)'
 *	
 *
 */
char *getstrings(char *source, char *separators, INT bump )
{
	static char *ch;
	register char *sep, *token;

	/* if no source supplied, use the previous one.
	 */

⌨️ 快捷键说明

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