Hello. Gradually I reprint the sample program on a PC from http://we.easyelectronics.ru/electro-and-pc/usb-dlya-avr-chast-2-hid-class-na-v-usb.html
Using the hidlibrary.h library https://cloud.mail.ru/public/4Hgd/mWysiTyRH
The program is written in Borland C ++ Builder 6, I am writing in the console application MVS2012, omitting the visual part.
#include <Windows.h> #include "hidlibrary.h" #include <stdio.h> using namespace std; // Вытягиваем имена устройства из проекта контроллера. #include "usbconfig.h" char vendorName[] = {USB_CFG_VENDOR_NAME, 0}; // для того что бы знать как char productName[] = {USB_CFG_DEVICE_NAME, 0}; // называется наше устройство struct dataexchange_t { unsigned char b1; unsigned char b2; unsigned char b3; }; struct dataexchange_t pdata = {0, 0, 0}; HIDLibrary <dataexchange_t> hid; int connect() // этой функцией будем подключаться к устройству { volatile int n, res=0; string exampleDeviceName = ""; exampleDeviceName += vendorName; exampleDeviceName += " "; exampleDeviceName += productName; n = hid.EnumerateHIDDevices(); return res; } int main (int) { system("pause"); } Reached the line
n = hid.EnumerateHIDDevices() When adding it, I encountered errors below. For reasons of lack of education I can’t give you comprehensive information, I don’t know what is trivial, but I’ll add it on request.
1>Source.obj : error LNK2019: unresolved external symbol __imp__SetupDiDestroyDeviceInfoList@4 referenced in function "public: int __thiscall HIDLibrary<struct dataexchange_t>::EnumerateHIDDevices(void)" (?EnumerateHIDDevices@?$HIDLibrary@Udataexchange_t@@@@QAEHXZ) 1>Source.obj : error LNK2019: unresolved external symbol __imp__SetupDiEnumDeviceInterfaces@20 referenced in function "public: int __thiscall HIDLibrary<struct dataexchange_t>::EnumerateHIDDevices(void)" (?EnumerateHIDDevices@?$HIDLibrary@Udataexchange_t@@@@QAEHXZ) 1>Source.obj : error LNK2019: unresolved external symbol __imp__SetupDiGetDeviceInterfaceDetailA@24 referenced in function "protected: class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > __thiscall HIDLibrary<struct dataexchange_t>::GetDevicePath(void *,struct _SP_DEVICE_INTERFACE_DATA *)" (?GetDevicePath@?$HIDLibrary@Udataexchange_t@@@@IAE?AV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@PAXPAU_SP_DEVICE_INTERFACE_DATA@@@Z) 1>Source.obj : error LNK2019: unresolved external symbol __imp__SetupDiGetClassDevsA@16 referenced in function "public: int __thiscall HIDLibrary<struct dataexchange_t>::EnumerateHIDDevices(void)" (?EnumerateHIDDevices@?$HIDLibrary@Udataexchange_t@@@@QAEHXZ)