def read(self, length, timeout_ms=<NUM_LIT:0>, blocking=False):
self._check_device_status()<EOL>bufp = ffi.new("<STR_LIT>", length)<EOL>if not timeout_ms and blocking:<EOL><INDENT>timeout_ms = -<NUM_LIT:1><EOL><DEDENT>if timeout_ms:<EOL><INDENT>rv = hidapi.hid_read_timeout(self._device, bufp, length,<EOL>timeout_ms)<EOL><DEDENT>else:<EOL><INDENT>rv = hidapi.hid_read(self._device, bufp, length)<EOL><DEDENT>if rv == -<NUM_LIT:1>:<EOL><INDENT>raise IOError("<STR_LIT>"<EOL>.format(self._get_last_error_string()))<EOL><DEDENT>elif rv == <NUM_LIT:0>:<EOL><INDENT>return None<EOL><DEDENT>else:<EOL><INDENT>return ffi.buffer(bufp, rv)[:]<EOL><DEDENT>
Read an Input report from a HID device with timeout.

        Input reports are returned to the host through the `INTERRUPT IN`
        endpoint. The first byte will contain the Report number if the device
        uses numbered reports.
        By default reads are non-blocking, i.e. the method will return
        `None` if no data was available. Blocking reads can be enabled with
        :param blocking:. Additionally, a timeout for the read can be
        specified.

        :param length:      The number of bytes to read. For devices with
                            multiple reports, make sure to read an extra byte
                            for the report number.
        :param timeout_ms:  Timeout in miliseconds
        :type timeout_ms:   int
        :param blocking:    Block until data is available