Не удалось получить OnBarCodeEvent для сканера Zebra в linux C ++ - PullRequest
1 голос
/ 14 марта 2020

Я использую Zebra linux SDK для сканера, чтобы захватить сканируемый штрих-код. Я хочу прослушать OnBarcodeEvent и записать код.

Я попробовал пример кода консольного приложения и gui код приложения

Я назвал

::ExecCommand( CMD_REGISTER_FOR_EVENTS , inXml, outXml, &eStatus);

OnBarcodeEvent не вызывается при сканировании штрих-кода.

Код, представленный ниже.

void SampleEventListener::connect_corescanner()
{

    cout <<"connect_corescanner startp"<< endl;

    int iScannerType = SCANNER_TYPE_ALL;
    StatusID eStatus ;

    ::Open(this, SCANNER_TYPE_ALL , &eStatus );
    std::cout << "Open eStatus line 634 ConsoleSampleEventListener.cpp" << ": " << eStatus << std::endl;

    if ( eStatus != STATUS_OK )
    {
        cout <<eStatus<< endl;
        cout <<"can't connect to the corescanner. "<< endl;
        exit(0);
    }

    // register for all events //
    std::string inXml;
    std::ostringstream oss;
    oss << "<inArgs>" << std::endl;
    oss << "    <cmdArgs>" << std::endl;
    oss << "        <arg-int>6</arg-int>" << std::endl;
    oss << "        <arg-int>1,2,4,8,16,32</arg-int>" << std::endl;
    oss << "    </cmdArgs>" << std::endl;
    oss << "</inArgs>" ;
    inXml = oss.str();

    std::string outXml;
    ::ExecCommand( CMD_REGISTER_FOR_EVENTS , inXml, outXml, &eStatus);
    std::cout << "ExecCommand eStatus line 658 ConsoleSampleEventListener.cpp" << ": " << eStatus << std::endl;
    if( eStatus != STATUS_OK ){
        cout <<"unable to register for events"<< endl;

        exit(-1);
    }

    cout <<"subscribe to events successful."<< outXml;
    cout <<"\nsubscribe to events successful."<< endl;

    cout <<"connect_corescanner endp\n"<< endl;

}


void SampleEventListener::OnBarcodeEvent(short int eventType, std::string & pscanData)
{
    cout << "Barcode Detected" << endl;
    cout << "Out XML" << endl;
    cout << pscanData << endl;
}
...