Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Write to HID device of type (/dev/hidrawX) on Linux
Forum Updated to NodeBB v4.3 + New Features

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

Scheduled Pinned Locked Moved General and Desktop
1 Posts 1 Posters 686 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    Antweb
    wrote on last edited by
    #1

    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?

    1 Reply Last reply
    0

    • Login

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Get Qt Extensions
    • Unsolved