Skip to content

Commit

Permalink
feat:添加初始化
Browse files Browse the repository at this point in the history
  • Loading branch information
yhf98 committed Mar 10, 2023
1 parent 4d81004 commit df73b44
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 2 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "hid-handle",
"main": "./hidhandle.js",
"version": "1.3.0",
"version": "1.4.0",
"description": "hid-handle - Write data to USB HID devices from Node.js",
"scripts": {
"build": "node-gyp build",
Expand Down
35 changes: 34 additions & 1 deletion src/hidhandle.cc
Original file line number Diff line number Diff line change
Expand Up @@ -659,7 +659,40 @@ int hmi_delete_obj(unsigned int id);
* @return int
*/
int hmi_create_label_handle(){
int ret = hmi_create_label();
int ret = -1;
int string_index = 1;

printf(" ... hid init ...\n");

hid_init();

hid_handle = hid_open(0x264a, 0x232a, NULL);
if (hid_handle == NULL)
{
printf(" open hid error!\n");
return 0;
}
else
{
printf(" open hid succeed!\n");
}

hid_set_nonblocking(hid_handle, 0);

hid_get_manufacturer_string(hid_handle, manufact, sizeof(manufact));
printf("manufact = %ls\n", manufact);
hid_get_product_string(hid_handle, product, sizeof(product));
printf("product = %ls\n", product);
hid_get_serial_number_string(hid_handle, serial_num, sizeof(serial_num));
printf("serial_num = %ls\n", serial_num);
hid_get_indexed_string(hid_handle, string_index, indexed, sizeof(indexed));
printf("indexed = %ls\n", indexed);

ret = hmi_create_label();

hid_close(hid_handle);
hid_handle = NULL;

return ret;
}

Expand Down

0 comments on commit df73b44

Please sign in to comment.