Exemple #1
0
uint8_t HIDUniversal::Poll()
{
	uint8_t rcode = 0;

	if (!bPollEnable)
		return 0;

	if (qNextPollTime <= millis())
	{
		qNextPollTime = millis() + 50;

		uint8_t buf[constBuffLen];

		for (uint8_t i=0; i<bNumIface; i++)
		{
			uint8_t		index	= hidInterfaces[i].epIndex[epInterruptInIndex];
			uint16_t	read	= (uint16_t)epInfo[index].maxPktSize;

			ZeroMemory(constBuffLen, buf);

			uint8_t rcode = pUsb->inTransfer(bAddress, epInfo[index].epAddr, &read, buf);

			if (rcode)
			{
				if (rcode != hrNAK)
					USBTRACE2("Poll:", rcode);
				return rcode;
			}

			if (read > constBuffLen)
				read = constBuffLen;

			bool identical = BuffersIdentical(read, buf, prevBuf);

			SaveBuffer(read, buf, prevBuf);

			if (identical)
				return 0;

			Serial.print("\r\nBuf: ");

			for (uint8_t i=0; i<read; i++)
				PrintHex<uint8_t>(buf[i]);

			Serial.println("");

			HIDReportParser		*prs = GetReportParser( ((bHasReportId) ? *buf : 0) );

			if (prs)
				prs->Parse(this, bHasReportId, (uint8_t)read, buf);
		}
	}
	return rcode;
}
Exemple #2
0
uint8_t HIDUniversal::Poll() {
        uint8_t rcode = 0;

        if(!bPollEnable)
                return 0;

        if((long)(millis() - qNextPollTime) >= 0L) {
                qNextPollTime = millis() + pollInterval;

                uint8_t buf[constBuffLen];

                for(uint8_t i = 0; i < bNumIface; i++) {
                        uint8_t index = hidInterfaces[i].epIndex[epInterruptInIndex];
                        uint16_t read = (uint16_t)epInfo[index].maxPktSize;

                        ZeroMemory(constBuffLen, buf);

                        uint8_t rcode = pUsb->inTransfer(bAddress, epInfo[index].epAddr, &read, buf);

                        if(rcode) {
                                if(rcode != hrNAK)
                                        USBTRACE3("(hiduniversal.h) Poll:", rcode, 0x81);
                                return rcode;
                        }

                        if(read > constBuffLen)
                                read = constBuffLen;

                        bool identical = BuffersIdentical(read, buf, prevBuf);

                        SaveBuffer(read, buf, prevBuf);

                        if(identical)
                                return 0;
#if 0
                        Notify(PSTR("\r\nBuf: "), 0x80);

                        for(uint8_t i = 0; i < read; i++) {
                                D_PrintHex<uint8_t > (buf[i], 0x80);
                                Notify(PSTR(" "), 0x80);
                        }

                        Notify(PSTR("\r\n"), 0x80);
#endif
                        ParseHIDData(this, bHasReportId, (uint8_t)read, buf);

                        HIDReportParser *prs = GetReportParser(((bHasReportId) ? *buf : 0));

                        if(prs)
                                prs->Parse(this, bHasReportId, (uint8_t)read, buf);
                }
        }
        return rcode;
}
uint8_t HIDUniversal::Poll()
{
	uint8_t rcode = 0;

	if (!bPollEnable)
		return 0;

	if (qNextPollTime <= millis())
	{
		qNextPollTime = millis() + 50;

		const uint8_t const_buff_len = 16;
		uint8_t buf[const_buff_len];

		for (uint8_t i=0; i<bNumIface; i++)
		{
			uint8_t		index	= hidInterfaces[i].epIndex[epInterruptInIndex];
			uint16_t	read	= (uint16_t)epInfo[index].maxPktSize;

			USBTRACE2("i:",	i);
			USBTRACE2("Ind:", index);
			USBTRACE2("EP:",  epInfo[index].epAddr);
			USBTRACE2("Rd:",  read);

			uint8_t rcode = pUsb->inTransfer(bAddress, epInfo[index].epAddr, &read, buf);

			if (rcode)
			{
				if (rcode != hrNAK)
					USBTRACE2("Poll:", rcode);
				else
					USBTRACE2("poll:", rcode);
				return rcode;
			}
			Serial.print("Read:");
			PrintHex<uint8_t>(read);
			Serial.println("");

			for (uint8_t i=0; i<read; i++)
				PrintHex<uint8_t>(buf[i]);
			if (read)
				Serial.println("");

			HIDReportParser		*prs = GetReportParser( ((bHasReportId) ? *buf : 0) );

			if (prs)
				prs->Parse(this, bHasReportId, (uint8_t)read, buf);
		}

	}
	return rcode;
}