Skip to Main Content

Java SE (Java Platform, Standard Edition)

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

I got a EXCEPTION_PRIV_INSTRUCTION

843798Jun 13 2008 — edited Jun 15 2008
Hi there,
I'm trying to control the parallel port using java.
Here's my code(very simple):
import parport.ParallelPort;
public class Principal {

	public static void main(String[] args) {
		ParallelPort lpt1 = new ParallelPort(0x378);
		
		for(int i=1; i<128; i=i*2){
			lpt1.write(i);
			try {
				Thread.sleep(500);
			} catch (InterruptedException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
		}
	}
	
}
Here's the code of the ParalellPort:
package parport;

	public class ParallelPort {

	   /** The port base address (e.g. 0x378 is base address for LPT1) */
	   private int portBase;

	   /** To cunstruct a ParallelPort object,
	     * you need the port base address
	   */
	   public ParallelPort (int portBase)
	   {
	      this.portBase = portBase;
	   }

	   /** Reads one byte from the STATUS pins of the parallel port.
	     *
	     * The byte read contains 5 valid bits, corresponing to 5 pins of input
	     * from the STATUS pins of the parallel port (the STATUS is located
	     * at "portBase + 1", e.g. the STATUS address for LPT1 is 0x379).
	     * 
	     * This diagram shows the content of the byte:
	     *
	     *  Bit | Pin # | Printer Status  | Inverted
	     * -----+-------+-----------------+-----------
	     *   7  |  ~11  | Busy            |   Yes
	     *   6  |   10  | Acknowledge     |
	     *   5  |   12  | Out of paper    |
	     *   4  |   13  | Selected        |
	     *   3  |   15  | I/O error       |
	     * 
	     * Note that Pin 11 is inverted, this means that "Hi" input on pin
	     * means 0 on bit 7, "Low" input on pin means 1 on bit 7.
	   */
	   public int read ()
	   {
	      return ParallelPort.readOneByte (this.portBase+1);
	   }

	   /** Writes one byte to the DATA pins of parallel port.
	     * The byte is written to the DATA pins of the port. The DATA pins are
	     * located at the base address of the port (e.g. DATA address for LPT1
	     * is 0x378).
	     *
	     * This diagram shows how the byte is written:
	     *
	     *  Bit | Pin # | Printer DATA
	     * -----+-------+--------------
	     *   7  |   9   |   DATA 7
	     *   6  |   8   |   DATA 6
	     *   5  |   7   |   DATA 5
	     *   4  |   6   |   DATA 4
	     *   3  |   5   |   DATA 3
	     *   2  |   4   |   DATA 2
	     *   1  |   3   |   DATA 1
	     *   0  |   2   |   DATA 0
	   */
	   public void write (int oneByte)
	   {
	      ParallelPort.writeOneByte (this.portBase, oneByte);
	   }

	   /** Reads one byte from the specified address.
	     * (normally the address is the STATUS pins of the port)
	     */
	   public static native int readOneByte (int address);

	   /** Writes one byte to the specified address
	     * (normally the address is the DATA pins of the port)
	     */
	   public static native void writeOneByte (int address, int oneByte);

	   static
	   {
	      System.loadLibrary("parport");
	   }
	}
And here's the message i got when i try to run it:
#
# An unexpected error has been detected by Java Runtime Environment:
#
#  EXCEPTION_PRIV_INSTRUCTION (0xc0000096) at pc=0x1000107b, pid=2464, tid=896
#
# Java VM: Java HotSpot(TM) Client VM (1.6.0_03-b05 mixed mode)
# Problematic frame:
# C  [parport.dll+0x107b]
#
# An error report file with more information is saved as hs_err_pid2464.log
#
# If you would like to submit a bug report, please visit:
#   http://java.sun.com/webapps/bugreport/crash.jsp
#
Any ideas? I'm using Windows XP Sp2.
In my university i was able to use this algoritm, but there we use Sp1, could be it?
Before someone ask i'm suing UsePort to unlock the Paralell Port.
Thx a lot.
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jul 13 2008
Added on Jun 13 2008
1 comment
1,221 views