31#ifndef _GARMINPROTOCOLHANDLER_H__
32#define _GARMINPROTOCOLHANDLER_H__
37#include <sys/socket.h>
38#include <netinet/in.h>
52#include <wx/datetime.h>
59#define GSocket GlibGSocket
67#include "conn_params.h"
68#include "dsPortType.h"
74#define PI 3.1415926535897931160E0
77#define TIMER_SOCKET 7006
87#define GARMIN_USB_API_VERSION 1
88#define GARMIN_USB_MAX_BUFFER_SIZE 4096
89#define GARMIN_USB_INTERRUPT_DATA_SIZE 64
91#define IOCTL_GARMIN_USB_API_VERSION \
92 CTL_CODE(FILE_DEVICE_UNKNOWN, 0x800, METHOD_BUFFERED, FILE_ANY_ACCESS)
93#define IOCTL_GARMIN_USB_INTERRUPT_IN \
94 CTL_CODE(FILE_DEVICE_UNKNOWN, 0x850, METHOD_BUFFERED, FILE_ANY_ACCESS)
95#define IOCTL_GARMIN_USB_BULK_OUT_PACKET_SIZE \
96 CTL_CODE(FILE_DEVICE_UNKNOWN, 0x851, METHOD_BUFFERED, FILE_ANY_ACCESS)
100DEFINE_GUID(GARMIN_GUID, 0x2c9c45c2L, 0x8e7d, 0x4c08, 0xa1, 0x2d, 0x81, 0x6b,
101 0xba, 0xe7, 0x22, 0xc0);
107#define GUSB_SESSION_START 5
108#define GUSB_SESSION_ACK 6
109#define GUSB_REQUEST_BULK 2
111#define GUSB_RESPONSE_PVT 51
112#define GUSB_RESPONSE_SDR 114
117 unsigned char reserved1;
118 unsigned char reserved2;
119 unsigned char reserved3;
120 unsigned char pkt_id[2];
121 unsigned char reserved6;
122 unsigned char reserved7;
123 unsigned char datasz[4];
124 unsigned char databuf[5];
126 unsigned char dbuf[1024];
130 unsigned long serial_number;
131 unsigned long unit_id;
132 unsigned long unit_version;
134 char *product_identifier;
186 unsigned char status;
197enum { rs_fromintr, rs_frombulk };
199#define TIMER_GARMIN1 7005
212 void StopIOThread(
bool b_pause);
213 void RestartIOThread(
void);
215 void StopSerialThread(
void);
217 void OnTimerGarmin1(wxTimerEvent &event);
219 bool FindGarminDeviceInterface();
221 wxEvtHandler *m_pMainEventHandler;
229 wxTimer TimerGarmin1;
231 int m_Thread_run_flag;
234 bool m_bneed_int_reset;
241 HANDLE garmin_usb_start();
242 bool ResetGarminUSBDriver();
243 static bool IsGarminPlugged();
244 bool gusb_syncup(
void);
255 WXLRESULT MSWWindowProc(WXUINT message, WXWPARAM wParam, WXLPARAM lParam);
258 DECLARE_EVENT_TABLE()
272 wxEvtHandler *MessageTarget, wxString port);
275 void string(wxCharBuffer mb_str);
278 wxEvtHandler *m_pMessageTarget;
280 void *m_parent_stream;
298 wxEvtHandler *MessageTarget,
unsigned int device_handle,
304 void *m_parent_stream;
310 wxEvtHandler *m_pMessageTarget;