我正在尝试通过包jnpout32reg(http://www.hytherion.com/beattidp/comput/pport.htm)与并行端口进行通信,这是一个inpout32(http://www.highrez.co.uk/downloads/inpout32/)的Java实现。我已经使用并行端口测试器(下载.cnet.com / Parallel-Port-Tester / 3000-2086_4-75940249.html)测试了inpout32,这似乎完美无缺。但是,java实现似乎不起作用。
package ioTest_reg;
import hardware.jnpout32.*;
public class ioTestReg
{
static short datum;
static short Addr;
static pPort lpt;
static void write()
{
datum = 0x001;
// Notify the console
System.out.println("Write to Port: " + Integer.toHexString(Addr) +
" with data = " + Integer.toHexString(datum));
//Write to the port
long start = System.currentTimeMillis();
long stop = System.currentTimeMillis();
while (stop-start < 10000){
lpt.output((short)0x001);
stop = System.currentTimeMillis();
}
System.out.println("Finished");
}
static void do_read_range()
{
// Try to read 0x378..0x37F, LPT1:
for (Addr=0x378; (Addr<0x380); Addr++) {
//Read from the port
datum = (short) lpt.input(Addr);
// Notify the console
System.out.println("Port: " + Integer.toHexString(Addr) +
" = " + Integer.toHexString(datum));
}
}
public static void main( String args[] )
{
lpt = new pPort();
Addr=0x378;
datum=0x01;
write();
// Try to read 0x378..0x37F, LPT1:
do_read_range();
}
}
与端口建立连接,我可以从端口读取(端口378返回78,379返回79等...)。但是,我不能写输出。没有给出错误,但接收端没有任何反应(与并行端口测试器相反)。
当我使用jnpout32pkg(不同版本的jnpout32reg)时,我收到以下错误(即使我安装了所有类似的东西):
Exception in thread "main" java.lang.UnsatisfiedLinkError: ioTest_pkg.jnpout32.ioPort.Out32(SS)V
我做错了什么,pkg和reg之间有什么区别?