Java 从生物指纹考勤设备检索数据

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/20732928/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-13 03:53:29  来源:igfitidea点击:

Retrieving data from Biometric Fingerprint Attendance Device

javasocketsnetworkingfingerprintbiometrics

提问by RocketRuwan

I am trying to connect with a Biometric Fingerprint Attendance Deviceusing a Java Program. The device I am using is a Pegasus T5Fingerprint scanner. Unfortunately their SDK for this device (which can be downloaded here) covers only C#, .Net, and VB which I have no expertise. And when I have requested the manufacturers, they have replied that there is no Java SDKfor the device. Even though I have no knowledge on any of those languages, I gave a try to understand the codes in the SDK to find out how the device is connecting and I saw that it is just making a connection with the device using the network ip and port number.

我正在尝试使用 Java 程序连接生物指纹考勤设备。我使用的设备是Pegasus T5指纹扫描仪。不幸的是,他们针对该设备的 SDK(可在此处下载)仅涵盖 C#、.Net 和 VB,我对此一无所知。当我询问制造商时,他们回答说该设备没有Java SDK。尽管我对这些语言一无所知,但我尝试理解 SDK 中的代码以了解设备的连接方式,我发现它只是使用网络 ip 和端口与设备建立连接数字。

If you refer to the C# SDK of the device, you can see the example I saw on this at frmEvent.cswhich in the cmdStartMoniter_Clickmethod, make the connection as follows.

如果你参考设备的C# SDK,你可以看到我在frmEvent.cs看到的例子 ,在cmdStartMoniter_Click方法中,进行如下连接。

bRet = bpc.StartEventCapture(0, util.pubIPAddrToLong(txtSourceIP.Text), Convert.ToInt32(txtPortNumber.Text));

And that refers to the method StartEventCaptureas public virtual bool StartEventCapture(int dwCommType, int dwParam1, int dwParam2);which is in a .dllfile as it appears and which I have lost my track as I have further knowledge on how to figure out the code.

这指的是.dll文件中的方法StartEventCapture,因为我对如何找出代码有了进一步的了解,因此我已经迷失了方向。public virtual bool StartEventCapture(int dwCommType, int dwParam1, int dwParam2);

However keeping that example I had seen in my head, as my next step I started researching for a global standard on how to connect, send and retrieve data with a Fingerprint Device which again I wasn't lucky enough to find a clear solution. But with some examples from some people who have been trying to deal with the same and the example I saw by myself, I tried to connect with the device by creating a Socketobject but when I executed it, it only resulted with the java.net.ConnectException: Connection timed out: connect

然而,保持我在脑海中看到的那个例子,作为我的下一步,我开始研究关于如何使用指纹设备连接、发送和检索数据的全球标准,但我再次没有足够幸运地找到一个明确的解决方案。但是从一些试图处理相同问题的人的一些例子以及我自己看到的例子中,我试图通过创建一个Socket对象来连接设备,但是当我执行它时,它只会导致java.net.ConnectException: Connection timed out: connect

There are four questions

有四个问题

  1. Is there any Java SDK for Biometric Fingerprint Attendance Devices which I can use for my device as well?
  2. Is there any general, standard way to connect, send and retrieve data from such device using Java?
  3. Ifconnecting to the device via a Socketis a solution, is there any specific, standard requests I should be sending to the device in order to receive a response from it?
  4. If the attempt I have made is a way to do it, what I have I done wrong with it and how should I correct the problem?
  1. 是否有任何适用于生物识别指纹考勤设备的 Java SDK 也可以用于我的设备?
  2. 是否有任何通用的标准方法可以使用 Java 从此类设备连接、发送和检索数据?
  3. 如果通过 a 连接到设备Socket是一种解决方案,是否有任何特定的标准请求我应该发送到设备以接收来自它的响应?
  4. 如果我所做的尝试是一种方法,那么我做错了什么,我应该如何纠正问题?

This is the code I used to connect with the device.

这是我用来连接设备的代码。

    String host = "192.168.168.100";
    int port = Integer.parseInt("5005");

    try {
        Socket socket = new Socket(host, port);
        BufferedReader in = new BufferedReader(new InputStreamReader(socket.getInputStream()));

        String line;
        while (true){
            line = in.readLine();
            if (line != null){
                System.out.println(line);
            }
        }
    } catch (UnknownHostException e) {
        e.printStackTrace();
    } catch (IOException e) {
        e.printStackTrace();
    }

回答by user1911721

Each biomatric device have normally lAN port or Web interface. Biomatric device sends data on specific port. for example

每个生物矩阵设备通常都有 LAN 端口或 Web 界面。Biomatric 设备在特定端口上发送数据。例如

192.168.1.23:8080

you can make connection to it using java sockets and can read data ..

您可以使用java套接字连接到它并可以读取数据..

Socket socket = new Socket("192.168.1.23","8080");

keep it up

保持

enjoy

请享用

回答by Victor

If you try to access the biometric machines to associate with your web application, then look for CAMSUnit machines. CAMS provides the WEB APIsfor their biometric machines. It supports registering the callback URL which gets called every time a new attendance is registered.

如果您尝试访问生物识别机器以与您的 Web 应用程序关联,请查找 CAMSUnit 机器。CAMS为其生物识别机器提供WEB API。它支持注册回调 URL,每次注册新考勤时都会调用该 URL。

回答by Kevin

Just gone through the sample code downloaded from the link shared in the question. let me share my few cents, if that helps you.

刚刚浏览了从问题中共享的链接下载的示例代码。让我分享我的几分钱,如果这对你有帮助。

As per the code, we can not directly connect the machine through simple socket programming. Which is possible, only if you know the low level communication protocol which none of the manufactures do share. So, you must follow their SDKs only.

根据代码,我们不能通过简单的socket编程直接连接机器。这是可能的,前提是您知道没有制造商共享的低级通信协议。因此,您必须仅遵循他们的 SDK。

Coming to the SDK

来到 SDK

AxSBXPC::StartEventCapture has three paramters, where 1st one says TCP/IP or serial communication. 0 means TCP/IP, and 1 means serial communication.

for TCP/IP, 2nd and 3rd parameters are IP and PORT.

First implement a simple program by just connecting the machine through TCP/IP. Once success, you can move implementing the events and handling the data. Before running the program, you must check if the biometric machine is pingable in the computer by the configured IP.

AxSBXPC::StartEventCapture 具有三个参数,其中第一个表示 TCP/IP 或串行通信。0 表示 TCP/IP,1 表示串行通信。

对于 TCP/IP,第二个和第三个参数是 IP 和 PORT。

首先实现一个简单的程序,只需通过 TCP/IP 连接机器。一旦成功,您就可以移动实现事件和处理数据。在运行程序之前,您必须检查生物识别机器是否可以通过配置的 IP 在计算机中 ping 通。

You need to find events for attendance, user update, and etc., and implement them as per the need. Events are triggered with XML parameter which holds all the data Data, so you must find the keys of every item you like to read.

您需要查找考勤、用户更新等事件,并根据需要进行实施。事件由保存所有数据的 XML 参数触发,因此您必须找到您喜欢阅读的每个项目的键。

Pegasus doesn't provide the direct cloud communication, if you need the direct cloud communication, as Victor pointed out, you will have to use the web api supported biometric machines.

Pegasus 不提供直接云通信,如果您需要直接云通信,正如 Victor 所指出的,您将必须使用支持 web api 的生物识别机器。