C++ hid_read_timeout函数代码示例

本文整理汇总了C++中hid_read_timeout函数的典型用法代码示例。如果您正苦于以下问题:C++ hid_read_timeout函数的具体用法?C++ hid_read_timeout怎么用?C++ hid_read_timeout使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


C++ hid_read_timeout函数代码示例

在下文中一共展示了hid_read_timeout函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: hid_read_timeout

char* minicut::read1s()
{
    this->buffer=(unsigned char*)malloc(36*sizeof(unsigned char));

    hid_read_timeout(minicut_device,this->buffer,sizeof(buffer),1000);
    return  (char*)buffer;
}
开发者ID:tuxun,项目名称:dollyCNC,代码行数:7,代码来源:Minicut.cpp

示例2: getPeer

JNIEXPORT jint JNICALL Java_com_codeminders_hidapi_HIDDevice_readTimeout
(JNIEnv *env, jobject self, jbyteArray data, jint milliseconds )
{
    hid_device *peer = getPeer(env, self);
    if(!peer) 
    {
        throwIOException(env, peer);
        return 0; /* not an error, freed previously */ 
    }
    
    jsize bufsize = env->GetArrayLength(data);
    jbyte *buf = env->GetByteArrayElements(data, NULL);
    int read = hid_read_timeout(peer, (unsigned char*) buf, bufsize, milliseconds);
    env->ReleaseByteArrayElements(data, buf, read==-1?JNI_ABORT:0);
    if(read == 0) /* time out */
    {
        return 0;
    }
    else if(read == -1)
    {
        throwIOException(env, peer);
        return 0; /* not an error, freed previously */ 
    }
    return read;
}
开发者ID:DeqingSun,项目名称:javahidapi,代码行数:25,代码来源:HIDDevice.cpp

示例3: read_timeout

int
read_timeout(hid_device *device, unsigned char *data, size_t length, int milliseconds)
{
    return hid_executor->await([=] {
            return hid_read_timeout(device, data, length, milliseconds);
        });
}
开发者ID:easeip,项目名称:trezord,代码行数:7,代码来源:hid.hpp

示例4: while

void RawHIDReadThread::run()
{
    while(m_running)
    {
        //here we use a temporary buffer so we don't need to lock
        //the mutex while we are reading from the device

        // Want to read in regular chunks that match the packet size the device
        // is using.  In this case it is 64 bytes (the interrupt packet limit)
        // although it would be nice if the device had a different report to
        // configure this
        unsigned char buffer[READ_SIZE] = {0};

        int ret = hid_read_timeout(m_hid->m_handle, buffer, READ_SIZE, READ_TIMEOUT);

        if(ret > 0) //read some data
        {
            QMutexLocker lock(&m_readBufMtx);
            // Note: Preprocess the USB packets in this OS independent code
            // First byte is report ID, second byte is the number of valid bytes
            m_readBuffer.append((char *) &buffer[2], buffer[1]);

            emit m_hid->readyRead();
        }
        else if(ret == 0) //nothing read
        {
        }
        else // < 0 => error
        {
            //TODO! make proper error handling, this only quick hack for unplug freeze
            m_running=false;
        }
    }
}
开发者ID:Liambeguin,项目名称:TauLabs,代码行数:34,代码来源:rawhid.cpp

示例5: openDevice

void openDevice(hid_dev_desc * desc, std::atomic<bool> &shouldBeRunning)
	{
		trace("open device %p\n");
		std::lock_guard<std::mutex> lock(guard);
		if (map.find(desc) != map.end())
			// thread already polling device
			return;

		boost::thread * deviceThread = threads.create_thread( [=, &shouldBeRunning] {
			trace("start polling thread for %d\n", desc);

			while( true ) {
				unsigned char buf[256];

				int res = hid_read_timeout( desc->device, buf, sizeof(buf), 250);
				if ( res > 0 ) {
					hid_parse_input_report( buf, res, desc );
				} else if (res == -1) {
					trace("device thread interrupted \n");
					hid_throw_readerror( desc );
					trace("device thread closed device \n");
					return;
				}
			}
			std::lock_guard<std::mutex> lock_(guard);
                        auto it = map.find(desc);
                        threads.remove_thread(it->second);
                        map.erase(it);
		});

		map.insert( std::make_pair(desc, deviceThread) );
	}
开发者ID:ASauer,项目名称:supercollider,代码行数:32,代码来源:SC_HID_api.cpp

示例6: USB_Read

int USB_Read()
{
    if(DeviceHandle == NULL)
        return -1;

    return hid_read_timeout(DeviceHandle, InputBuffer, USB_MIN_PACKET_SIZE+1, 2000);
}
开发者ID:SchwartzNU,项目名称:DataAcquisition,代码行数:7,代码来源:usb.cpp

示例7: throw

bool PortalIO::CheckResponse (RWBlock *res, char expect) throw (int)
{
    
    int b = hid_read_timeout(hPortalHandle, res->buf, rw_buf_size, TIMEOUT);
    
    if(b<0)
        throw 8;
    
    res->dwBytesTransferred = b;
    
    // this is here to debug the different responses from the portal.
    
    /*
     SkylanderIO *skio;
     skio = new SkylanderIO();
     printf("<<<\n");
     skio->fprinthex(stdout,res->buf, 0x21);
     delete skio;
     */
    
    // found wireless USB but portal is not connected
    if (res->buf[0] == 'Z')
        throw 9;
    
    // Status says no skylander on portal
    if (res->buf[0] == 'Q' && res->buf[1] == 0)
        throw 11;
    
    
    return   (res->buf[0] != expect);
    
}
开发者ID:bobox59,项目名称:SkyReader,代码行数:32,代码来源:portalio_hidapi.cpp

示例8: condisHandler

void vmarker::condisHandler(){
    if(this->connected){
        //CHECK IF DISCONNECTED
        unsigned char *data;
        if(hid_read_timeout(this->vmarkerdev,data,0,200)<0){
            this->connected = false;
            qDebug("Vmarker Disconnected");
            emit(Disconnect());
            hid_close(this->vmarkerdev);
        }
    }else{
        //SEARCH FOR VMARKER
        struct hid_device_info *devs,*cur_dev;
        int i = 0;
        for(i = 0; i<numPIDlist;i++){
            devs = hid_enumerate(VID,PIDlist[i]);
            cur_dev = devs;
            while(cur_dev){
                qDebug(cur_dev->path);
                if(cur_dev->interface_number == MIlist[i]){
                    this->vmarkerdev = hid_open_path(cur_dev->path);
                    if(this->vmarkerdev){
                        this->productID = PIDlist[i];
                        this->connected = true;
                        qDebug("Vmarker Connected");
                        emit (Connected());
                    }
                }
                cur_dev = cur_dev->next;
            }
            hid_free_enumeration(devs);
        }
    }
}
开发者ID:vmarker,项目名称:VmarkerGUI,代码行数:34,代码来源:vmarker.cpp

示例9: writereg

bool vmarker::writereg(uint8_t reg, uint16_t *data){
    if(this->connected){
        unsigned char buf[] = {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00};
        buf[1] = 0x05;
        buf[2] = reg;
        buf[3] = *data >> 8;
        buf[4] = *data;
        if(hid_write(this->vmarkerdev,buf,9)<0) return false;
        if(hid_read_timeout(this->vmarkerdev,buf,9,200)<0) return false;
        return true;
    }else{
开发者ID:vmarker,项目名称:VmarkerGUI,代码行数:11,代码来源:vmarker.cpp

示例10: cb_panel_read_blocking

int cb_panel_read_blocking(unsigned char *buf) {
	int res = 0;
	if (cbHandle) {
		hid_set_nonblocking(cbHandle, 0);
		res = hid_read_timeout(cbHandle, buf, CB_IN_BUF_SIZE, 100);
		if (res < 0) {
			sprintf(tmp, "-> CP: cb_driver.panel_read_blocking: Error: %ls\n",
					hid_error(cbHandle));
			printf(tmp);
		}
	}
	return res;
}
开发者ID:taco24,项目名称:hwpanels-xplane,代码行数:13,代码来源:cb_driver.c

示例11: while

void HIDDMXDevice::run()
{
    while(m_running == true)
    {
        unsigned char buffer[35];
        int size;

        size = hid_read_timeout(m_handle, buffer, 33, HID_DMX_READ_TIMEOUT);

        /**
        * Protocol: 33 bytes in buffer[33]
        * [0]      = chunk, which is the offset by which the channel is calculated
        *            from, the nth chunk starts at address n * 32
        * [1]-[32] = channel values, where the nth value is the offset + n
        */
        while(size > 0)
        {
            if(size == 33)
            {
                unsigned short startOff = buffer[0] * 32;
                if (buffer[0] < 16)
                {
                    for (int i = 0; i < 32; i++)
                    {
                        unsigned short channel = startOff + i;
                        unsigned char value = buffer[i + 1];
                        if ((unsigned char)m_dmx_in_cmp.at(channel) != value)
                        {
                            emit valueChanged(UINT_MAX, m_line, channel, value);
                            m_dmx_in_cmp[channel] = value;
                        }
                    }
                }
            }

            size = hid_read_timeout(m_handle, buffer, 33, HID_DMX_READ_TIMEOUT);
        }
    }
}
开发者ID:PML369,项目名称:qlcplus,代码行数:39,代码来源:hiddmxdevice.cpp

示例12: readreg

bool vmarker::readreg(uint8_t reg, uint16_t *data){
    if(this->connected){
        unsigned char buf[] = {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00};
        buf[1] = 0x04;
        buf[2] = reg;
        if(hid_write(this->vmarkerdev,buf,9)<0) return false;
        if(hid_read_timeout(this->vmarkerdev,buf,9,200)<0) return false;
        *data = (buf[1]<<8)+buf[2];
        qDebug() << (uint16_t)buf[0] << " " << (uint16_t)buf[1] << " " << (uint16_t)buf[2] << " " << (uint16_t)buf[3] << " " << (uint16_t)buf[4] << " ";
        return true;
    }else{
        return false;
    }
}
开发者ID:vmarker,项目名称:VmarkerGUI,代码行数:14,代码来源:vmarker.cpp

示例13: hid_write

int usbDialog::sendCMD(unsigned char *cmd)
{
	int rc;

	rc = hid_write(dev, cmd, 1 + cmd[1]);

	dumpRawData(true, rc, cmd);

	rc = hid_read_timeout(dev, rawdata, sizeof(rawdata), 1000);

	dumpRawData(false, rc, rawdata);

	return rc;
}
开发者ID:LazyT,项目名称:obpm,代码行数:14,代码来源:usb.cpp

示例14: ReadInput

int ReadInput(glowproxy_device* handle, InputReport* reportBuffer)
{
    //TODO: add last-report filtering
    if (handle == NULL) return -1;
    int result;
    unsigned char buffer[25];
    memset(buffer, 0, sizeof(buffer));

    buffer[0] = 0x00;
    result = hid_read_timeout(handle, buffer, 25, READWAIT_MS);
    if (result > 0)
    {
        memcpy(reportBuffer, &buffer, 25);
    }
    return result;
}
开发者ID:TransistorLabs,项目名称:glowproxy,代码行数:16,代码来源:GlowProxyAPI.cpp

示例15: receive

std::size_t receive(unsigned char* buffer, std::size_t bufferSize)
	{
		const int size = hid_read_timeout(handle_, buffer, bufferSize, rxTimeout_);
		if (size < 0)
		{
			const int errorCode = hid_last_error_code(handle_);
			if (errorCode == ERROR_DEVICE_NOT_CONNECTED)
			{
				throw IOException("Interface not connected");
			}
			else
			{
				throw IOException(("USB driver: Receive Error (error %d)", errorCode));
			}
		}
		return size;
	}
开发者ID:weinzierl-engineering,项目名称:baos,代码行数:17,代码来源:UsbDriver_WIN32.cpp

本文标签属性:

示例:示例是什么意思

代码:代码编程

hid_read_timeout:hid_read_timeout

上一篇:种群的解释种群的解释是什么(种群是什么意思)
下一篇:山丹县属于哪个省哪个市(山丹县有多少人口)(甘肃省张掖市山丹县)

为您推荐