Programming hardware controls

G

Galois271

Hi all,

I am a relatively new programmer. Does anyone know how to write
programs that control the hardware of a computer, e.g. printers,
speakers, cd-roms, etc...?

Thanks!

Lurch
 
R

Roedy Green

I am a relatively new programmer. Does anyone know how to write
programs that control the hardware of a computer, e.g. printers,
speakers, cd-roms, etc...?

If the device has a fairly simple serial port or parallel port
protocol you can do it from high level java.

See http://mindprod.com/jgloss/serialport.html
http://mindprod.com/jgloss/parallelport.html

For anything else, you need to write a device driver, usually in C++
with a smattering of assembler, then write some glue in C++/JNI to
access the driver from Java.
see http://mindprod.com/jgloss/jni.html
--
Roedy Green Canadian Mind Products
http://mindprod.com
"Humanity is conducting an unintended, uncontrolled, globally pervasive experiment
whose ultimate consequences could be second only to global nuclear war."
~ Environment Canada (The Canadian equivalent of the EPA on global warming)
 
T

timjowers

If the device has a fairly simple serial port or parallel port
protocol you can do it from high level java.

Seehttp://mindprod.com/jgloss/serialport.htmlhttp://mindprod.com/jgloss/parallelport.html

For anything else, you need to write a device driver, usually in C++
with a smattering of assembler, then write some glue in C++/JNI to
access the driver from Java.
seehttp://mindprod.com/jgloss/jni.html
--
Roedy Green Canadian Mind Productshttp://mindprod.com
"Humanity is conducting an unintended, uncontrolled, globally pervasive experiment
 whose ultimate consequences could be second only to global nuclear war.."
~ Environment Canada (The Canadian equivalent of the EPA on global warming)


Yes, Java is not the first choice for hardware control per se. But, of
course, J2ME is designed to integrate with phones.
You can write a device driver and control hardware. Install Linux.
Write a kernel Module (in C). Make the module talk to hardware. How do
you "talk to hardware"? Take a look at existing opensource device
drivers for examples: http://lxr.linux.no/linux+v2.6.27.7/drivers/
Linux is all written in C. You could even bypass using JNI altogether
if you simply use a File I/O model. That is, your java code would open
the device as if it were a file and read and write to it. File-based
IO is the basic design of Unix (and therefore Windows NT and Linux).
Thus the serial port driver exposes itself as a file. (the magic
filename tells the OS to hook you to the serial port driver rather
than to the filesystem driver). The serial driver transmits characters
so is called a char mode driver so lives in that part of the source
tree: http://lxr.linux.no/linux+v2.6.27.7/drivers/char/generic_serial.c
etc.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top