31 #ifndef _GARMINPROTOCOLHANDLER_H__
32 #define _GARMINPROTOCOLHANDLER_H__
38 #include <sys/socket.h>
39 #include <netinet/in.h>
47 #include <wx/wxprec.h>
53 #include <wx/datetime.h>
60 #define GSocket GlibGSocket
61 #include <wx/socket.h>
64 #include <wx/socket.h>
67 #include "garminusb.h"
68 #include "model/conn_params.h"
69 #include "model/ds_porttype.h"
75 #define PI 3.1415926535897931160E0
78 #define TIMER_SOCKET 7006
88 #define GARMIN_USB_API_VERSION 1
89 #define GARMIN_USB_MAX_BUFFER_SIZE 4096
90 #define GARMIN_USB_INTERRUPT_DATA_SIZE 64
92 #define IOCTL_GARMIN_USB_API_VERSION \
93 CTL_CODE(FILE_DEVICE_UNKNOWN, 0x800, METHOD_BUFFERED, FILE_ANY_ACCESS)
94 #define IOCTL_GARMIN_USB_INTERRUPT_IN \
95 CTL_CODE(FILE_DEVICE_UNKNOWN, 0x850, METHOD_BUFFERED, FILE_ANY_ACCESS)
96 #define IOCTL_GARMIN_USB_BULK_OUT_PACKET_SIZE \
97 CTL_CODE(FILE_DEVICE_UNKNOWN, 0x851, METHOD_BUFFERED, FILE_ANY_ACCESS)
101 DEFINE_GUID(GARMIN_GUID, 0x2c9c45c2L, 0x8e7d, 0x4c08, 0xa1, 0x2d, 0x81, 0x6b,
102 0xba, 0xe7, 0x22, 0xc0);
108 #define GUSB_SESSION_START 5
109 #define GUSB_SESSION_ACK 6
110 #define GUSB_REQUEST_BULK 2
112 #define GUSB_RESPONSE_PVT 51
113 #define GUSB_RESPONSE_SDR 114
116 unsigned long serial_number;
117 unsigned long unit_id;
118 unsigned long unit_version;
120 char *product_identifier;
124 #pragma pack(push, 1)
168 unsigned char status;
179 enum { rs_fromintr, rs_frombulk };
181 #define TIMER_GARMIN1 7005
194 void StopIOThread(
bool b_pause);
195 void RestartIOThread(
void);
197 void StopSerialThread(
void);
199 void OnTimerGarmin1(wxTimerEvent &event);
201 bool FindGarminDeviceInterface();
203 wxEvtHandler *m_pMainEventHandler;
211 wxTimer TimerGarmin1;
213 std::atomic_int m_Thread_run_flag;
216 bool m_bneed_int_reset;
223 HANDLE garmin_usb_start();
224 bool ResetGarminUSBDriver();
225 static bool IsGarminPlugged();
226 bool gusb_syncup(
void);
228 int gusb_win_get(garmin_usb_packet *ibuf,
size_t sz);
229 int gusb_win_get_bulk(garmin_usb_packet *ibuf,
size_t sz);
230 int gusb_win_send(
const garmin_usb_packet *opkt,
size_t sz);
232 int gusb_cmd_send(
const garmin_usb_packet *opkt,
size_t sz);
233 int gusb_cmd_get(garmin_usb_packet *ibuf,
size_t sz);
237 WXLRESULT MSWWindowProc(WXUINT message, WXWPARAM wParam, WXLPARAM lParam);
240 DECLARE_EVENT_TABLE()
254 wxEvtHandler *MessageTarget, wxString port);
257 void string(wxCharBuffer mb_str);
260 wxEvtHandler *m_pMessageTarget;
279 wxEvtHandler *MessageTarget,
unsigned int device_handle,
285 int gusb_win_get(garmin_usb_packet *ibuf,
size_t sz);
286 int gusb_win_get_bulk(garmin_usb_packet *ibuf,
size_t sz);
287 int gusb_cmd_get(garmin_usb_packet *ibuf,
size_t sz);
289 wxEvtHandler *m_pMessageTarget;