Gnanavel
Gnanavel

Reputation: 665

How to use USB interface of R307 fingerprint module?

I want to use the R307 fingerprint module using USB Protocol. I found an SDK for it that included a dll file. Now I want to use NodeJS to call the dll functions. So, I used node ffi module to call native dll functions.

DLL file link: https://drive.google.com/file/d/1dmcdtgajeuOvK0gH0BV2ricJ850Yo722/view?usp=sharing

DLL Documentation link: https://drive.google.com/file/d/1LtCfMjyISxUehI-48rJboxXjPTgBCZC8/view?usp=sharing

This is my code:

const ffi = require("ffi");
const ref = require('ref')

const intPtr = ref.refType('int');

const R307 = new ffi.Library("./SynoAPIEx", {
    "PSOpenDeviceEx": [
        "int32", [intPtr, "int32", "int32", "int32", "int32", "int32"]
    ],
    "PSCloseDeviceEx": [
        "int32", [intPtr]
    ],
    "PSGetImage": [
        "int32", [intPtr, "int32"]
    ]
});


const pHandle = ref.alloc(ref.types.int, 0)
const status = R307.PSOpenDeviceEx(pHandle, 2, 1, 1, 2, 0)
if (status === 0) {
    const response = R307.PSGetImage(pHandle, 1)
    console.log(response);
}

I first tried to connect to the R307 fingerprint sensor using the PSOpenDeviceEx function and received a return value of 0. According to the documentation, 0 means "OK."

Then I used PSGetImage function to read the fingerprint. This function accepts pHandle and nAddr as arguments. According to documentaion the value of pHandle will be set by PSOpenDeviceEx function. When I call this function I am getting -1 as return value. And I also don't know what is the exact error. PLs help me.

Upvotes: 0

Views: 628

Answers (1)

Tehseen
Tehseen

Reputation: 98

A similar type of situation is present in an example project on Github. An example code is available on GitHub using this SynoAPIEX DLL. This is the implementation of the PSOpenDeviceEx function in this example: enter image description here

And the implementation of the PSGetImage function is also in next piece of code: enter image description here

These lines of code are present in the Test.cs file under FingerPrintDEMO module: enter image description here

Some text like comments and string messages are in Chinese language but you can easily convert them using Google Translate if you like.

Demo Application Source Code: https://github.com/Meng-Ye/SynoAPIEx-v3.035

Upvotes: 1

Related Questions