-
Notifications
You must be signed in to change notification settings - Fork 11
Description
I'm sorry for opening another issue with similar title with already open issue, but since the last one was quite old without any response, I figured it's better to open new one.
Environment:
OS: Windows 10
NodeJS: v18.10.0
TypeScript
the error is more or less the same as previous issue:
Error: Unknown code error.
at new ErrorHandler (<omitted>\node_modules\uareu-node\dist\modules\handlers\error\error.handler.js:17:23)
at <omitted>\node_modules\uareu-node\dist\modules\index.js:113:24
at new Promise (<anonymous>)
at UareU.dpfpddInit (<omitted>\node_modules\uareu-node\dist\modules\index.js:103:48)
at <omitted>\test\app.js:455:17
At first, I used the code example you provided on readme, and decided to edit it a little to figure out where the code stopped working:
const { UareU, CONSTANTS } = require('uareu-node'); // Import
const uareu = UareU.getInstance(); // Get a unique instance of library handler.
let reader; // Create a variable to keep the reader handle after 'open' the device.
// Probably the code below will also work for you.
uareu.loadLibs() // Load libs
.then(() => { console.log("Uareu lib loaded"); uareu.dpfpddInit(); }) // Init libs
.then(() => { console.log("Uareu lib initialized"); uareu.dpfpddQueryDevices() }) // Search reader devices connected
.then((res) => { console.log("Uareu device scanned", res); uareu.dpfpddOpen(res.devicesList[0]) }) // 'Open' the reader device, it's needed for use others functions like: dpfpddCaptureAsync
.then((res) => { console.log("Uareu device opened"); if (res) reader = res; console.log("Uareu initialized") }) // Set reader variable
.catch((err) => { throw err; });With this code, it managed to run until the third callback:
Uareu lib loaded
Uareu lib initialized
Uareu device scanned undefined
Error: Unknown code error.
Notice that variable res is undefined, and the same error was thrown after that line on console.
Next I tried to check what's res type, so I changed the import line to this:
import { UareU, CONSTANTS } from "uareu-node";And then from TypeScript compiler:
Property 'devicesList' does not exist on type 'void'.
I figured that you need to return the function in the previous callback to make it wait and receive the res variable, so the code changes to this:
uareu.loadLibs() // Load libs
.then(() => { console.log("Uareu lib loaded"); return uareu.dpfpddInit(); }) // Init libs
.then(() => { console.log("Uareu lib initialized"); return uareu.dpfpddQueryDevices() }) // Search reader devices connected
.then((res) => { console.log("Uareu device scanned", res); return uareu.dpfpddOpen(res.devicesList[0]) }) // 'Open' the reader device, it's needed for use others functions like: dpfpddCaptureAsync
.then((res) => { console.log("Uareu device opened"); if (res) reader = res; console.log("Uareu initialized") }) // Set reader variable
.catch((err) => { throw err; });And so the compiler accepted this code and run it after compiling it, but the result was quite different:
Uareu lib loaded
Error: Unknown code error.
It only manages to run on first callback, the next one failed, meaning the error originated from calling uareu.dpfpddInit();.