/*
Module : GPS.CPP
Purpose: "C" style Implementation to GPS32
Created: PJN / 28-12-1997
History: PJN / 20-01-1998 1. A number of problems were discovered when GPSLIB was being
used in a UNICODE build. These problems have been fixed
2. Mak file now includes all the possible build options
3. Mak file no longer hard codes output to d:\winnt\system32
4. Included release binaries in distribution
PJN / 26-08-1998 1. Small change to stdafx.h to include afxcview.h in gps32exe
2. The GpsShowControlPanel function now actually works
3. Minor tweaks to the GPS Mak files
4. Removed a number of unused symbols
5. Change ID of a number of GPS32EXE menu items to avoid conflict
with new VC 6 defines.
6. Updated all Version Infos to 1.02
7. Removed a level 4 warning from the Test app.
8. Removed unused toolbar from GPS CPL file
9. GPS cpl file now uses standard F2 accelerator for Rename
10. GPS32EXE toolbar is now shown flat
11. Number of extra TRACE statements have been added to
aid in debugging.
PJN / 11-08-1999 1. Now uses the WINAPI calling convention meaning that GPSLIB is now
callable from VB.
2. Now also ships a GPS.BAS file for use of GPSLIB in VB
PJN / 27-09-2001 1. Fixed a problem where the background serial port thread using causing
heavy CPU utilization.
2. Updated the project settings so that all binaries get build to the Bin
directory and all Lib files get created in a Lib directory
3. Updated the version info's in all the binaries
4. Updated the copyright message in the code modules
PJN / 21-08-2002 1. Fixed a synchronisation problem between the worker thread and the
GpsGetPosition method. Thanks to Bill Oatman for spotting this problem.
Copyright (c) 1997 - 2002 by PJ Naughter. (Web: www.naughter.com, Email: pjna@naughter.com)
All rights reserved.
Copyright / Usage Details:
You are allowed to include the source code in any product (commercial, shareware, freeware or otherwise)
when your product is released in binary form. You are allowed to modify the source code in any way you want
except you cannot modify the copyright details at the top of each module. If you want to distribute source
code with your application, then you are only allowed to distribute versions released by the author. This is
to maintain a single distribution point for the source code.
*/
///////////////////////////////// Includes //////////////////////////////////
#include "stdafx.h"
#include "gps.h"
#include "serport.h"
#include "resource.h"
#include "nmea.h"
#include "math.h"
#include "gpssetup.h"
////////////////////////////////// Macros / Defines //////////////////////////
#ifdef _DEBUG
#undef THIS_FILE
static char BASED_CODE THIS_FILE[] = __FILE__;
#define new DEBUG_NEW
#endif
////////////////////////////////// Locals /////////////////////////////////////
class GPSHandle
{
public:
GPSHandle();
~GPSHandle();
GPSPOSITION m_Position; //the actual data
CEvent* m_pKillEvent; //Event to signal thread to exit
CEvent* m_pStartEvent; //Is the background thread running
GPSDEVINFO m_DevInfo; //Settings of the comms port to use
BOOL m_bRunning; //Is the background thread running
CWinThread* m_pThread; //The pointer to the background thread
CCriticalSection m_csPosition; //Critical section used to serialized access to m_Position
};
BOOL GetGpsDevice(DWORD dwDevice, LPGPSDEVINFO lpGpsDevInfo);
BOOL SetGpsDevice(DWORD dwDevice, LPCGPSDEVINFO lpGpsDevInfo, BOOL bCheckDefault = TRUE);
BOOL SetGpsNumDevices(DWORD dwDevices);
UINT GpsMonitorThead(LPVOID pParam);
////////////////////////////////// Implementation /////////////////////////////
GPSHandle::GPSHandle()
{
ZeroMemory(&m_Position, sizeof(GPSPOSITION));
m_pKillEvent = new CEvent(FALSE, TRUE);
m_pStartEvent = new CEvent(FALSE, TRUE);
m_pThread = NULL;
}
GPSHandle::~GPSHandle()
{
delete m_pStartEvent;
m_pStartEvent = NULL;
delete m_pKillEvent;
m_pKillEvent = NULL;
}
BOOL GetGpsDevice(DWORD dwDevice, LPGPSDEVINFO lpGpsDevInfo)
{
BOOL bSuccess = FALSE;
HKEY hKey;
CString sValueKey;
sValueKey.Format(_T("SOFTWARE\\PJ Naughter\\GPS32\\%d"), dwDevice);
LONG nError = RegOpenKeyEx(HKEY_LOCAL_MACHINE, sValueKey, 0, KEY_ALL_ACCESS, &hKey);
if (nError == ERROR_SUCCESS)
{
DWORD dwType;
DWORD dwSize;
RegQueryValueEx(hKey, _T("DeviceName"), 0, &dwType, NULL, &dwSize);
TCHAR* pszName = new TCHAR[dwSize / sizeof(TCHAR)];
RegQueryValueEx(hKey, _T("DeviceName"), 0, &dwType, (LPBYTE) pszName, &dwSize);
_tcscpy(lpGpsDevInfo->szDeviceName, pszName);
delete [] pszName;
RegQueryValueEx(hKey, _T("DefaultReceiver"), 0, &dwType, (LPBYTE) &lpGpsDevInfo->bDefaultReceiver, &dwSize);
RegQueryValueEx(hKey, _T("Port"), 0, &dwType, (LPBYTE) &lpGpsDevInfo->wCommPort, &dwSize);
RegQueryValueEx(hKey, _T("BaudRate"), 0, &dwType, (LPBYTE) &lpGpsDevInfo->dwCommBaudRate, &dwSize);
RegQueryValueEx(hKey, _T("DataBits"), 0, &dwType, (LPBYTE) &lpGpsDevInfo->wCommDataBits, &dwSize);
RegQueryValueEx(hKey, _T("StopBits"), 0, &dwType, (LPBYTE) &lpGpsDevInfo->wCommStopBits, &dwSize);
bSuccess = TRUE;
RegCloseKey(hKey);
}
else
{
TRACE(_T("GetGpsDevice, Failed to open a registry key, Error was: %d\n"), nError);
}
return bSuccess;
}
BOOL GpsSetNumDevices(DWORD dwDevices)
{
BOOL bSuccess = FALSE;
HKEY hKey;
DWORD dwDisposition;
LONG nError = RegCreateKeyEx(HKEY_LOCAL_MACHINE, _T("SOFTWARE\\PJ Naughter\\GPS32"), 0, _T(""),
REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL, &hKey, &dwDisposition);
if (nError == ERROR_SUCCESS)
{
RegSetValueEx(hKey, _T("NumberOfDevices"), 0, REG_DWORD, (CONST BYTE*) &dwDevices, sizeof(DWORD));
RegCloseKey(hKey);
bSuccess = TRUE;
}
else
{
TRACE(_T("GpsSetNumDevices, Failed in call to create a registry key, Error was: %d\n"), nError);
}
return bSuccess;
}
BOOL SetGpsDevice(DWORD dwDevice, LPCGPSDEVINFO lpDevice, BOOL bCheckDefault)
{
//Fix up the case where we have just made this device
//the default by removing the default flag from all
//other devices
if (bCheckDefault && lpDevice->bDefaultReceiver)
{
//make all other devices non default
for (DWORD i=0; i<GpsGetNumDevices(); i++)
{
GPSDEVINFO devInfo;
GetGpsDevice(i, &devInfo);
devInfo.bDefaultReceiver = FALSE;
SetGpsDevice(i, &devInfo, FALSE);
}
}
BOOL bSuccess = FALSE;
HKEY hKey;
DWORD dwDisposition;
CString sValueKey;
sValueKey.Format(_T("SOFTWARE\\PJ Naughter\\GPS32\\%d"), dwDevice);
LONG nError = RegCreateKeyEx(HKEY_LOCAL_MACHINE, sValueKey, 0, _T(""), REG_OPTION_NON_VOLATILE,
KEY_ALL_ACCESS, NULL, &hKey, &dwDisposition);
if (nError == ERROR_SUCCESS)
{
RegSetValueEx(hKey, _T("DeviceName"), 0, REG_SZ, (CONST BYTE*) lpDevice->szDeviceName, _tcslen(lpDevice->szDeviceName));
RegSetValueEx(hKey, _T("DefaultReceiver"), 0, REG_DWORD, (CONST BYTE*) &lpDevice->bDefaultReceiver, sizeof(BOOL));
DWORD dwData = lpDevice->wCommPort;
RegSetValueEx(hKey, _T("Port"), 0, REG_DWORD, (CONST BYTE*) &dwData, sizeof(DWORD));
没有合适的资源?快使用搜索试试~ 我知道了~
一款GPS软件的源代码
共106个文件
h:23个
cpp:18个
def:8个
3星 · 超过75%的资源 需积分: 10 93 下载量 87 浏览量
2009-06-10
13:53:30
上传
评论 1
收藏 3.81MB RAR 举报
温馨提示
GPSLibsrc 一个关于GPS学习的软件,使用可靠。 有关如何获取GPS信息的软件,又源代码。
资源推荐
资源详情
资源评论
收起资源包目录
一款GPS软件的源代码 (106个子文件)
Gps32.001 9KB
GPSCPL.001 8KB
GPS32EXE.001 7KB
TestGPS.001 6KB
gps.bas 2KB
wizinstall.bmp 28KB
MAINFRAM.BMP 2KB
BIGIL.BMP 1KB
Toolbar.bmp 1KB
SMALLIL.BMP 374B
Gps.cpp 24KB
SerialPort.cpp 17KB
GPSSETUP.CPP 11KB
GPSGuiView.cpp 10KB
NMEA.CPP 8KB
FlatBar.cpp 7KB
TestGPSDlg.cpp 6KB
SERPORT.CPP 4KB
CTRLPAN.CPP 2KB
MainFrm.cpp 2KB
Gpscpl.cpp 1KB
App.cpp 771B
GPSGuiDoc.cpp 747B
TestGPS.cpp 576B
GPSLib.cpp 312B
StdAfx.cpp 205B
StdAfx.cpp 204B
StdAfx.cpp 204B
GPS32u.def 544B
GPS32ud.def 543B
Gps32.def 541B
GPS32d.def 540B
Gpscpld.def 131B
Gpscpl.def 130B
Gpscplud.def 129B
Gpscplu.def 128B
Gps32.dsp 9KB
GPSCPL.DSP 8KB
GPS32EXE.DSP 7KB
TestGPS.dsp 6KB
Gps32.dsw 1KB
Form1.frm 12KB
GPSLIB.GIF 1KB
Gps.h 4KB
GPSSETUP.H 4KB
RESOURCE.H 4KB
SerialPort.h 3KB
NMEA.H 3KB
GPSGuiView.h 2KB
resource.h 2KB
Resource.h 1KB
SERPORT.H 1KB
TestGPSDlg.h 1KB
FlatBar.h 925B
CTRLPAN.H 812B
MainFrm.h 743B
GPSGuiDoc.h 709B
GPSCPL.H 653B
Response.h 632B
RESOURCE.H 543B
TestGPS.h 429B
App.h 401B
GPSLib.h 393B
StdAfx.h 331B
StdAfx.h 250B
StdAfx.h 250B
BuildLog.htm 6KB
BuildLog.htm 6KB
BuildLog.htm 5KB
BuildLog.htm 5KB
MAINFRM.ICO 9KB
MAINFRM.ICO 9KB
MAINFRM.ICO 1KB
MAINFRM.ICO 1KB
properties.ico 766B
vc90.idb 19KB
vc90.idb 19KB
vc90.idb 19KB
vc90.idb 19KB
GPS103d.dll.embed.manifest 2KB
GPS103d.cpl.embed.manifest 2KB
TestGPS.exe.embed.manifest 2KB
GPS103d.exe.embed.manifest 2KB
Gps32.ncb 13.45MB
Gps32.opt 64KB
vc90.pdb 36KB
vc90.pdb 36KB
vc90.pdb 36KB
vc90.pdb 36KB
GPSLib.rc 13KB
GPS32EXE.rc 11KB
TestGPS.rc 6KB
GPSCPL.rc 3KB
TestGPS.rc2 399B
GPSLib.rc2 398B
Gps32.sln 4KB
Gps32.suo 12KB
TestGPS.vcproj.PC3.Administrator.user 3KB
GPS32EXE.vcproj.PC3.Administrator.user 3KB
Gps32.vcproj.PC3.Administrator.user 3KB
共 106 条
- 1
- 2
资源评论
- raoxing012011-10-27也没有什么说明性的文档,调试不知道怎么老是出错。
- 普通网友2015-08-13还行,不过数据解析不全
嗨炉
- 粉丝: 2
- 资源: 7
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功