使用插座处理生物识别指纹考勤设备 [英] Handling a Biometric Fingerprint Attendance Device by using socket

查看:20
本文介绍了使用插座处理生物识别指纹考勤设备的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I am trying to connect with a Biometric Fingerprint Attendance Device using a Java program. The device I am using is a Biocom Fingerprint attendance system. However, I am search and reading about that and I see the SDK could used which based on device type (which hard, not logical, moreover, it is not global solution!)

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

I research 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. Currently, I tried to connect with the device by creating a Socket object (through Ethernet port) but also not executed with me. This open infinite loop problems on my head.

  • 是否有任何通用的标准方法可以使用 Java 从此类设备连接、发送和检索数据?
  • Socket 是否可以作为此类问题的解决方案?
  • 如果是,我下面的代码有什么问题?除了主机 IP 和端口号之外,还需要什么其他东西来连接设备?
  • Is there any general, standard way to connect, send and retrieve data from such device using Java?
  • Can a Socket be considered as a solution for such problem?
  • If yes, what is wrong in my code below? What additional things more than the host IP and port number are needed to connect with the device?

使用的 Socket 代码:

The Socket code that used:

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();
}
}

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

This image may give more details:

推荐答案

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

You don't need the ObjectInputStream. Just use the InputStream you get from requestSocket.getInputStream().

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

Alternatively use a terminal programm like putty to connect to your device. This requires no coding.

这篇关于使用插座处理生物识别指纹考勤设备的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆