[DB25] Parallel Port with Java

For discussions about programming, programming questions/advice, and projects that don't really have anything to do with Puppy.
Post Reply
Message
Author
User avatar
xxxlam
Posts: 18
Joined: Thu 28 Jul 2011, 07:53
Location: South East Asia

[DB25] Parallel Port with Java

#1 Post by xxxlam »

Hello guys, I want to ask our programmer folks out there; how do I communicate with my db25 parallel port with Puppy Linux?

In WenD0wz XP, I'm using java to do so. As you can see, I'm using a native WenD0wz jnpout.dll. [see attached file] I just wonder if I can do it in Puppy, too!

Any help will do, thanks guys in advance! =)
Attachments
DB25java.zip
Interaction with db25 parallel port using java in WenD0wz XP.
(50.89 KiB) Downloaded 301 times
[size=150][b][color=blue]System[/color].out.[color=green]println[/color]([color=red]"Hello, Puppies! "[/color]);[/b][/size]

User avatar
xxxlam
Posts: 18
Joined: Thu 28 Jul 2011, 07:53
Location: South East Asia

#2 Post by xxxlam »

For the second time, no sign of hope.

Hmm... But at least you can teach me how to communicate with parallel port db25 IN ANY PROGRAMMING LANGUAGE. Or if not, how to edit a memory block?
[size=150][b][color=blue]System[/color].out.[color=green]println[/color]([color=red]"Hello, Puppies! "[/color]);[/b][/size]

User avatar
Dave_G
Posts: 453
Joined: Thu 21 Jul 2011, 13:53

#3 Post by Dave_G »

Hi xxxlam,

The way linux handles h/ware ports is very different to the way XP (and later)
versions of windoze does it.

So depending on your application/s, there are several methods to use them with linux.

Please give a detailed description of what you want to achieve and I will try and help.

Dave.

muggins
Posts: 6724
Joined: Fri 20 Jan 2006, 10:44
Location: hobart

#4 Post by muggins »

Parconis a simple c program, with a little tk gui, that lets you toggle // port pins.
Last edited by muggins on Fri 26 Apr 2019, 23:43, edited 1 time in total.

muggins
Posts: 6724
Joined: Fri 20 Jan 2006, 10:44
Location: hobart

#5 Post by muggins »


User avatar
Dave_G
Posts: 453
Joined: Thu 21 Jul 2011, 13:53

#6 Post by Dave_G »

Hi muggins,

Nice links.

I'm no expert a C but it seems to me that the code for Parcon is missing
a ioperm(888, 1, 0) just after the outb(val,888);

Since a ioperm(888, 1, 1) was called earlier on, then it's good
programming practice to close the port (and permissions) when done.

Another feature the program could benefit from is not having the port
address hardcoded but rather allow the user to pass it as a parameter
when executing the program.

Although 888 (0x378) is the default address for the first parallel port,
I have come across computers having them at address 956 (0x3BC).

Dave.

User avatar
Dave_G
Posts: 453
Joined: Thu 21 Jul 2011, 13:53

#7 Post by Dave_G »

An easy way to find the address of your LPT is to look
at the BIOS data area at (address:offset) 0000:0408

User avatar
xxxlam
Posts: 18
Joined: Thu 28 Jul 2011, 07:53
Location: South East Asia

#8 Post by xxxlam »

Dave_G, what I'm trying to achieve is to light up an L.E.D. bulb using Java (in the case of Wend0wz)... and according to the best of my knowledge, it's located in 0x378. The file uploaded is simulation of the police car lights.

Muggins, I'll be looking at those sites later since I'm not allowed to execute applications here in the internet library. THanks for the links by the way.

And, oh, by the way, why is it that my pin number 17 appears to be a ground instead of a control/output? Well, again, thanks guys for the great help. =)
[size=150][b][color=blue]System[/color].out.[color=green]println[/color]([color=red]"Hello, Puppies! "[/color]);[/b][/size]

User avatar
Dave_G
Posts: 453
Joined: Thu 21 Jul 2011, 13:53

#9 Post by Dave_G »

Hi,

Why make your life difficult and try and use Java to access ports unless
you have a very good reason to.
Java h/ware I/O is very much an after thought by the developers.

My suggestion to you is to make an executable using either C or asm
then call that when ever you need to output something to the port.

0x378 is the "normal" address for LPT1 and 99% of the time you can safetly
assume that is where your LPT is located but as I said before there is always
the other 1%.

As to your question about Pin17, have you checked that your LPT is set to SPP
as opposed to EPP or ECP mode?
The newer (ECP) mode makes all the pins bi-directional so it could be
that your pin is actually set to input and is floating "low".

Also remember that pin17 is part of the control port so it's address
is not 0x378 but 0x378+2 = 0x37A
If you only need a few pins to drive some LED's why not just use the data pins (pins 2 to 9)? at least they are at 0x378

User avatar
Dave_G
Posts: 453
Joined: Thu 21 Jul 2011, 13:53

#10 Post by Dave_G »

If memory serves me correctly, pin 17 is rather strange in that some LPTs
have a open collector output for this pin and therefore if you don't have a
pull-up resistor (normally in the actual printer), you will always read a 0.

As I said in my previous post, rather use pins 2 to 9, much easier and they
are standard.
You may also want to consider going thru a TTL octal buffer to offer some
protection to your port in case something goes wrong with your circuit.
The octal buffer will also increase the drive capabilities of the data pins.

User avatar
xxxlam
Posts: 18
Joined: Thu 28 Jul 2011, 07:53
Location: South East Asia

#11 Post by xxxlam »

Thanks Dave and Muggins for the GREAT HELP you've provided. Well, I hope you understand that I'm still in the university and learning a lot of things: studying Parallel Port DB25 is not part of my course -- It's my hobby.

By the way, what I'm trying to achieve are too many to mention: I want to switch my TV, to create a custom keyboard to open my door, to create my custom sound I/O device, switch on/off lights in my laboratory (my room)... You feel me?

Well Java is my specialty but C is not, I'm still learning (by my self; C is not discussed in the university.) Until now I'm amazed with my self! XD LOL.

By the way, in W3nD0wz I have 8 input, 8 output, 9 grounds (including pin 17 I mentioned earlier). In Puppy Linux, I have 16 output, no input, 9 grounds (the same).

Again, thanks for the great help. Sorry it took some time to reply in this post; I have to download lupu_devx_525.sfs in a very slow internet connection here in the university.

// Allan
[size=150][b][color=blue]System[/color].out.[color=green]println[/color]([color=red]"Hello, Puppies! "[/color]);[/b][/size]

Post Reply