dart-lang / dart-lang/native

Run desktop app Lost connection to device.

Open
#908 2 comments 0 reactions 0 assignees View on GitHub
package:ffi
Dominant language
Dart
Stars
275
Forks
144
Avg merge
2d 10h
Merged PRs (30d)
47

Description

run windows . flutter calls the DLL, and already gets the value returned by c. But then it will lose connection to device.
I don't know what's causing this.Below is my code
` Future sendAPDUHex(String cmd) async {
int sendLen = cmd.length ~/ 2;
try {

Pointer apduRLen = calloc.allocate(sizeOf());

Pointer apduResData = calloc.allocate(sizeOf());

Pointer sendData = cmd.toNativeUtf8();

int apduRst =
await cpuAPDUHexFun(icDev, sendLen, sendData, apduRLen, apduResData);
debugPrint("apduRst=$apduRst");
if (apduRst != 0) {
return "";
}
Pointer dataFromAddress =
Pointer.fromAddress(apduResData.address);
String message = dataFromAddress.toDartString();
debugPrint("message=$message");
await Future.microtask(() => calloc.free(apduRLen));
await Future.microtask(() => calloc.free(apduResData));
await Future.microtask(() => calloc.free(dataFromAddress));
return message;
} on ArgumentError catch (e) {
return e.toString();
} on Exception catch (e) {
return e.toString();
}
}`

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.