Write to HID device of type (/dev/hidrawX) on Linux



  • bool BusMain::openHidraw(QString device)
    {
    int fd = open(device.toLocal8Bit(),O_NONBLOCK);
    if(fd <= 0)
    {
    qDebug()<<"[WARN]rcMouseHandler::open-> Cant open!";
    return false;
    }
    qDebug() << fd << ": HID Connected";
    m_read = new QSocketNotifier(fd, QSocketNotifier::Read);
    m_read->setEnabled(true);
    connect(m_read, SIGNAL(activated(int)), this, SLOT(readyHIDRead()));

    m_write = new QSocketNotifier(fd, QSocketNotifier::Write);
    emit this->hid_detected();
    
    return true;
    

    }

    void BusMain::readyHIDRead()
    {
    read(m_read->socket(),&buffer,32);
    qDebug() << buffer;
    }

    void BusMain::readyHIDWrite()
    {
    int n = write(m_write->socket(),"GET",3);
    if (n < 0)
    qDebug() << "ERROR writing to socket";
    else
    qDebug() << "GET SENT";
    }

    hid_detected() is connected to a thread which executes readyHIDWrite every second.
    My program connects to HID and reads perfectly well but is not able to Write.
    AM i doing something wrong?


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.