コード例 #1
1
irecv_error_t irecv_receive(irecv_client_t client) {
	unsigned char buffer[BUFFER_SIZE];
	memset(buffer, '\0', BUFFER_SIZE);
	if (client == NULL || client->handle == NULL) {
		return IRECV_E_NO_DEVICE;
	}

	int bytes = 0;
	while (libusb_bulk_transfer(client->handle, 0x81, buffer, BUFFER_SIZE, &bytes, 100) == 0) {
		if (bytes > 0) {
			if (client->received_callback != NULL) {
				irecv_event_t event;
				event.size = bytes;
				event.data = buffer;
				event.type = IRECV_RECEIVED;
				if (client->received_callback(client, &event) != 0) {
					return IRECV_E_SUCCESS;
				}
			}
		} else break;
	}

	return IRECV_E_SUCCESS;
}
コード例 #2
0
ファイル: libirecovery.c プロジェクト: mucit/opensn0w
irecv_error_t irecv_receive(irecv_client_t client)
{
	char buffer[BUFFER_SIZE];
	int bytes = 0;

	memset(buffer, '\0', BUFFER_SIZE);
	if (check_context(client) != IRECV_E_SUCCESS)
		return IRECV_E_NO_DEVICE;

	while (irecv_bulk_transfer
	       (client, 0x81, (unsigned char *)buffer, BUFFER_SIZE, &bytes,
		500) == 0) {
		if (bytes > 0) {
			if (client->received_callback != NULL) {
				irecv_event_t event;
				event.size = bytes;
				event.data = buffer;
				event.type = IRECV_RECEIVED;
				if (client->received_callback(client, &event) !=
				    0) {
					return IRECV_E_SUCCESS;
				}
			}
			if (bytes < BUFFER_SIZE)
				break;
		} else
			break;
	}

	return IRECV_E_SUCCESS;
}