Programming hardware controls

Discussion in 'Java' started by Galois271@gmail.com, Dec 1, 2008.

  1. Guest

    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
     
    , Dec 1, 2008
    #1
    1. Advertising

  2. Roedy Green Guest

    On Mon, 1 Dec 2008 12:52:09 -0800 (PST), wrote,
    quoted or indirectly quoted someone who said :

    >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)
     
    Roedy Green, Dec 2, 2008
    #2
    1. Advertising

  3. timjowers Guest

    On Dec 1, 8:18 pm, Roedy Green <>
    wrote:
    > On Mon, 1 Dec 2008 12:52:09 -0800 (PST), wrote,
    > quoted or indirectly quoted someone who said :
    >
    > >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.
    >
    > 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.
     
    timjowers, Dec 2, 2008
    #3
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. fred
    Replies:
    2
    Views:
    4,638
    Hermit Dave
    Jan 14, 2004
  2. Rajesh Bawa

    Re: Outsoursing Hardware verification

    Rajesh Bawa, Jul 5, 2003, in forum: VHDL
    Replies:
    2
    Views:
    1,190
    Prasanna
    Aug 5, 2003
  3. Amontec Team
    Replies:
    0
    Views:
    1,791
    Amontec Team
    Jul 11, 2003
  4. chellappa

    Hardware Programming

    chellappa, Jul 6, 2005, in forum: C Programming
    Replies:
    1
    Views:
    335
    Malcolm
    Jul 6, 2005
  5. Nathan Sokalski
    Replies:
    4
    Views:
    1,170
    Muhammad Naveed Yaseen
    Sep 5, 2007
Loading...

Share This Page