⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 class parallelport.mht

📁 Project for interfacing Parallel port of the PC through JAVA application.
💻 MHT
字号:
From: <Saved by Microsoft Internet Explorer 5>
Subject: Class ParallelPort
Date: Sun, 22 Apr 2007 01:44:00 +0500
MIME-Version: 1.0
Content-Type: text/html;
	charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
Content-Location: file://C:\Documents and Settings\(Admin) Yasir\Desktop\Related Study\parport\ParallelPort.html
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2180

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD><TITLE>Class ParallelPort</TITLE>
<META http-equiv=3DContent-Type content=3D"text/html; =
charset=3Dwindows-1252">
<META content=3D"MSHTML 6.00.2900.2180" name=3DGENERATOR></HEAD>
<BODY bgColor=3Dwhite>
<TABLE cellSpacing=3D0 cellPadding=3D3 width=3D"100%" border=3D1>
  <TBODY>
  <TR class=3DTableHeadingColor bgColor=3D#ccccff>
    <TD><FONT size=3D+2>
      <CENTER><B>parport.ParallelPort=20
  Documentation</B></FONT></CENTER></TD></TR></TBODY></TABLE>
<HR>
<!-- =3D=3D=3D=3D=3D=3D=3D=3D START OF CLASS DATA =
=3D=3D=3D=3D=3D=3D=3D=3D -->
<H2><FONT size=3D-1>parport</FONT><BR>Class =
ParallelPort</H2><PRE>java.lang.Object
  |
  +--<B>ParallelPort</B>
</PRE>
<HR>

<DL>
  <DT>public class <B>ParallelPort</B>
  <DT>extends java.lang.Object</DT></DL>Read and write bytes through =
parallel=20
printer ports. For example:<BR><PRE>  import parport.ParallelPort;

  class SimpleIO {
    public static void main ( String []args )
    {
      ParallelPort lpt1 =3D new ParallelPort(0x378); // 0x378 is =
normally the base address for the LPT1 port
      int aByte;
      aByte =3D lpt1.read(); // read a byte from the port's STATUS pins
      System.out.println("Input from parallel port: " + aByte);
      aByte =3D aByte &gt;&gt; 2; // a simple and irrelevant operation
      lpt1.write(aByte); // write a byte to the port's DATA pins
      System.out.println("Output to port: " + aByte);
    }
  }</PRE>This class defines two native methods that are implemented in =
Visual=20
C++ 6.0 for Windows, therefore this class works only on Windows systems =
(if you=20
would be interested in a linux version send me an <A=20
href=3D"mailto:jdelcid@galileo.edu">email</A>, and I'll get to work on =
it). Read=20
the <A=20
href=3D"file:///C:/Documents%20and%20Settings/(Admin)%20Yasir/Desktop/Rel=
ated%20Study/parport/install.html">installation=20
instructions.</A>=20
<P>
<DL>
  <DT><B>See Also:</B>=20
  <DD><A =
href=3D"http://java.sun.com/docs/books/tutorial/native1.1/TOC.html">Java =

  Native Interface</A>, <A=20
  href=3D"http://www.beyondlogic.org/spp/parallel.htm">Interfacing the =
Parallel=20
  Port</A> </DD></DL>
<HR>

<P><!-- =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D FIELD SUMMARY =
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D -->
<TABLE cellSpacing=3D0 cellPadding=3D3 width=3D"100%" border=3D1>
  <TBODY>
  <TR class=3DTableHeadingColor bgColor=3D#ccccff>
    <TD colSpan=3D2><FONT size=3D+2><B>Field =
Summary</B></FONT></TD></TR>
  <TR class=3DTableRowColor bgColor=3Dwhite>
    <TD vAlign=3Dtop align=3Dright width=3D"1%"><FONT=20
      size=3D-1><CODE>&nbsp;int</CODE></FONT></TD>
    <TD><CODE><A=20
      =
href=3D"file:///C:/Documents%20and%20Settings/(Admin)%20Yasir/Desktop/Rel=
ated%20Study/parport/ParallelPort.html#portBase"><B>portBase</B></A></COD=
E>=20
      =
<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;The=20
      parallel port's base address</TD></TR></TBODY></TABLE>&nbsp; <!-- =
=3D=3D=3D=3D=3D=3D=3D=3D CONSTRUCTOR SUMMARY =3D=3D=3D=3D=3D=3D=3D=3D =
--><A name=3Dconstructor_summary><!-- --></A>
<TABLE cellSpacing=3D0 cellPadding=3D3 width=3D"100%" border=3D1>
  <TBODY>
  <TR class=3DTableHeadingColor bgColor=3D#ccccff>
    <TD colSpan=3D2><FONT size=3D+2><B>Constructor =
Summary</B></FONT></TD></TR>
  <TR class=3DTableRowColor bgColor=3Dwhite>
    <TD><CODE><B><A=20
      =
href=3D"file:///C:/Documents%20and%20Settings/(Admin)%20Yasir/Desktop/Rel=
ated%20Study/parport/ParallelPort.html#ParallelPort(int)">ParallelPort</A=
></B>(int&nbsp;portBase)</CODE>=20
      =
<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Create =
an=20
      interface to a parallel port using its base=20
address</TD></TR></TBODY></TABLE>&nbsp; <!-- =
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D METHOD SUMMARY =
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --><A=20
name=3Dmethod_summary><!-- --></A>
<TABLE cellSpacing=3D0 cellPadding=3D3 width=3D"100%" border=3D1>
  <TBODY>
  <TR class=3DTableHeadingColor bgColor=3D#ccccff>
    <TD colSpan=3D2><FONT size=3D+2><B>Method =
Summary</B></FONT></TD></TR>
  <TR class=3DTableRowColor bgColor=3Dwhite>
    <TD vAlign=3Dtop align=3Dright width=3D"1%"><FONT=20
      size=3D-1><CODE>&nbsp;int</CODE></FONT></TD>
    <TD><CODE><B><A=20
      =
href=3D"file:///C:/Documents%20and%20Settings/(Admin)%20Yasir/Desktop/Rel=
ated%20Study/parport/ParallelPort.html#read()">read</A></B>()</CODE>=20
      =
<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Read one =

      byte from the STATUS pins of this parallel port object. </TD></TR>
  <TR class=3DTableRowColor bgColor=3Dwhite>
    <TD vAlign=3Dtop align=3Dright width=3D"1%"><FONT=20
      size=3D-1><CODE>static&nbsp;int</CODE></FONT></TD>
    <TD><CODE><B><A=20
      =
href=3D"file:///C:/Documents%20and%20Settings/(Admin)%20Yasir/Desktop/Rel=
ated%20Study/parport/ParallelPort.html#readOneByte(int)">readOneByte</A><=
/B>(int=20
      address)</CODE>=20
      =
<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Reads =
one=20
      byte from the specified address. </TD></TR>
  <TR class=3DTableRowColor bgColor=3Dwhite>
    <TD vAlign=3Dtop align=3Dright width=3D"1%"><FONT=20
      size=3D-1><CODE>&nbsp;void</CODE></FONT></TD>
    <TD><CODE><B><A=20
      =
href=3D"file:///C:/Documents%20and%20Settings/(Admin)%20Yasir/Desktop/Rel=
ated%20Study/parport/ParallelPort.html#write(int)">write</A></B>(int=20
      oneByte)</CODE>=20
      <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; =
Write one=20
      byte to the DATA pins of this parallel port object. </TD></TR>
  <TR class=3DTableRowColor bgColor=3Dwhite>
    <TD vAlign=3Dtop align=3Dright width=3D"1%"><FONT=20
      size=3D-1><CODE>static&nbsp;void</CODE></FONT></TD>
    <TD><CODE><B><A=20
      =
href=3D"file:///C:/Documents%20and%20Settings/(Admin)%20Yasir/Desktop/Rel=
ated%20Study/parport/ParallelPort.html#writeOneByte(int, =
int)">writeOneByte</A></B>(int=20
      address, int oneByte)</CODE>=20
      =
<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Writes =
one=20
      byte to the specified address. </TD></TR></TBODY></TABLE>
<P><!-- =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D FIELD DETAIL =
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D -->
<TABLE cellSpacing=3D0 cellPadding=3D3 width=3D"100%" border=3D1>
  <TBODY>
  <TR class=3DTableHeadingColor bgColor=3D#ccccff>
    <TD><FONT size=3D+2><B>Field =
Detail</B></FONT></TD></TR></TBODY></TABLE><A=20
name=3DportBase><!-- --></A>
<H3>portBase</H3><PRE>private int <B>portBase</B></PRE>
<DL>
  <DD>The parallel port's <A=20
  href=3D"http://www.beyondlogic.org/spp/parallel.htm#4">base =
address</A> </DD></DL><!-- =3D=3D=3D=3D=3D=3D=3D=3D=3D CONSTRUCTOR =
DETAIL =3D=3D=3D=3D=3D=3D=3D=3D --><A=20
name=3Dconstructor_detail><!-- --></A>
<TABLE cellSpacing=3D0 cellPadding=3D3 width=3D"100%" border=3D1>
  <TBODY>
  <TR class=3DTableHeadingColor bgColor=3D#ccccff>
    <TD><FONT size=3D+2><B>Constructor =
Detail</B></FONT></TD></TR></TBODY></TABLE><A=20
name=3DParallelPort(int)><!-- --></A>
<H3>ParallelPort</H3><PRE>public =
<B>ParallelPort</B>(int&nbsp;portBase)</PRE>
<DL>
  <DD>Create an interface to a parallel port using its <A=20
  =
href=3D"file:///C:/Documents%20and%20Settings/(Admin)%20Yasir/Desktop/Rel=
ated%20Study/parport/ParallelPort.html#portBase">base=20
  address</A>=20
  <P></P>
  <DD>
  <DL>
    <DT><B>Parameters:</B>=20
    <DD>portBase - The parallel port's base address. =
</DD></DL></DD></DL><!-- =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D METHOD =
DETAIL =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --><A=20
name=3Dmethod_detail><!-- --></A>
<TABLE cellSpacing=3D0 cellPadding=3D3 width=3D"100%" border=3D1>
  <TBODY>
  <TR class=3DTableHeadingColor bgColor=3D#ccccff>
    <TD><FONT size=3D+2><B>Method =
Detail</B></FONT></TD></TR></TBODY></TABLE><A=20
name=3Dread()><!-- --></A>
<H3>read</H3><PRE>public int <B>read</B>()</PRE>
<DL>
  <DD>Read one byte from the <A=20
  href=3D"http://www.beyondlogic.org/spp/parallel.htm#5">STATUS</A> =
address of a=20
  parallel port. The byte read contains 5 valid bits, corresponding to 5 =
pins of=20
  input from the STATUS pins of the parallel port (the STATUS is located =
at=20
  "portBase + 1", e.g. the STATUS address for LPT1 is =
0x379).<BR><BR>This=20
  diagram shows the content of the byte: <PRE>        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       |
</PRE>Note that Pin 11 is inverted, this means that "Hi" input on =
pin<BR>means=20
  0 on bit 7, "Low" input on pin means 1 on bit 7.
  <P></P>
  <DD>
  <DL>
    <DT><B>Returns:</B>=20
    <DD>The byte read from the STATUS pins of the port. =
</DD></DL></DD></DL>
<HR>
<A name=3Dwrite(int)><!-- --></A>
<H3>write</H3><PRE>public void <B>write</B>(int oneByte)</PRE>
<DL>
  <DD>Write one byte to the <A=20
  href=3D"http://www.beyondlogic.org/spp/parallel.htm#5">DATA</A> =
address of a=20
  parallel port. The byte is written to the DATA pins of the port. The =
DATA pins=20
  are located at the base address of the port (e.g. DATA address for =
LPT1 is=20
  0x378).<BR><BR>This diagram shows how the byte is written: <PRE>       =
  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
</PRE>
  <DD>
  <DL>
    <DT><B>Parameters:</B>=20
    <DD>oneByte - the byte to write to the DATA pins. =
</DD></DL></DD></DL>
<HR>
<A name=3DreadOneByte(int)><!-- --></A>
<H3>readOneByte</H3><PRE>public static int <B>readOneByte</B>(int =
address)</PRE>
<DL>
  <DD>Reads one byte from any address on your PC's I/O memory=20
  <DD>
  <DL>
    <DT><B>Parameters:</B>=20
    <DD>address - the address to read from. Normally it is the STATUS =
address of=20
    a parallel port.=20
    <DT><B>Returns:</B>=20
    <DD>The byte read from the specified address. </DD></DL></DD></DL>
<HR>
<A name=3D"writeOneByte(int, int)"><!-- --></A>
<H3>writeOneByte</H3><PRE>public static void <B>writeOneByte</B>(int =
address,
                                int oneByte)</PRE>
<DL>
  <DD>Writes one byte to any address on your PC's I/O memory=20
  <DD>
  <DL>
    <DT><B>Parameters:</B>=20
    <DD>address - The address to write at. Normally it is the DATA =
address of a=20
    parallel port.=20
    <DD>oneByte - The byte to write. </DD></DL></DD></DL>&nbsp; <!-- =
=3D=3D=3D=3D=3D=3D=3D=3D=3D END OF CLASS DATA =
=3D=3D=3D=3D=3D=3D=3D=3D=3D -->
<HR>
<FONT size=3D-1><A href=3D"mailto:jdelcid@galileo.edu">Submit a bug or =
feature</A> -=20
Version 1.4.1 of Java Platform API Specification<BR>This software is =
distributed=20
"as is". It is Freeware. Any use of this software is by the users own=20
risk.</FONT> </BODY></HTML>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -