Closed redDwarf03 closed 2 years ago
Sure, but it'll take a couple days before I have time to look into this.
Upgraded.
thank for your work
small question.
i have a pid 0411 and vid 0bda
in example, we have: int? vid = int.tryParse(parsable.removeAt(0));
so, I can't pass hex value ?
https://api.dart.dev/stable/2.15.1/dart-core/int/parse.html you can prepend 0x before the number marking it as a hex number. int.tryParse will detect this.
ok thank you.
i met another issue... sorry for that.
I'm working with macOS M1
I have install hidapi with brew install hidapi
But when I execute the example, I have this message:
ArgumentError (Invalid argument(s): Failed to load dynamic library 'libhidapi-hidraw.so': dlopen(libhidapi-hidraw.so, 0x0001):
oh, 'cause currently I only wrote lib loading for Windows/Linux, didn't handle Mac OS X. Can you paste the filename of file installed by brew here (specifically the *.dylib)
here the folder with infos
Okay, I added the lib loading in branch macosx. Can you clone the branch and try running the examples see if it reports any errors?
thx. I test but I think I have an error with path...
Invalid argument(s): Failed to load dynamic library 'libhidapi.dylib': dlopen(libhidapi.dylib, 0x0001): tried: '/Users/reddwarf/SSe/flutter/bin/cache/dart-sdk/bin/./libhidapi.dylib' (no such file), '/Users/reddwarf/SSe/flutter/bin/cache/dart-sdk/bin/../../../libhidapi.dylib' (no such file), '/Users/reddwarf/SSe/flutter/bin/cache/dart-sdk/bin/Frameworks/libhidapi.dylib' (no such file), '/Users/reddwarf/SSe/flutter/bin/cache/dart-sdk/bin/./libhidapi.dylib' (no such file), '/Users/reddwarf/SSe/flutter/bin/cache/dart-sdk/bin/../../../libhidapi.dylib' (no such file), '/Users/reddwarf/SSe/flutter/bin/cache/dart-sdk/bin/Frameworks/libhidapi.dylib' (no such file), 'libhidapi.dylib' (no such file), '/usr/lib/libhidapi.dylib' (no such file), '/Users/reddwarf/SSe/app/SANDBOX/hidapi_dart-2/example/libhidapi.dylib' (no such file), '/usr/lib/libhidapi.dylib' (no such file)
do you know where the program search lib because, it doesn't seem to search with $PATH value
Uh, sorry for that, I'm not very familiar with Mac OS.
i met some issue with mac because of difference of architecture between intel and apple chipset.. so, i tried to test iwth windows and i have this error when i launch the example
reading...
Unhandled exception:
Invalid argument(s): Failed to lookup symbol 'wcslen': error code 749726248
#0 DynamicLibrary.lookup (dart:ffi-patch/ffi_dynamic_library_patch.dart:34:70)
#1 _wcslen (package:hidapi_dart/hidapi_ffi.dart)
#2 _wcslen (package:hidapi_dart/hidapi_ffi.dart)
#3 wstringLen
#4 fromWString
#5 HID.getProductString.<anonymous closure>
#6 using
#7 HID.getProductString
#8 info
#9 main
#10 _delayEntrypointInvocation.<anonymous closure> (dart:isolate-patch/isolate_patch.dart:295:32)
#11 _RawReceivePortImpl._handleMessage (dart:isolate-patch/isolate_patch.dart:192:12)
Exited (255)
any idea?
NB: i downloaded the dll from https://github.com/libusb/hidapi/releases and copied into system32 folders dll
oh, this is the native function I loaded for implementing some buffer handling in ffi interface. Looks like it's not located in the dll I selected. Let me fix it
Fixed, should be fine now.
i will check this. Thank you !!!
that's ok. thank you! i will continue to explore your lib. i close this issue
when i used, that's ok, the lib get my usb device (product and serial)
i use the read function, nothing is return
var ret = await hid.read(timeout: 1);
return '' if i precise a timeout and if i precise nothing, the method never returns
is it possible to discuss with usb device. i would like to send APDU et get the response cf: https://speculos.ledger.com/user/clients.html
this should be the intended behavior. if you didn't supply the timeout, it will just wait until the device is readable. if you supplied a timeout but the timeout expires, it will return an empty string instead (since hidapi will report it read 0 bytes in this case.)
sorry but I need a small help in your example, what is the command please to send command 'e0c4000000' to a device with pid = '0x1011' and vid='0x2C97' please And how to get the result. thx
You can invoke the example program like dart run main.dart 0x2c97 0x1011 -- e0c4000000
.
this should send and read response from the device.
and don't forget to pull the changes before executing the command above, I've changed the argument parsing.
thx i appreciate a lot your help!
. i tried yesterday like you said The raw for 0x2c97 is 'àA' and the response is [196, 0, 0 ,0, 0, 0...] i was surprise by the value of raw in input. And how to transform the output in String ?
Oh, because the old example will just dump the raw value, updated example program should output hex string instead.
And, don't forget to pull the newer version because I've pushed a fix for a crash would occur under some circumstances.
ok. great. i will test that in few hours. don't you think, it could be interesting to integrate directly in your project hidapi libs for windows, linux and macos ? is it possible ?
uh, you're saying bundle the hidapi libs in this project? maybe doable, but gotta find out how to do this properly.
for info, i test with your last dev My APDU in input 'e0c4000000' is changed by raw = 'c3a0c384000000'. Why don't you send directly the APDU ? and i receive '' when i read. So for my context, it doesn't work sadly
other thing: the timeout paramter is missing here: https://github.com/NightFeather/hidapi_dart/blob/cad10a47a74d4ced470f3ee10ece1c8eea117bcc/example/main.dart#L128
when i execute the example with my paramter, i changed the timeout with 5 but i don't wait 5 seconds for the result. it responded quickly
Uh, looks like something have gone wrong during the payload parsing. and looks like need documentation for the timeout parameter, actually it's in milliseconds not seconds.
Okay, the real payload sent should be fine. The changed payload are the artifact from I'm using wrong way to convert it to hex string. Looks like using utf8 codec for those stuff isn't a good idea.
ok. have you any idea ?
I'm gonna rework some parts so it may take a bit of time.
Ok thank I will test for you if you need
Fix pushed.
thank you for your speed :)
new test and result for:
[write, 0x2c97, 0x1011, --, e0c4000000]
'> e0c4000000 < c4000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
I'm waiting the value '1b300200010100039000'
for info, i tested a web version https://pub.dev/packages/web_hid and it works in web mode. perhaps it could be helpful for you and your lib
the project i refer integrate this: https://wicg.github.io/webhid/
i test with another apdu '> b0010000 < 01000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
it seems the response = substring(APDU, 2)
Hello. Have you any time to work on this? Thx!
Hello. do you think you will work on the project or do you want i close this issue ? Thx
Hello I’m searching a way to interact with device supports usb HID protocol with APDU commands Perhaps your lib will be a good way but could you migrate to flutter 2 please if possible? Thank you