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

📄 g7to.h

📁 这是经典的卫星编程应用程序
💻 H
📖 第 1 页 / 共 4 页
字号:
//
// output binary of garmin protocol
//
#define DEBUGREAD	 0
//=================================================
//  typedefs from the Garmin Protocol Specification
//=================================================
typedef unsigned char byte;
typedef unsigned long longword;
typedef unsigned char boolean;
typedef unsigned char BYTE;

extern int timeonsa3;
#define MAX_LENGTH	255	/* maximum length of Garmin binary message */
#if __BORLANDC__
//================================================================
//================================================================
// Borland compiler
//================================================================
//================================================================
#include <stdio.h>
#include <stdlib.h>
#include <stdarg.h>
#include <string.h>
#include <alloc.h>
#include <bios.h>
#include <conio.h>
#include <dir.h>
#include <dos.h>
#include <fcntl.h>
#include <io.h>
#include <math.h>
#include <mem.h>
#include <signal.h>
#include <time.h>
#include <ctype.h>

#define INT int
#define LONGdouble long double
#define WORD	short
#define	DWORD	long
#define LONG	long
#define MAXTRACK 	4096

INT AsyncInit(INT addr, INT irq);
unsigned INT AsyncStat(void);  
void AsyncSet(INT Baud, INT Control);
void AsyncOut(INT dev);
void AsyncStop(INT IOAddress);
extern struct 	ftime ft;

#if 0
typedef struct tagRGBQUAD { 		// rgbq 
	BYTE    rgbBlue;
	BYTE    rgbGreen; 
	BYTE    rgbRed;
	BYTE    rgbReserved;
} RGBQUAD; 

typedef struct tagBITMAPFILEHEADER {// bmfh
	WORD    bfType; 				// specifies file type--must be BM
	DWORD   bfSize; 				// size in bytes of the bitmap file
	WORD    bfReserved1; 			// must be 0
	WORD    bfReserved2;			// must be 0
	DWORD   bfOffBits;				// offset in bytes from the BITMAPFILEHEADER to the 
									//  bitmap bits
} BITMAPFILEHEADER;

typedef struct tagBITMAPINFOHEADER{ // bmih
	DWORD  biSize; 					// Specifies the number of bytes required by the structure
	LONG   biWidth;					// Specifies the width of the bitmap, in pixels
	LONG   biHeight;				// Specifies the height of the bitmap, in pixels
	WORD   biPlanes;				// Specifies the number of planes for the target device. 
									//  This value must be set to 1. 
	WORD   biBitCount; 				// Specifies the number of bits per pixel.
									//  This value must be 1, 4, 8, 16, 24, or 32. 
	DWORD  biCompression;			// Specifies the type of compression for a compressed
	                                //  bottom-up bitmap (top-down DIBs cannot be compressed). 
									//  It can be one of the following values:
//		  Value			Description 
// 		BI_RGB			An uncompressed format. 
// 		BI_RLE8			A run-length encoded (RLE) format for
//						bitmaps with 8 bits per pixel.  The
//						compression format is a two-byte format
//						consisting of a count byte followed by a byte
//						containing a color index.  For more
//						information, see the following Remarks section.
//		BI_RLE4  		An RLE format for bitmaps with 4 bits per pixel.  The
//						compression format is a two-byte format
//						consisting of a count byte followed by two
//						word-length color indices.  For more
//						information, see the following Remarks section.

// 		BI_BITFIELDS    Specifies that the bitmap is not compressed and that the
//						color table consists of three doubleword color masks that
//						specify the red, green, and blue components, respectively, of
//						each pixel.  This is valid when used with 16- and
//						32-bits-per-pixel bitmaps.

		DWORD  biSizeImage;			// Specifies the size, in bytes, of the image.
									//  This may be set to 0 for BI_RGB bitmaps
		LONG   biXPelsPerMeter;		// Specifies the horizontal resolution, in pixels per meter,
									//  of the target device for the bitmap. An application can
									//  use this value to select a bitmap from a resource group
									//  that best matches the characteristics of the current
									//  device
		LONG   biYPelsPerMeter;		// Specifies the vertical resolution, in pixels per meter,
									//  of the target device for the bitmap
		DWORD  biClrUsed;			// Specifies the number of color indices in the color table
									//  that are actually used by the bitmap. If this value is
									//  zero, the bitmap uses the maximum number of colors
									//  corresponding to the value of the biBitCount member for
									//  the compression mode specified by biCompression
		DWORD  biClrImportant; 		// Specifies the number of color indices that are consideredi
									//  important for displaying the bitmap.
									//  If this value is zero, all colors are important
} BITMAPINFOHEADER; 

typedef struct tagBITMAPINFO {		// bmi
	BITMAPINFOHEADER bmiHeader; 	// Specifies a BITMAPINFOHEADER structure that contains
									//  information about the dimensions and color format
									//  of a DIB. 
	RGBQUAD  bmiColors[1];			// Specifies an array of RGBQUAD or doubleword data
									//  types that define the colors in the bitmap
} BITMAPINFO;
#endif
#else					// not borland compiler
//================================================================
//================================================================
// Visual C++ 5.0 compiler
//================================================================
//================================================================
#define INT short
extern struct	mftime ft;
void AsyncOut(unsigned char *buf, INT count);
void AsyncSet(int wBaudRate, INT wByteSize, INT wStopBits, INT wParity);
INT AsyncInit(char *a);
void AsyncStop(void);
#define MAXTRACK 	65535L
#define LONGdouble double
#include <WINDOWS.H>
#include <stdio.h>
#include <stdlib.h>
#include <stdarg.h>
#include <string.h>
#include <conio.h>
#include <dos.h>
#include <fcntl.h>
#include <io.h>
#include <math.h>
#include <signal.h>
#include <time.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <sys/timeb.h>
#define M_PI        3.14159265358979323846
struct  mftime   {
    unsigned int   ft_tsec  : 5;   // Two second interval
    unsigned int   ft_min   : 6;   // Minutes
    unsigned int   ft_hour  : 5;   // Hours
    unsigned int   ft_day   : 5;   // Days
    unsigned int   ft_month : 4;   // Months
    unsigned int   ft_year  : 7;   // Year
};
#define fnsplit _splitpath
#define strncmpi _strnicmp
#define stricmp _stricmp
extern void delay(long);
extern void conson(void);
extern void consoff(void);
#endif

extern  char ProgramName[MAX_LENGTH];
typedef INT Symbol_Type;
typedef unsigned INT word;
//=======================================
//  typedefs for bitmaps
//=======================================

#define ASY_MAX 4 
#define TIMEOUT 3 // seconds to wait for response from serial port
#define RADtoDEG  57.295779513082322
#define DEGtoRAD  0.017453292519943296

INT kbraw(void);
INT AsyncIn(void);

void AsyncSend(BYTE * message, INT length);
INT AsyncOutStat(void);
INT AsyncInStat(void);

#define COM1 0
#define COM2 1
#define COM3 2
#define COM4 3

#define Pi (double)M_PI

extern	INT route_lines;
extern	int cycle_track_colors;
extern	char months[13][4];
extern	char days[7][4];
extern	char debugin_name[MAX_LENGTH];
/* Messages declarations */
extern	BYTE m1[],     m2[];
extern	BYTE p1[],     p2[];
extern	BYTE alm1[],   alm2[];
extern	BYTE trk1[],   trk2[];
extern	BYTE wpt1[],   wpt2[];
extern	BYTE rte1[],   rte2[],     rte3[];
extern	BYTE almt[],   rtet[],     trkt[],   wptt[];
extern	BYTE pwroff[], GPStimex[], GPSPos[], HDWare[];

struct RECORD {
	char type;			// Record Type W,T,R,D,P
	char ident[41];		// Record ident
	char ns;			//  N/S for latitude
	double la;			// latitude   in dd.ddddddd
	char ew;			//  E/W for longitude
	double lo;			// longitude  in dd.ddddddd
	INT monthn;			// month number of record
	char day_week[4];	// day of week of record
	char datetime[25];	// date/time string as read
	INT dayofmonth;		// day of month 1-31
	INT year;			// 4 digit year of record
	INT ht,mt,st;		// time of record
	INT dla, mla;		// Deg & Min for Lat
	INT dlo, mlo;		// Deg & Min for Long
	INT tnthsla, tnthslo;	// tenths of a minute*10000
	double minla,minlo;	// Lat/Long minutes in decimal
	double secla,seclo;	// Lat/Long seconds in decimal
	float ProxDist;		// Proximity Distance
	short icon_smbl; 	// Garmin smbl coverted to SA
	short icon_dspl;	// Display style.  Consistant with
						//  later garminunits, i.e.
						//
						//  1 = Symbol by itself
						//  2 = Symbol with waypoint name
						//  3 = Symbol with comment

    BYTE color;         //  Waypoint symbol Color for Color units:
                        //
                        //   12CX : 0 - Default waypoint color
                        //          1 - Red
                        //          2 - Green
                        //          3 - Blue
//
// garmin additions from beta.  They are used by various Pilot units
//
	BYTE class;
	BYTE status;		// for Lowrance/Eagle waypoints
	BYTE subclass[13];
	INT alt;
	INT dpth;
	char state[3];
	char cc[3];			// garmin
	char name[31];		// garmin
	char comment[51];   // Comment field 20 max for 45
	char facility[31];  // facility name
	char city[25];      // garmin (24)
	char addr[51];      // address
	char cross_road[51];// intersecting road label
	float altitude;
};

extern struct RECORD record;
struct PREFS{
	short datum;
	long creator;
	double offset;
};
extern struct PREFS gPrefs;

// Garmin message type characters
#define ACK			0x06	// last record received was ok
#define ALM 		0x1f	// Almanac record
#define EOFREC  	0x0c	// EOF leadin for transters
#define GPSpos		0x11	// GPS Position record
#define PROX		0x13	// GPS Proximity Position record
#define MYID		0xff	// Version/ID record
#define NAK			0x15	// last record received was bad
#define NREC		0x1b	// number of records to receive
#define RTE_NAM 	0x1d	// Route name record
#define RTE_WPT 	0x1e	// Route waypoint record
#define TIMEREC 	0x0e	// UTC Time record
#define TRK 		0x22	// Track record
#define WPT 		0x23	// Waypoint record
#define Volts 		0x28	// GPS Voltages record
#define SENDID 		0xfe	// Send ID

/* Defines for Com Port Paramaters, the second paramater to AsyncSet() */
#define BITS_8      0x03
#define BITS_7      0x02
#define STOP_1      0x00
#define STOP_2      0x04
#define EVEN_PARITY 0x18
#define ODD_PARITY  0x08
#define NO_PARITY   0x00

/* Defines for AsyncHand() */
#define	DTR			0x01
#define	RTS			0x02
#define	USER		0x04
#define	LOOPBACK	0x10

/* Defines for AsyncStat() */
#define	D_CTS		0x0100
#define	D_DSR		0x0200
#define	D_RI		0x0400
#define	D_DCD		0x0800
#define	CTS			0x1000
#define	DSR			0x2000
#define	RI			0x4000
#define	DCD			0x8000
#define	PARITY		0x0004
#define	THREMPTY	0x0020
#define	BREAKDET	0x1000

//=======================================
//
// Structures for waypoint records
//
//=======================================

typedef struct
{
	INT product_ID;
	INT software_version;
	byte a[1];  // fake the below by....
// char product_description[]; null-terminated string
// ... zero or more additional null-terminated strings
} Product_Data_Type;

typedef struct
{
	byte tag;
	word data;
} Protocol_Data_Type;

typedef struct
{
	long lat; /* latitude in semicircles */
	long lon; /* longitude in semicircles */
} Semicircle_Type;

//
//  7.5.1. D100_Wpt_Type
typedef struct
{
	char ident[6];			// identifier
	Semicircle_Type posn;	// position
	unsigned long unused;	// should be set to zero
	char cmnt[40];			// comment
} D100_Wpt_Type;

//  7.5.2. D101_Wpt_Type
//
// Example products: GPSMAP 210 and GPSMAP 220 (both prior to version 4.00).
typedef struct
{
	char ident[6];			// identifier
	Semicircle_Type posn;	// position
	longword unused;		// should be set to zero
	char cmnt[40];			// comment
	float dst;				// proximity distance (meters)
	byte smbl;				// symbol id
} D101_Wpt_Type;

//The enumerated values for the "smbl" member of the D101_Wpt_Type
//   are the same as those for Symbol_Type (see Section 7.4.9 on page 28).
//   However, since the "smbl" member of the D101_Wpt_Type is only 8-bits
//   (instead of 16-bits), all Symbol_Type values whose upper byte is
//   non-zero are unallowed in the D101_Wpt_Type.
//7.5.3. D102_Wpt_Type
//
// Example products: GPSMAP 175, GPSMAP 210 and GPSMAP 220.
typedef struct
{
	char ident[6];			// identifier
	Semicircle_Type posn;	// position
	longword unused;		// should be set to zero
	char cmnt[40];			// comment
	float dst;				// proximity distance (meters)
	Symbol_Type smbl;		// symbol id
} D102_Wpt_Type;

//7.5.4. D103_Wpt_Type
// Example products: GPS 12, GPS 12 XL, GPS 48 and GPS II Plus.
typedef struct
{
	char ident[6];			// identifier
	Semicircle_Type posn;	// position
	longword unused;		// should be set to zero
	char cmnt[40];			// comment
	byte smbl;				// symbol id
	byte dspl;				// display option
} D103_Wpt_Type;
// The enumerated values for the "dspl" member of the D103_Wpt_Type
//    are shown below:
//enum
//{
//	dspl_name = 0, /* Display symbol with waypoint name */
//	dspl_none = 1, /* Display symbol by itself */
//	dspl_cmnt = 2 /* Display symbol with comment */
//};

//7.5.5. D104_Wpt_Type
// Example products: GPS III.
typedef struct
{
	char ident[6];			// identifier
	Semicircle_Type posn;	// position
	longword unused;		// should be set to zero
	char cmnt[40];			// comment
	float dst;				// proximity distance (meters)
	Symbol_Type smbl;		// symbol id
	byte dspl;				// display option
} D104_Wpt_Type;
// The enumerated values for the "dspl" member of the 
//   D104_Wpt_Type are shown below:
//enum
//{
//	dspl_smbl_only = 1, /* Display symbol by itself */
//	dspl_smbl_name = 3, /* Display symbol with waypoint name */
//	dspl_smbl_cmnt = 5, /* Display symbol with comment */
//};

⌨️ 快捷键说明

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