40 #define __FILE_ID__ "ypkt_win" 42 #if defined(WINDOWS_API) && !defined(WINCE) 45 #ifdef LOG_DEVICE_PATH 46 #define DP(PATH) (PATH) 48 #define DP(PATH) "..." 52 #define SPDRP_INSTALL_STATE (0x00000022) 53 #define _TRUNCATE ((size_t)-1) 56 #define yWinSetErr(iface,errmsg) yWinSetErrEx(__LINE__,iface,GetLastError(),"",errmsg) 58 static int yWinSetErrEx(u32 line,
yInterfaceSt *iface, DWORD err,
const char *msg,
char *errmsg)
70 FORMAT_MESSAGE_FROM_SYSTEM |
71 FORMAT_MESSAGE_IGNORE_INSERTS,
74 MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
75 (LPSTR)(errmsg + len),
91 FORMAT_MESSAGE_FROM_SYSTEM |
92 FORMAT_MESSAGE_IGNORE_INSERTS,
95 MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
96 (LPSTR)(errmsg + len),
104 static u32 decodeHex(
const char *p,
int nbdigit)
108 for (i = nbdigit - 1; i >= 0; i--, p++) {
110 if (*p >=
'a' && *p <=
'f') {
111 digit = 10 + *p -
'a';
112 }
else if (*p >=
'A' && *p <=
'F') {
113 digit = 10 + *p -
'A';
114 }
else if (*p >=
'0' && *p <=
'9') {
119 ret += digit << (4 * i);
127 #define FIRST_NOT_OF 2 129 static char* findDelim(
char *str,
const char *delimiters,
const int nbdelim,
const int mode)
134 for (d = 0; d < nbdelim; d++) {
135 if (*str == delimiters[d]) {
139 if (mode == FIRST_OF) {
154 void DecodeHardwareid(
char *str, u32 *vendorid, u32 *deviceid, u32 *release, u32 *iface)
156 const char *delim =
"\\&?";
157 char *token_start, *token_stop;
158 token_start = findDelim(str, delim, 4, FIRST_NOT_OF);
159 token_stop = findDelim(token_start, delim, 4, FIRST_OF);
160 *vendorid = *deviceid = *release = *iface = 0;
161 while (token_start != token_stop) {
162 if (
YSTRNICMP(token_start,
"VID_", 4) == 0) {
163 *vendorid = decodeHex(token_start + 4, 4);
164 }
else if (
YSTRNICMP(token_start,
"PID_", 4) == 0) {
165 *deviceid = decodeHex(token_start + 4, 4);
166 }
else if (
YSTRNICMP(token_start,
"REV_", 4) == 0) {
167 *release = decodeHex(token_start + 4, 4);
168 }
else if (
YSTRNICMP(token_start,
"MI_", 3) == 0) {
169 *iface = decodeHex(token_start + 3, 2);
171 token_start = findDelim(token_stop, delim, 2, FIRST_NOT_OF);
172 token_stop = findDelim(token_start, delim, 2, FIRST_OF);
178 static int getProcName(
char *buffer,
int buffer_size)
182 DWORD pid = GetCurrentProcessId();
186 hProcessSnap = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0);
187 if (hProcessSnap == INVALID_HANDLE_VALUE) {
188 dbglog(
"CreateToolhelp32Snapshot (of processes)\n");
193 pe32.dwSize =
sizeof(PROCESSENTRY32);
197 if (!Process32First(hProcessSnap, &pe32)) {
198 dbglog(
"Process32First error\n");
199 CloseHandle(hProcessSnap);
206 if (pid == pe32.th32ProcessID) {
208 YSTRCPY(buffer, buffer_size, pe32.szExeFile);
210 #if defined(_MSC_VER) && (_MSC_VER > MSC_VS2003) 213 wcstombs_s(&len, buffer, buffer_size, (
wchar_t*)pe32.szExeFile, _TRUNCATE);
216 wcstombs(buffer, (
wchar_t*)pe32.szExeFile, buffer_size);
222 }
while (Process32Next(hProcessSnap, &pe32));
223 buffer[buffer_size - 1] = 0;
224 CloseHandle(hProcessSnap);
230 #define LEGACY_YOCTOPUCE_KEY "Software\\Yoctopuce\\" 231 #define USB_LOCK_KEY "Software\\Yoctopuce\\usb_lock\\" 232 #ifndef KEY_WOW64_32KEY 234 #define KEY_WOW64_32KEY 0 237 static int yConvertUSBLockKey(
yContextSt *ctx,
int deletekey)
241 res = ctx->registry.yRegOpenKeyEx(HKEY_LOCAL_MACHINE, LEGACY_YOCTOPUCE_KEY, 0, KEY_WRITE | KEY_READ | KEY_WOW64_32KEY, &key);
242 if (res == ERROR_SUCCESS) {
244 char process_name[512];
246 DWORD value_length = 32;
247 res = ctx->registry.yRegQueryValueEx(key,
"process_id", NULL, NULL, (LPBYTE)buffer, &value_length);
248 if (res != ERROR_SUCCESS) {
252 res = ctx->registry.yRegQueryValueEx(key,
"process_name", NULL, NULL, (LPBYTE)process_name, &value_length);
253 if (res != ERROR_SUCCESS) {
258 ctx->registry.yRegCloseKey(key);
259 res = ctx->registry.yRegDeleteKeyEx(HKEY_LOCAL_MACHINE, LEGACY_YOCTOPUCE_KEY, KEY_WOW64_32KEY, 0);
261 ctx->registry.yRegDeleteValue(key,
"process_id");
262 ctx->registry.yRegDeleteValue(key,
"process_name");
263 ctx->registry.yRegCloseKey(key);
266 res = ctx->registry.yRegCreateKeyEx(HKEY_LOCAL_MACHINE, USB_LOCK_KEY, 0, NULL, REG_OPTION_NON_VOLATILE, KEY_WRITE | KEY_READ | KEY_WOW64_32KEY, NULL, &key, NULL);
268 if (ctx->registry.yRegSetValueEx(key,
"process_id", 0, REG_SZ, (BYTE*)buffer,
YSTRLEN(buffer)) != ERROR_SUCCESS) {
269 dbglog(
"Unable to set registry value yapi_process");
271 if (ctx->registry.yRegSetValueEx(key,
"process_name", 0, REG_SZ, (BYTE*)process_name,
YSTRLEN(process_name)) != ERROR_SUCCESS) {
272 dbglog(
"Unable to set registry value yapi_process");
274 ctx->registry.yRegCloseKey(key);
283 static int yReserveGlobalAccess(
yContextSt *ctx,
char * errmsg)
286 char process_name[512];
288 DWORD value_length = 512;
294 if (ctx->registry.hREG != NULL) {
295 res = ctx->registry.yRegCreateKeyEx(HKEY_LOCAL_MACHINE, USB_LOCK_KEY, 0, NULL, REG_OPTION_NON_VOLATILE, KEY_WRITE | KEY_READ | KEY_WOW64_32KEY, NULL, &key, NULL);
296 if (res == ERROR_CHILD_MUST_BE_VOLATILE) {
297 yConvertUSBLockKey(ctx, 1);
298 res = ctx->registry.yRegCreateKeyEx(HKEY_LOCAL_MACHINE, USB_LOCK_KEY, 0, NULL, REG_OPTION_NON_VOLATILE, KEY_WRITE | KEY_READ | KEY_WOW64_32KEY, NULL, &key, NULL);
299 if (res != ERROR_SUCCESS) {
302 }
else if (res == ERROR_SUCCESS) {
303 yConvertUSBLockKey(ctx, 0);
311 ctx->apiLock = CreateMailslotA(
"\\\\.\\mailslot\\yoctopuce_yapi", 8, 0, NULL);
312 ctx->nameLock = CreateMailslotA(
"\\\\.\\mailslot\\yoctopuce_yapi_name", 8, 0, NULL);
313 if (ctx->apiLock == INVALID_HANDLE_VALUE) {
317 if (has_reg_key && ctx->nameLock == INVALID_HANDLE_VALUE) {
319 res = ctx->registry.yRegQueryValueEx(key,
"process_id", NULL, NULL, (LPBYTE)buffer, &value_length);
320 if (res == ERROR_SUCCESS) {
324 res = ctx->registry.yRegQueryValueEx(key,
"process_name", NULL, NULL, (LPBYTE)process_name, &value_length);
325 if (res == ERROR_SUCCESS && pid >= 0) {
326 char current_name[512];
327 getProcName(current_name, 512);
328 if (
YSTRCMP(process_name, current_name)) {
329 YSPRINTF(errmsg,
YOCTO_ERRMSG_LEN,
"Another process named %s (pid %"FMTs64
") is already using yAPI", process_name, pid);
338 int pid = getProcName(process_name, 512);
340 if (ctx->registry.yRegSetValueEx(key,
"process_id", 0, REG_SZ, (BYTE*)buffer,
YSTRLEN(buffer)) != ERROR_SUCCESS) {
341 dbglog(
"Unable to set registry value yapi_process");
343 if (ctx->registry.yRegSetValueEx(key,
"process_name", 0, REG_SZ, (BYTE*)process_name,
YSTRLEN(process_name)) != ERROR_SUCCESS) {
344 dbglog(
"Unable to set registry value yapi_process");
349 ctx->registry.yRegCloseKey(key);
355 static void yReleaseGlobalAccess(
yContextSt *ctx)
357 CloseHandle(ctx->apiLock);
358 ctx->apiLock = INVALID_HANDLE_VALUE;
359 CloseHandle(ctx->nameLock);
360 ctx->nameLock = INVALID_HANDLE_VALUE;
367 ctx->registry.hREG = LoadLibraryA(
"Advapi32.dll");
368 if (ctx->registry.hREG != NULL) {
370 ctx->registry.yRegCreateKeyEx = (PYRegCreateKeyEx)GetProcAddress(ctx->registry.hREG,
"RegCreateKeyExA");
371 ctx->registry.yRegOpenKeyEx = (PYRegOpenKeyEx)GetProcAddress(ctx->registry.hREG,
"RegOpenKeyExA");
372 ctx->registry.yRegSetValueEx = (PYRegSetValueEx)GetProcAddress(ctx->registry.hREG,
"RegSetValueExA");
373 ctx->registry.yRegQueryValueEx = (PYRegQueryValueEx)GetProcAddress(ctx->registry.hREG,
"RegQueryValueExA");
374 ctx->registry.yRegDeleteValue = (PYRegDeleteValue)GetProcAddress(ctx->registry.hREG,
"RegDeleteValueA");
375 ctx->registry.yRegCloseKey = (PYRegCloseKey)GetProcAddress(ctx->registry.hREG,
"RegCloseKey");
376 ctx->registry.yRegDeleteKeyEx = (PYRegDeleteKeyEx)GetProcAddress(ctx->registry.hREG,
"RegDeleteKeyExA");
380 YPROPERR(yReserveGlobalAccess(ctx, errmsg));
381 ctx->hid.hHID = LoadLibraryA(
"HID.DLL");
382 if (ctx->hid.hHID == NULL) {
383 return yWinSetErr(NULL, errmsg);
386 ctx->hid.GetHidGuid = (PHidD_GetHidGuid)GetProcAddress(ctx->hid.hHID,
"HidD_GetHidGuid");
387 ctx->hid.GetAttributes = (PHidD_GetAttributes)GetProcAddress(ctx->hid.hHID,
"HidD_GetAttributes");
388 ctx->hid.GetManufacturerString = (PHidD_GetManufacturerString)GetProcAddress(ctx->hid.hHID,
"HidD_GetManufacturerString");
389 ctx->hid.GetProductString = (PHidD_GetProductString)GetProcAddress(ctx->hid.hHID,
"HidD_GetProductString");
390 ctx->hid.GetSerialNumberString = (PHidD_GetSerialNumberString)GetProcAddress(ctx->hid.hHID,
"HidD_GetSerialNumberString");
391 ctx->hid.SetNumInputBuffers = (PHidD_SetNumInputBuffers)GetProcAddress(ctx->hid.hHID,
"HidD_SetNumInputBuffers");
402 yFree(ctx->prevEnum);
403 ctx->prevEnum = NULL;
405 ctx->prevEnumCnt = 0;
406 yReleaseGlobalAccess(ctx);
419 PSP_DEVICE_INTERFACE_DETAIL_DATA_A pDetailedInterfaceData;
421 GUID InterfaceClassGuid;
423 HDEVINFO DeviceInfoTable = INVALID_HANDLE_VALUE;
429 yContext->hid.GetHidGuid(&InterfaceClassGuid);
430 DeviceInfoTable = SetupDiGetClassDevs(&InterfaceClassGuid, NULL, NULL, DIGCF_PRESENT | DIGCF_DEVICEINTERFACE);
431 if (DeviceInfoTable == INVALID_HANDLE_VALUE) {
432 return yWinSetErr(NULL, errmsg);
435 pDetailedInterfaceData = (PSP_DEVICE_INTERFACE_DETAIL_DATA_A)buffer;
438 nbifaceAlloc =
yContext->prevEnumCnt + 8;
440 memset(*ifaces, 0, nbifaceAlloc *
sizeof(
yInterfaceSt));
444 u32 vendorid, deviceid, release, ifaceno, inst_state;
445 SP_DEVINFO_DATA DevInfoData;
447 DevInfoData.cbSize =
sizeof(SP_DEVINFO_DATA);
448 if (!SetupDiEnumDeviceInfo(DeviceInfoTable, index, &DevInfoData)) {
453 SetupDiGetDeviceRegistryPropertyA(DeviceInfoTable, &DevInfoData, SPDRP_HARDWAREID, NULL, (PBYTE)buffer, 512, NULL);
455 DecodeHardwareid(buffer + 4, &vendorid, &deviceid, &release, &ifaceno);
457 SetupDiGetDeviceRegistryProperty(DeviceInfoTable, &DevInfoData, SPDRP_INSTALL_STATE, NULL, (PBYTE)&inst_state,
sizeof(inst_state), &needsize);
459 SP_DEVICE_INTERFACE_DATA InterfaceData;
461 int find, retry = 16;
464 if (*nbifaceDetect == nbifaceAlloc) {
468 memset(tmp, 0, newsize);
474 iface = *ifaces + *nbifaceDetect;
479 InterfaceData.cbSize =
sizeof(SP_DEVICE_INTERFACE_DATA);
480 if (!SetupDiEnumDeviceInterfaces(DeviceInfoTable, &DevInfoData, &InterfaceClassGuid, 0, &InterfaceData)) {
481 dbglog(
"Fail to retrieve DeviceInterfaces");
484 SetupDiGetDeviceInterfaceDetailA(DeviceInfoTable, &InterfaceData, NULL, 0, &needsize, NULL);
486 dbglog(
"buffer too small");
489 pDetailedInterfaceData->cbSize =
sizeof(SP_DEVICE_INTERFACE_DETAIL_DATA_A);
490 SetupDiGetDeviceInterfaceDetailA(DeviceInfoTable, &InterfaceData, pDetailedInterfaceData, needsize, NULL, NULL);
492 for (find = 0; find <
yContext->prevEnumCnt; find++) {
493 if (
YSTRCMP(iface->devicePath,
yContext->prevEnum[find].devicePath) == 0)
break;
495 if (find < yContext->prevEnumCnt) {
499 HALLOG(
"Get serial for %s\n", pDetailedInterfaceData->DevicePath);
500 control = CreateFileA(pDetailedInterfaceData->DevicePath, 0, FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, OPEN_EXISTING, 0, 0);
501 if (control == INVALID_HANDLE_VALUE) {
502 dbglog(
"Unable to open device %s to get serial\n", pDetailedInterfaceData->DevicePath);
506 dbglog(
"Unable to get serial for %s (%d), retrying (%d)\n", pDetailedInterfaceData->DevicePath, GetLastError(), retry);
510 dbglog(
"Unable to get serial for %s (%d), giving up\n", pDetailedInterfaceData->DevicePath, GetLastError());
511 CloseHandle(control);
514 #if defined(_MSC_VER) && (_MSC_VER > MSC_VS2003) 522 CloseHandle(control);
526 HALENUMLOG(
"----Running Dev %x:%x:%d:%s ---\n", vendorid, deviceid, ifaceno, iface->
serial);
527 #ifdef LOG_DEVICE_PATH 528 HALENUMLOG(
"----DevicePath %s ---\n", iface->devicePath);
531 HALENUMLOG(
"----Running Firm %x:%x:%d:%s ---\n", vendorid, deviceid, ifaceno, iface->
serial);
538 if (!SetupDiDestroyDeviceInfoList(DeviceInfoTable)) {
539 HALLOG(
"Unable to unallocated Device Info Table (%d)", GetLastError());
543 yContext->prevEnumCnt = *nbifaceDetect;
544 if (*nbifaceDetect > 0) {
564 if (
YSTRCMP(dev->
iface.devicePath, newiface->devicePath) != 0) {
584 iface->wrHDL = INVALID_HANDLE_VALUE;
586 iface->wrHDL = CreateFileA(iface->devicePath, GENERIC_WRITE | GENERIC_READ,
587 FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, OPEN_EXISTING, 0, 0);
588 if (iface->wrHDL == INVALID_HANDLE_VALUE) {
590 res = yWinSetErr(iface, errmsg);
600 if (iface->wrHDL != INVALID_HANDLE_VALUE) {
601 CloseHandle(iface->wrHDL);
602 iface->wrHDL = INVALID_HANDLE_VALUE;
614 iface->rdHDL = CreateFileA(iface->devicePath, GENERIC_WRITE | GENERIC_READ,
615 FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, OPEN_EXISTING, FILE_FLAG_OVERLAPPED, 0);
616 if (iface->rdHDL == INVALID_HANDLE_VALUE) {
617 res = yWinSetErr(iface, errmsg);
618 HALLOG(
"OpenReadHandles of %s error %d of %s:%d (%s)\n", DP(iface->devicePath), res, iface->
serial, iface->
ifaceno, errmsg);
622 setbuffres =
yContext->hid.SetNumInputBuffers(iface->rdHDL, 256);
624 res = yWinSetErr(iface, errmsg);
625 dbglog(
"SetNumInputBuffers of %s error %d of %s:%d (%s)\n", DP(iface->devicePath), res, iface->
serial, iface->
ifaceno, errmsg);
630 res = yWinSetErr(iface, errmsg);
631 HALLOG(
"OpenReadHandles error %d of %s:%d (%s)\n", res, iface->
serial, iface->
ifaceno, errmsg);
642 if (iface->rdpending && iface->rdHDL != INVALID_HANDLE_VALUE) {
643 if (CancelIo(iface->rdHDL) == 0) {
644 HALLOG(
"CancelIo failed with %d\n", GetLastError());
646 if (GetOverlappedResult(iface->rdHDL, &iface->rdOL, &readed, TRUE)) {
649 HALLOG(
"invalid packet size read %d %d\n", iface->
ifaceno, readed);
655 u32 error = GetLastError();
656 if (error != ERROR_OPERATION_ABORTED) {
666 if (iface->rdHDL != INVALID_HANDLE_VALUE) {
667 CloseHandle(iface->rdHDL);
668 iface->rdHDL = INVALID_HANDLE_VALUE;
670 iface->rdpending = 0;
674 static int StartReadIO(
yInterfaceSt *iface,
char *errmsg)
679 YASSERT(iface->rdpending == 0);
680 memset(&iface->rdOL, 0,
sizeof(iface->rdOL));
683 if (!ReadFile(iface->rdHDL, &iface->tmpd2hpkt,
sizeof(
OS_USB_Packet), &readed, &iface->rdOL)) {
684 u32 error = GetLastError();
685 if (error != ERROR_IO_PENDING) {
686 return yWinSetErrEx(__LINE__, iface, error,
"", errmsg);
688 iface->rdpending = 1;
711 if (iface->rdpending == 0) {
713 res = StartReadIO(iface, errmsg);
716 CloseReadHandles(iface);
717 if (
YISERR(OpenReadHandles(iface))) {
725 HALLOG(
"Read IO error %s:%d (%s/%s)\n", iface->
serial, iface->
ifaceno, errmsg, DP(iface->devicePath));
729 if (GetOverlappedResult(iface->rdHDL, &iface->rdOL, &readed, 0)) {
730 iface->rdpending = 0;
732 HALLOG(
"drop invalid packet on %s:%d (invalid size %d)\n", iface->
serial, iface->
ifaceno, readed);
737 res = StartReadIO(iface, errmsg);
740 CloseReadHandles(iface);
741 if (
YISERR(OpenReadHandles(iface))) {
749 HALLOG(
"Read IO error %s:%d (%s/%s)\n", iface->
serial, iface->
ifaceno, errmsg, DP(iface->devicePath));
753 u32 error = GetLastError();
754 if (error != ERROR_IO_INCOMPLETE) {
755 iface->rdpending = 0;
756 res = yWinSetErrEx(__LINE__, iface, error,
"", errmsg);
758 CloseReadHandles(iface);
759 if (
YISERR(OpenReadHandles(iface))) {
767 HALLOG(
"Read IO error %s:%d (%s/%s)\n", iface->
serial, iface->
ifaceno, errmsg, DP(iface->devicePath));
771 if (retrycount == 0) {
772 HALLOG(
"Read IO needed 1 retry %s:%d (%s/%s)\n", iface->
serial, iface->
ifaceno, errmsg, DP(iface->devicePath));
788 if (!WriteFile(iface->wrHDL, &winpkt,
sizeof(
OS_USB_Packet), &written, NULL)) {
789 YRETCODE code = yWinSetErr(iface, errmsg);
792 CloseWriteHandles(iface);
793 if (
YISERR(OpenWriteHandles(iface))) {
801 HALLOG(
"Write IO error %s:%d (%s/%s)\n", iface->
serial, iface->
ifaceno, errmsg, DP(iface->devicePath));
804 if (retrycount == 0) {
805 HALLOG(
"Write IO needed 1 retry %s:%d (%s/%s)\n", iface->
serial, iface->
ifaceno, errmsg, DP(iface->devicePath));
812 static void* yyyUsbIoThread(
void* thread_void)
821 iface->wrHDL = INVALID_HANDLE_VALUE;
822 iface->rdHDL = INVALID_HANDLE_VALUE;
823 for (i = 0; i < 2; i++) {
828 if (
YISERR(OpenWriteHandles(iface))) {
833 if (
YISERR(OpenReadHandles(iface))) {
840 yWinSetErr(iface, errmsg);
847 HALLOG(
"yyyReady I%x wr=%x rd=%x se=%s\n", iface->
ifaceno, iface->wrHDL, iface->rdHDL, iface->
serial);
858 HALLOG(
"----IoThread start of %s:%d (%s) ---\n", iface->
serial, iface->
ifaceno, DP(iface->devicePath));
865 #ifdef DEBUG_PKT_TIMING 866 u64 timeBeforeWrite, timeAfterWrite, stop;
869 YASSERT(timeBeforeWrite >= 0 && timeBeforeWrite < 50);
871 if (
YISERR(yyyyWrite(iface, pktItem))) {
875 #ifdef DEBUG_PKT_TIMING 877 timeAfterWrite = stop - pktItem->time;
880 printf(
"outpkt no %llu %llu -> %llu (%llu=>%llu) (next=no %llu %llu)\n", pktItem->ospktno, timeBeforeWrite, timeAfterWrite, pktItem->time, stop, pktItem->
next->ospktno, tmp);
882 printf(
"outpkt no %llu %llu -> %llu (%llu=>%llu) (no next)\n",
883 pktItem->ospktno, timeBeforeWrite, timeAfterWrite, pktItem->time, stop);
885 YASSERT(timeAfterWrite >= 0 && timeAfterWrite < 50);
892 dwEvent = WaitForMultipleObjects(
897 if (dwEvent == WAIT_FAILED) {
898 YRETCODE code = yWinSetErr(iface, errmsg);
905 if (dwEvent != WAIT_TIMEOUT) {
915 HALLOG(
"----IoThread end of %s:%d (%s) ---\n", iface->
serial, iface->
ifaceno, DP(iface->devicePath));
920 CloseWriteHandles(iface);
921 CloseReadHandles(iface);
929 HALLOG(
"yyySetup %p\n", iface);
932 memset(&iface->io_thread, 0,
sizeof(
yThread));
933 if (
yThreadCreate(&iface->io_thread, yyyUsbIoThread, (
void*)iface) < 0) {
947 HALLOG(
"yyyPacketShutdown %p\n", iface);
981 int yUSBGetInterfaces(
yInterfaceSt **ifaces,
int *nbifaceDetect,
char *errmsg)
void yThreadKill(yThread *yth)
#define YERRMSG(code, message)
void yInitializeCriticalSection(yCRITICAL_SECTION *cs)
#define YOCTO_DEVID_BOOTLOADER
#define YWIN_EVENT_INTERRUPT
int yThreadCreate(yThread *yth, void *(*fun)(void *), void *arg)
int yyySetup(yInterfaceSt *iface, char *errmsg)
int yyyUSBGetInterfaces(yInterfaceSt **ifaces, int *nbifaceDetect, char *errmsg)
void yLeaveCriticalSection(yCRITICAL_SECTION *cs)
#define WIN_DEVICE_PATH_LEN
#define YSTRNICMP(A, B, len)
YRETCODE yPktQueuePopH2D(yInterfaceSt *iface, pktItem **pkt)
int yyyUSB_init(yContextSt *ctx, char *errmsg)
#define HALENUMLOG(fmt, args...)
int yyySignalOutPkt(yInterfaceSt *iface, char *errmsg)
void yThreadRequestEnd(yThread *yth)
#define yApproximateSleep(ms)
#define YSTRCPY(dst, dstsize, src)
int yyyUSB_stop(yContextSt *ctx, char *errmsg)
void yPktQueueSetError(pktQueue *q, YRETCODE code, const char *msg)
struct _yInterfaceSt yInterfaceSt
YRETCODE yPktQueuePeekH2D(yInterfaceSt *iface, pktItem **pkt)
#define HALLOG(fmt, args...)
void yEnterCriticalSection(yCRITICAL_SECTION *cs)
char serial[YOCTO_SERIAL_LEN *2]
YRETCODE yPktQueuePushD2H(yInterfaceSt *iface, const USB_Packet *pkt, char *errmsg)
void yDeleteCriticalSection(yCRITICAL_SECTION *cs)
void ySetEvent(yEvent *ev)
void yPktQueueFree(pktQueue *q)
u64 YAPI_FUNCTION_EXPORT yapiGetTickCount(void)
void yyyPacketShutdown(yInterfaceSt *iface)
void yThreadSignalEnd(yThread *yth)
char serial[YOCTO_SERIAL_LEN]
#define yMemcpy(dst, src, size)
int yThreadMustEnd(yThread *yth)
int yyyOShdlCompare(yPrivDeviceSt *dev, yInterfaceSt *newiface)
#define YIO_DEFAULT_USB_TIMEOUT
int yThreadIsRunning(yThread *yth)
void yThreadSignalStart(yThread *yth)
void yPktQueueInit(pktQueue *q)
#define YSTRNCPY(dst, dstsize, src, len)