Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Assertion `ctx->pollfds_cnt >= internal_nfds' failed. #397

Open
FFY00 opened this issue Jun 15, 2018 · 1 comment
Open

Assertion `ctx->pollfds_cnt >= internal_nfds' failed. #397

FFY00 opened this issue Jun 15, 2018 · 1 comment

Comments

@FFY00
Copy link

FFY00 commented Jun 15, 2018

Hey, I am trying to run a really simple example but I get an error when executing hid_exit().
I am running the latest libusb (1.0.22).

Code

#include <stdio.h>
#include <stdlib.h>
#include "hidapi.h"

#define MAX_STR 255

int main(int argc, char* argv[])
{
	int res;
	unsigned char buf[65];
	wchar_t wstr[MAX_STR];
	hid_device *handle;
	int i;

	// Initialize the hidapi library
	res = hid_init();

	// Open the device using the VID, PID,
	// and optionally the Serial number.
	handle = hid_open(0x1038, 0x1720, NULL);

	// Read the Manufacturer String
	res = hid_get_manufacturer_string(handle, wstr, MAX_STR);
	wprintf(L"Manufacturer String: %s\n", wstr);

	// Read the Product String
	res = hid_get_product_string(handle, wstr, MAX_STR);
	wprintf(L"Product String: %s\n", wstr);

	// Read the Serial Number String
	res = hid_get_serial_number_string(handle, wstr, MAX_STR);
	wprintf(L"Serial Number String: (%d) %s\n", wstr[0], wstr);

	// Read Indexed String 4
	res = hid_get_indexed_string(handle, 4, wstr, MAX_STR);
	wprintf(L"Indexed String 4: %s\n", wstr);

    // Read Indexed String 5
	res = hid_get_indexed_string(handle, 5, wstr, MAX_STR);
	wprintf(L"Indexed String 5: %s\n", wstr);

	// Request state (cmd 0x81). The first byte is the report number (0x0).
	buf[0] = 0x0;
	buf[1] = 0x90;
	res = hid_write(handle, buf, 65);

	// Read requested state
	res = hid_read(handle, buf, 65);

	// Print out the returned buffer.
	for (i = 0; i < 4; i++)
		printf("buf[%d]: %d\n", i, buf[i]);

	// Finalize the hidapi library
	res = hid_exit();

	return 0;
}
I am using my Steelseries Rival 310 as an example. The output should be something like what is showed here.

Output

Manufacturer String: S
Product String: S
Serial Number String: (48) 0
Indexed String 4: S
Indexed String 5: S
test-hidapi-c-rival310: io.c:2116: handle_events: Assertion `ctx->pollfds_cnt >= internal_nfds' failed.
fish: “./test-hidapi-c-rival310” terminated by signal SIGABRT (Abort)
Fish is my shell
@hepoun
Copy link

hepoun commented Sep 30, 2018

I observed the same problem (with slightly modified example code) and I resolved the issue by adding hid_close(handle) before hid_exit().

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants