简体   繁体   English

在Linux上从Java访问PC硬件端口

[英]PC hardware port access from Java on Linux

What is the Java-on-Linux equivalent to the C byte-sized PC-architecture hardware port input/output functions? Linux上的Java与C字节大小的PC架构硬件端口输入/输出功能等效吗?

For output there is outb as in this: 对于输出,有outb如下所示:

tmp = inb(0x61);
if (tmp != (tmp | 0x01)) 
    outb(0x61, tmp | 0x01);

For input there is inb as in this: 输入为inb如下所示:

tmp = (inb(0x61) & 0xfe);
outb(0x61, tmp);

Purpose: I want to implement something that imposes less overhead than this: 目的:我想要实现一些比这更少的开销的事情:

try { Runtime.getRuntime().exec("beep") } catch (IOException e) {}

as an alternative to sending code 7 (the bell char) to the standard output because that seems to have been aggressively disabled in Ubuntu. 作为将代码7(钟形字符)发送到标准输出的一种替代方法,因为在Ubuntu中似乎已禁用了该功能。 Toolkit's beep is also mute. 工具箱的提示音也静音。

I think you're barking up the wrong train. 我认为您在错车。

Java is a object-oriented high-level language compiling to a virtual machine architecture. Java是一种编译为虚拟机体系结构的面向对象的高级语言。 Assembler I/O instructions are hardware processor specific. 汇编器I / O指令特定于硬件处理器。 There is no direct equivalence between the two. 两者之间没有直接的对等关系。

The best you could hope for is to interface your Java code (using pipes, shared memory, sockets, etc) with a native Linux app which performs the required I/O. 您可能希望最好的办法是将Java代码(使用管道,共享内存,套接字等)与执行所需I / O的本地Linux应用程序接口。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM