def read(self, size=64, timeout=None):
        """
        Read from the hid device on its endpoint.


        Parameters:
            size: number of bytes to read
            timeout: length to wait in milliseconds

        Returns:
            The HID report read from the device. The first byte in the result
            will be the report ID if used.
        """

        if not self._is_open:
            raise HIDException("HIDDevice not open")

        data = [0] * size
        cdata = ffi.new("unsigned char[]", data)
        bytes_read = 0

        if timeout == None:
            bytes_read = hidapi.hid_read(self._device, cdata, len(cdata))
        else:
            bytes_read = hidapi.hid_read_timeout(self._device, cdata, len(cdata), timeout)


        if bytes_read < 0:
            raise HIDException("Failed to read from HID device: " + str(bytes_read))
        elif bytes_read == 0:
            return []
        else:
            return bytearray(cdata)
Read from the hid device on its endpoint.


        Parameters:
            size: number of bytes to read
            timeout: length to wait in milliseconds

        Returns:
            The HID report read from the device. The first byte in the result
            will be the report ID if used.