ERROR _NOT_SUPPORTED while ReadFile form USB

I’m beginner in programming and I’m trying to communicate with oscilloscope via USB port. I’ve found the device and recognised it by it’s vid and pid. I created file (CreateFile()) without an error. Then, while trying to Read or Write file the error occured (error 50 (0x32). The request is not supported).
Any possibly reason of it?

    void oscilloscopesFrame::OnButton2Click1(wxCommandEvent& event)
    int nr=0;
    DeviceObject = CreateFile(oscilloscopes[nr].c_str(),/* nazwa obiektu w systemie czyli adres*/
                              GENERIC_READ | GENERIC_WRITE, FILE_SHARE_READ, /* odczyt/zapis jest mozliwy, */
                              NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL,NULL ); /*w tym samym czasie inne urzadzeia moga odczytywac*/
    // brak zabeczpieczen, otworz tylko jak istnieje,

    if(DeviceObject == INVALID_HANDLE_VALUE)(*TextCtrl1) << "BLAD nr " << (int)GetLastError() << "!n";

        (*TextCtrl2) << "nCreateFile zakonczone pomyslnie.n Adres: n" << oscilloscopes[nr].c_str() << "n";
        /*BOOL WINAPI ReadFile(
          _In_        HANDLE       hFile,
          _Out_       LPVOID       lpBuffer,
          _In_        DWORD        nNumberOfBytesToRead,
          _Out_opt_   LPDWORD      lpNumberOfBytesRead,
          _Inout_opt_ LPOVERLAPPED lpOverlapped
        hHidLib = LoadLibrary(L"hid.dll");
            bool (__stdcall*HidD_GetNumInputBuffers)(IN HANDLE  HidDeviceObject,
                    OUT PULONG  NumberBuffers);
            ULONG numberBuffers; //pobranie max. długości raportu wejściowego
            numberBuffers = 64;
            //HidD_GetNumInputBuffers(DeviceObject, &numberBuffers);
            int i =0;

            memset(&inputReportBuffer, 0x00, sizeof(inputReportBuffer));
            if(ReadFile(DeviceObject, inputReportBuffer, sizeof(inputReportBuffer),
                        &numberOfBytesRead, NULL))
                for(int j=0; j<30; j++)
                    (*TextCtrl2) << " " << inputReportBuffer[j] ;
                (*TextCtrl2) << "n";

                    (*TextCtrl2) << "BLAD nr. " << (int)GetLastError() <<"!n";



Thank you for your answer!

Source: windows

Leave a Reply