I'm trying to make a Java program access a parallel port. Java's comm
API does not provide me with the control I need. I need to be able to
write to the data and control pins and read the status pins. Any Java
people know a good solution? I'm trying to use JNI and create my own
library, but building the library gives me these errors:
ld: warning: cannot find entry symbol _start; defaulting to
000000000804809 4
ParallelPort.o: In function `Java_ParallelP ort_setAddress' :
ParallelPort.cp p:(.text+0x96): undefined reference to `ioperm'
ParallelPort.cp p:(.text+0xaa): undefined reference to `ioperm'
Can anyone help me? Source follows.
ParallelPort.ja va
----------
public class ParallelPort {
static {
System.loadLibr ary("ParallelPo rt");
}
public ParallelPort() {
setAddress(0x37 8); // default to lp0
}
public ParallelPort(in t addr) {
setAddress(addr );
}
public native void setAddress(int addr);
public native int getAddress();
public native void sendData(int data);
public native int readStatus();
public native void sendControl(int control);
}
==========
ParallelPort.cp p
----------
#include "ParallelPort.h "
#include <jni.h>
#include <stdio.h>
#define extern static
#define REALLY_SLOW_IO
#include <asm/io.h> // port I/O
#undef extern
#include <sys/io.h> // for ioperm
jint DATA;
jint STATUS;
jint CONTROL;
JNIEXPORT void JNICALL Java_ParallelPo rt_setAddress(J NIEnv *env,
jobject obj,
jint addr) {
DATA = addr;
STATUS = addr + 1;
CONTROL = addr +2;
ioperm(DATA, 3, 1);
ioperm(0x80, 1, 1);
}
JNIEXPORT jint JNICALL Java_ParallelPo rt_getAddress(J NIEnv *env,
jobject obj) {
return DATA;
}
JNIEXPORT void JNICALL Java_ParallelPo rt_sendData(JNI Env *env, jobject
obj,
jint data) {
outb(data, DATA);
}
JNIEXPORT jint JNICALL Java_ParallelPo rt_readStatus(J NIEnv *env,
jobject obj) {
return inb(STATUS);
}
JNIEXPORT void JNICALL Java_ParallelPo rt_sendControl( JNIEnv *env,
jobject obj,
jint control) {
outb(control, CONTROL);
}
==========
ParallelPort.h (Auto-generated with javah)
----------
/* DO NOT EDIT THIS FILE - it is machine generated */
#include <jni.h>
/* Header for class ParallelPort */
#ifndef _Included_Paral lelPort
#define _Included_Paral lelPort
#ifdef __cplusplus
extern "C" {
#endif
/*
* Class: ParallelPort
* Method: setAddress
* Signature: (I)V
*/
JNIEXPORT void JNICALL Java_ParallelPo rt_setAddress
(JNIEnv *, jobject, jint);
/*
* Class: ParallelPort
* Method: getAddress
* Signature: ()I
*/
JNIEXPORT jint JNICALL Java_ParallelPo rt_getAddress
(JNIEnv *, jobject);
/*
* Class: ParallelPort
* Method: sendData
* Signature: (I)V
*/
JNIEXPORT void JNICALL Java_ParallelPo rt_sendData
(JNIEnv *, jobject, jint);
/*
* Class: ParallelPort
* Method: readStatus
* Signature: ()I
*/
JNIEXPORT jint JNICALL Java_ParallelPo rt_readStatus
(JNIEnv *, jobject);
/*
* Class: ParallelPort
* Method: sendControl
* Signature: (I)V
*/
JNIEXPORT void JNICALL Java_ParallelPo rt_sendControl
(JNIEnv *, jobject, jint);
#ifdef __cplusplus
}
#endif
#endif 12 8610
On Fri, 10 Feb 2006 19:44:54 -0800, david.brown.0 wrote: I'm trying to make a Java program access a parallel port.
The rxtx package has parallel port access, as well as others. www.rxtx.org
<da***********@ gmail.com> wrote in message
news:11******** *************@z 14g2000cwz.goog legroups.com... I'm trying to make a Java program access a parallel port. Java's comm API does not provide me with the control I need. I need to be able to write to the data and control pins and read the status pins. Any Java people know a good solution? I'm trying to use JNI and create my own library, but building the library gives me these errors:
<java error and code snipped>
Umm... why the heck are you asking about a Java issue cross posted to
c.l.c++ ?
RXTX was the only thing that had any form of parallel port access, but
as far as I can see, its just a native library without a Java side
implementation. I've done some more searching and found a lot that can
access the serial port, but not the parallel port. I'm trying to drive
an LCD display, so I cannot use the serial port short of buying a
BasicStamp, which is well out of reasonable price range. Java people
keep trying to find something. C++ people, help me build a working
parallel port library, in case I can't find anything. da***********@g mail.com wrote: RXTX was the only thing that had any form of parallel port access, but as far as I can see, its just a native library without a Java side implementation. I've done some more searching and found a lot that can access the serial port, but not the parallel port. I'm trying to drive an LCD display, so I cannot use the serial port short of buying a BasicStamp, which is well out of reasonable price range. Java people keep trying to find something. C++ people, help me build a working parallel port library, in case I can't find anything.
In WinXP and Linux and most modern oses, the parallel port is in
protected memory owned by system and you cant access it directly. You
would need to either use DOS outside windows or Win95/98 3.1. or get a
device driver as mentioned previously. (Look on internet for those.
they are usually available for your preferrred language too). For older
systems(DOS in windows or Win95/98 3.1.) you can get at the hardware.
Methods are often not standard (I think?) and are actually C not C++.
You will have to study the documentation, for example in VC6.0 you can
choose various options as follows:
#include <conio.h>
const static unsigned short PortA = 0x378;
intval =_inp(Port);
unsigned char val = 1;
_outp(Port,val) ;
alternatively use assembler eg:
__int16 PrinStat= PrinterStatus; // Port + 1...its a long time ago?
unsigned char temp0;
__asm {
mov dx,PrinStat /* setup for input from status reg*/
in al,dx
mov temp0,al
}
More info on parallel port workings available e.g http://www.lvr.com/jansfaq.htm
OTOH
More modern practise is to use USB or firewire, even Ethernet etc and
leave printer port alone as its old fashioned cumbersome with all its
wiring and required connectors and EMI dampening hardware and slow.
Some chips are set up to make use of e.g USB very simple. Software
compatible with their hardware is often free. See for example http://www.ftdichip.com/
Honestly learning about USB or other fast serial comms will be
preferable in the long term. Even modern printers dont use parallel
port;-)
cheers
Andy little
I'm just trying to control an LCD with 4x5 keypad, which maps perfectly
to the parallel port. I'm no electrical engineer. Plus the LCD
requires 4 or 8 bit parallel input (standard Hitachi-type).
On 12 Feb 2006 18:42:47 -0800, da***********@g mail.com wrote, quoted
or indirectly quoted someone who said : I'm just trying to control an LCD with 4x5 keypad, which maps perfectly to the parallel port. I'm no electrical engineer. Plus the LCD requires 4 or 8 bit parallel input (standard Hitachi-type).
if it does not talk back to you, perhaps you can drive it as if it
were a very stupid printer with a printer driver that just passes raw
"text" through.
see http://mindprod.com/jgloss/printing.html
Java lets you create PS files and pass them directly to a PS printer,
so there should be some way of creating text files and passing them
unmolested to a dumb printer.
--
Canadian Mind Products, Roedy Green. http://mindprod.com Java custom programming, consulting and coaching. da***********@g mail.com wrote: I'm just trying to control an LCD with 4x5 keypad, which maps perfectly to the parallel port. I'm no electrical engineer. Plus the LCD requires 4 or 8 bit parallel input (standard Hitachi-type).
Well. This thread is now Beyond off topic for a C++ language newsgoup.
I think you need to download the datasheets from Hitachi for the
particular LCD. I'd be amazed if they dont provide any driver
hardware/software frankly.
cheers
Andy Little da***********@g mail.com wrote: I'm trying to make a Java program access a parallel port. Java's comm API does not provide me with the control I need. I need to be able to write to the data and control pins and read the status pins. Any Java people know a good solution? I'm trying to use JNI and create my own library, but building the library gives me these errors:
ld: warning: cannot find entry symbol _start; defaulting to 000000000804809 4 ParallelPort.o: In function `Java_ParallelP ort_setAddress' : ParallelPort.cp p:(.text+0x96): undefined reference to `ioperm' ParallelPort.cp p:(.text+0xaa): undefined reference to `ioperm'
Actually the following links might explain whats going on. I'm guessing
you are using source code written for Linux or Unix on Windows? ioperm
lives in io.h in Linux, but doesnt exist in that header on Windows. You
could however try running Cygwin in Windows to get Unix like
functionality. http://www.die.net/doc/linux/man/man2/ioperm.2.html http://linux.about.com/library/cmd/blcmdl2_ioperm.htm http://openwince.sourceforge.net/ioperm/
cheers
Andy Little This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Joseph Suprenant |
last post by:
I am looking to read a byte or write a byte on the parallel port in linux.
I am using red hat 7.3. I tired using this but i couldnt get anywere.
{
unsigned char value;
__asm__ volatile ("inb %1,%0"
: "=a" (value)
: "d" ((unsigned short)port));
return value;
} */
|
by: Novice Experl |
last post by:
I'd like to write a simple application that interfaces with the parallel port, and changes the data on it according to keyboard input. I hope I can get it to run under windows xp and / or windows 2000.
How can I do this? What do I need to know? It doesn't look like the standard library (the one under my pillow) has that feature. In addition,...
|
by: David |
last post by:
I'm wondering if python is capable of fairly precise timing and also sending
data out the parallel port.
For example ; making a 7.5 KHz square wave come out of one of the data pins
on the printer port.
I've tried to help myself with this one but searching in the "Python Library
Reference" that installed with my version, yielded
nothing...
|
by: MNQ |
last post by:
Hi All
I want to use my parallel port of my PC to control some external devices. I
am writing a program in ANSI C using the PacificC compiler. What I need to
know is how to access the parallel port ie to send data and to read the
state of the parallel port including the control lines. Can anyone
help/point me in the correct direction? I...
|
by: MSDousti |
last post by:
Hi, everyone.
I have written this code in Tubo C++ 3.0 earlier, and now I want to
port it to VC.NET:
int out=0;
out=(out & 0xDF);
outportb(0x378,out);
....
As you see, it seeks to parallel port directly (port: 0x378)
| |
by: john |
last post by:
Hi,
I am trying to use "_outp " function to write to parallel port . I am
using microsoft visual C++6.0. I am using it like this _outp ( 956,
255) . I am using decimal numbers. The thing is that program crahes
evertime , I run it. Please advice!
John
#include < stdio. >
|
by: nik |
last post by:
hello frinds,
last night i am using C prog to get output at my
parallel port the following source code is
#include<dos.h>
#include<conio.h>
#include<process.h>
void main()
{
outportb( 0x378,00ff);
delay(1000);
|
by: abhi |
last post by:
Hello,
I want to create a small project which will display scrolling text on
LED that will be attached to Parallel port. I want to create this
project in C language(possibly in Mingw) on Windows XP. I want to know
how can i access(read and write data) on parallel port in XP.
I have a program that do the same thing but in its documentation...
|
by: Soren |
last post by:
Hi,
I want to control some motors using the parallel port.. however, my
laptop does not have any parallel ports (very few do). What I do have
is a USB->Parallel converter... I thought about using PyParallel, but
the USB->Parallel converter doesn't actually map to the LPT port ..
and PyParallel only looks for LPT ports?
Has anyone...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language...
| |
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it. ...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...
| |