You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
READIDCARD_API typedef void(*PIDDataCB)(char * pData);
READIDCARD_API int initReadIdcard(PIDDataCB func);
and with node-ffi, I can call it with:
const ffi = require('ffi');
let ReadIdcard = ffi.Library('./ReadIdcard.dll', {
'initReadIdcard': ['int', ['pointer']]
});
let callback = ffi.Callback('void', ['string'],
function(data) {
console.log("data: ", data);
}
);
console.log("registering the callback");
ReadIdcard.initReadIdcard(callback);
console.log('done');
// Make an extra reference to the callback pointer to avoid GC
process.on('exit', function() {
callback
});
now, I hope use fastcall rewrite it, and read the doc, I load DLL, but don't know how to callback, maybe I can use ffi.Callback to create a callback function, But without node-ffi, Is there a way only with fastcall to use callback
throw new TypeError('Cannot make callback from: ' + value);
^
TypeError: Cannot make callback from: [object Object]
at FastCallback.makePtr (E:\code\node-project\node___callback\node_modules\fastcall\lib\FastCallback.js:82:15)
at Ctx.(anonymous function).value [as argSetter0] (E:\code\node-project\node___callback\node_modules\fastcall\lib\Fa
stFunction.js:130:52)
at Ctx.eval (eval at _makeSyncFunction (E:\code\node-project\node___callback\node_modules\fastcall\lib\FastFunction.
js:159:25), <anonymous>:3:26)
at Object.func [as initReadIdcard] (E:\code\node-project\node___callback\node_modules\fastcall\lib\FastFunction.js:1
66:30)
at Object.<anonymous> (E:\code\node-project\node___callback\run.js:27:15)
at Module._compile (module.js:643:30)
at Object.Module._extensions..js (module.js:654:10)
at Module.load (module.js:556:32)
at tryModuleLoad (module.js:499:12)
at Function.Module._load (module.js:491:3)
at Function.Module.runMain (module.js:684:10)
at startup (bootstrap_node.js:187:16)
at bootstrap_node.js:608:3
thank you
The text was updated successfully, but these errors were encountered:
Hello, My DLL declare:
and with node-ffi, I can call it with:
now, I hope use fastcall rewrite it, and read the doc, I load DLL, but don't know how to callback, maybe I can use
ffi.Callback
to create a callback function, But without node-ffi, Is there a way only with fastcall to use callbackerror:
thank you
The text was updated successfully, but these errors were encountered: