【问题标题】:Handling a Biometric Fingerprint Attendance Device by using socket使用插座处理生物识别指纹考勤设备
【发布时间】:2014-07-22 08:35:20
【问题描述】:

我正在尝试使用 Java 程序连接生物识别指纹考勤设备。我使用的设备是 Biocom 指纹考勤系统。但是,我正在搜索和阅读相关内容,我看到可以使用基于设备类型的 SDK(这很难,不合逻辑,而且,它不是全局解决方案!)

我研究了有关如何使用指纹设备连接、发送和检索数据的全球标准,但我还是没有幸运地找到明确的解决方案。目前,我尝试通过创建Socket 对象(通过以太网端口)与设备连接,但也没有与我一起执行。这个打开的无限循环问题在我头上。

  • 是否有任何通用的标准方法可以使用 Java 从此类设备连接、发送和检索数据?
  • 可以将Socket 视为此类问题的解决方案吗?
  • 如果是,我下面的代码有什么问题?除了主机 IP 和端口号之外,还需要什么其他东西来连接设备?

使用的 Socket 代码:

import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.net.Socket;
import java.net.UnknownHostException;

public class Requester {
Socket requestSocket;
ObjectOutputStream out;
ObjectInputStream in;
String message;

Requester() {
}

void run() throws IOException {
    try {
        // 1. creating a socket to connect to the server
        requestSocket = new Socket("192.168.0.19", 4370);
        System.out.println("Connected to given host in port 4370");
        // 2. get Input and Output streams
        in = new ObjectInputStream(requestSocket.getInputStream());
        // 3: Communicating with the server
        String line;
        while (true) {
            line = in.readLine();
            if (line != null) {
                System.out.println(line);
            }
        }
    } catch (UnknownHostException unknownHost) {
        System.err.println("You are trying to connect to an unknown host!");

    } catch (IOException ioException) {
        ioException.printStackTrace();

    } catch (Exception Exception) {
        Exception.printStackTrace();

    } finally {
        in.close();
        requestSocket.close();
    }
}

void sendMessage(String msg) {
    try {
        out.writeObject(msg);
        out.flush();
        System.out.println("client: " + msg);

    } catch (IOException ioException) {
        ioException.printStackTrace();
    }
}

public static void main(String args[]) throws IOException {
    Requester client = new Requester();
    client.run();
}
}

这张图片可能会提供更多细节:

【问题讨论】:

  • 那么...应用程序表现如何?它会抛出一些异常吗?是不是什么都没读?
  • 是的,它没有读取任何内容!它在这条线之后停止 in = new ObjectInputStream(requestSocket.getInputStream()); !!这意味着它没有到达设备(可能)!
  • ObjectInputStream 反序列化原始数据和以前使用 ObjectOutputStream 编写的对象。您意识到您尝试接收的数据没有被 ObjectOutputStream 序列化,因此不会接收到正确的输入,请尝试将其包装在更通用的 InputStream 中,例如简单的 BufferedReader: BufferedReader reader = new BufferedReader(new InputStreamReader( requestSocket.getInputStream()))
  • 谢谢,但我真的试过了,但没有希望:((!)我不知道是什么问题而且我一直卡在没有任何进展的情况下!!没有任何教程,真是无限郁闷(而且没有人可以问:()!@TFC

标签: java sockets network-programming fingerprint biometrics


【解决方案1】:

您不需要ObjectInputStream。只需使用从requestSocket.getInputStream() 获得的InputStream

或者使用 putty 等终端程序连接到您的设备。这不需要编码。

【讨论】:

  • 感谢您的回答,我将代码更改为 [ in = requestSocket.getInputStream(); inputS = new BufferedInputStream(in); System.out.println(inputS.toString()); ] 并得到我不明白的 (java.io.BufferedInputStream@190d11) 的结果,请问这是什么意思?!
  • System.out.println(inputS.toString());这将打印 BufferedInputStream 对象 toString,您需要将其包装在各种阅读器中。
【解决方案2】:

Biocom Biometrics 是 ZKTeco 设备。 ZkTeco 设备仅使用 windows SDK 启动。您可以从https://www.zkteco.com/en/download_catgory.html 下载 SDK 并在 java 中使用只能在 Windows 平台上运行的 DLL。 HTTP通信,任何平台,任何语言,参考http://camsunit.com/application/zk-teco-essl-api-integration.html

【讨论】:

  • 是的,这是收费的。制造商始终将在线 API 作为许可提供。
猜你喜欢
  • 1970-01-01
  • 2017-07-04
  • 2023-01-24
  • 2023-04-02
  • 2017-01-31
  • 1970-01-01
  • 2017-08-08
  • 1970-01-01
  • 2010-12-26
相关资源
最近更新 更多