home *** CD-ROM | disk | FTP | other *** search
- // GpsSocket.cpp : implementation file
- //
-
- #include "stdafx.h"
- #include "gpsnk.h"
- #include "GpsSocket.h"
-
- #ifdef _DEBUG
- #define new DEBUG_NEW
- #undef THIS_FILE
- static char THIS_FILE[] = __FILE__;
- #endif
-
- /////////////////////////////////////////////////////////////////////////////
- // CGpsSocket
-
- CGpsSocket::CGpsSocket()
- { m_pDlg= NULL;
- }
- CGpsSocket::CGpsSocket(CDialog* pDlg)
- {
- m_pDlg= pDlg;
- }
-
- CGpsSocket::~CGpsSocket()
- {
- }
-
-
- // Do not edit the following lines, which are needed by ClassWizard.
- #if 0
- BEGIN_MESSAGE_MAP(CGpsSocket, CAsyncSocket)
- //{{AFX_MSG_MAP(CGpsSocket)
- //}}AFX_MSG_MAP
- END_MESSAGE_MAP()
- #endif // 0
-
- /////////////////////////////////////////////////////////////////////////////
- // CGpsSocket member functions
-
- void CGpsSocket::OnReceive(int nErrorCode)
- {
- // TODO: Add your specialized code here and/or call the base class
-
- // Get datagram that came from GPS source.
- char buf[512+1];
- int num= Receive(buf, 512);
- buf[num]= '\0';
-
- // Expected format: "DDD1:MM1:SS1 DDD2:MM2:SS2" where
- // DD1:MM1:SS1 is the longitude value and
- // DD2:MM2:SS2 is the latitude value.
- CString strLon;
- CString strLat;
- char* sep= " ";
- char* p= strtok(buf,sep);
- strLon= p; // Longitude value
- p= strtok(NULL, sep);
- strLat= p; // Latitude value
-
- // Now update the edit controls in the dialog.
- CEdit* pEdit;
- pEdit= (CEdit*) m_pDlg->GetDlgItem(IDC_EDIT_LON);
- pEdit->SetWindowText(strLon);
- pEdit= (CEdit*) m_pDlg->GetDlgItem(IDC_EDIT_LAT);
- pEdit->SetWindowText(strLat);
- }
-