Forum: PC-Programmierung Problem mit LPT unter WinNT,Win200, WinXP


von Fix (Gast)


Lesenswert?

So im Internet habe ich nochmal genauer nachgeschaut.
Ich finde sämtliche Tool dazu wie ich die LPT unter WinNT, Win200 und
WinXP ansprechen kann.
TOOLS:
1)porttalk
2)ParIO-alpha_0.1
3)Tvicport / Tviclpt, Tvichf50
4)inpout32.dll
5)UserPort

Ich weiss jetzt nun nicht was für mich geeignet ist.
Wie gesagt ich benutzte zur Zeit den Treiber "inpout32.dll" mit
Borland Builder C++.
Funktioniert auch.
Ich möchte meine Software so gestallten, dass ich nicht im BIOS immer
nachschauen muss, wie die LPT eingestellt ist.
z.B. EPP, ECP, ECP+EPP, SPP usw.
Was für eine Lösung gibt es da eigentlich?

Ich bin neu in diesem Gebiet. Wenn mir da jemand helfen könnte, wäre
ich sehr dankbar.

von Fix (Gast)


Lesenswert?

Sorry wenn ich nochmal nerve.
Leider komme ich mit meinem Projekt nicht weiter.
Wenn mir dabei jemand helfen kann, das wäre super.

von Fix (Gast)


Lesenswert?

Schade!

von Fix (Gast)


Lesenswert?

Mir geht es eigentlich nur darum, wie ich die Bios Einstellungen (z.B.
EPP, ECP, SPP usw) umgehen kann.
Bei anderen Gräten muss man nicht im Bios die Einstellungen anpassen.
Die Geräte z.B. Drucker funktionieren egal ob WinXP, WinNT usw.

von Jochen Pernsteiner (Gast)


Lesenswert?

Hallo,

>Mir geht es eigentlich nur darum, wie ich die Bios Einstellungen
(z.B.
>EPP, ECP, SPP usw) umgehen kann.

Meines Wissens geht das nicht.

>Die Geräte z.B. Drucker funktionieren egal ob WinXP, WinNT usw.

Würde ich so nicht sagen. Ich hatte mal das Problem, das ein nicht mehr
ganz neuer HP Laserjet nicht lief als im BIOS ECP/EPP eingestellt war.
Unter SPP lief er ganz prima.


Einen ganzen Haufen Infos zum Thema Parallelport kannst Du hier finden,
falls Du die Seite nicht ohnehin schon kennst:
http://www.lvr.com/parport.htm


Jochen

von Jochen Pernsteiner (Gast)


Lesenswert?

Hallo nochmal,

ich habe jetzt gerade nochmal unter www.beyondlogic.org/ecp/ecp.htm
nachgesehen.
Wenn Du im BIOS den ECP-Modus aktivierst, kannst Du die anderen Modi
(SPP,EPP,etc.) über das "Extended Control Register" des ECP wählen.

In der Regel ist ja das auch dieser Modus bei aktuellen PCs im BIOS
eingestellt. Wenn natürlich jemand im BIOS fest auf SPP stellt, geht's
nicht.


Jochen

von Fix (Gast)


Lesenswert?

Vielen dank Jochen!

Das heisst ich muss erst mal nachschauen ob im BIOS ECP eingestellt
ist!?
Oder muss ich da in meiner Software was verändern?
Ich verwende da den Treiber "inpout32.dll". Zu Hause auf meinem
Rechner verhält sich der LPT unter Win2000 irgendwie komisch. Der
Rechner ist allerdings 4 bis 5 Jahre alt.
Wie machen es eigentlich die Gerätehersteller wenn sie einen Treiber
schreiben?

von Jochen Pernsteiner (Gast)


Lesenswert?

>Das heisst ich muss erst mal nachschauen ob im BIOS ECP eingestellt
>ist!?

Sozusagen.

>Oder muss ich da in meiner Software was verändern?

Falls der ECP im BIOS eingestellt ist, kannst Du über das "Extended
Control Register" die Modi per Software wählen.

>Rechner verhält sich der LPT unter Win2000 irgendwie komisch.

Inwiefern komisch?

>Wie machen es eigentlich die Gerätehersteller wenn sie einen Treiber
>schreiben?

Naja, ich habe ein Mikrocontroller-Board mit Programmierdongle für den
Parallelport. Da steht in der Anleitung, daß man ECP 1.9 (und nicht
1.7) im BIOS aktivieren muss, sonst funktioniert das Ding nicht.


Jochen.

von Fix (Gast)


Lesenswert?

Vieln Dank Jochen!

Jetzt ist mir schon einiges klarer geworden.
Gibt es hier im Forum jemand, der auf das ECP Register(Extended Control
Register) unter Win2000 bzw WinNT per Software zugreift?

von Fix (Gast)


Lesenswert?

Hallo Jochen!

>Rechner verhält sich der LPT unter Win2000 irgendwie komisch.

-->Sorry ich meinte WindowsNT4.0. Da schaffe ich es nicht den LPT Port
auf bidirektional zu schalten. Hmm....da weiss ich nicht weiter.

von Fix (Gast)


Lesenswert?

Gibt es hier in diesem Forum der schon einmal unter WinNT bzw. Win2000
den LPT Port erfolgreich angesteuert hat?

von Fix (Gast)


Lesenswert?

Hat jemand schon was damit gemacht?

ECP Software Registers
------------------------------------------------------------------------ 
--------

The table below shows the registers of the Extended Capabilities Port.
The first 3 registers are exactly the same than with the Standard
Parallel Port registers. Note should be taken, however, of the Enable
Bi-Directional Port bit (bit 5 of the Control Port.) This bit reflects
the direction that the ECP port is currently in, and will effect the
FIFO Full and FIFO Empty bits of the ECR Register, which will be
explained later.


Address Port Name Read/Write
Base + 0 Data Port (SPP) Write
ECP Address FIFO (ECP MODE) Read/Write
Base + 1 Status Port (All Modes) Read/Write
Base + 2 Control Port (All Modes) Read/Write
Base + 400h Data FIFO (Parallel Port FIFO Mode) Read/Write
Data FIFO (ECP Mode) Read/Write
Test FIFO (Test Mode) Read/Write
Configuration Register A (Configuration Mode) Read/Write
Base + 401h Configuration Register B (Configuration Mode) Read/Write
Base + 402h Extended Control Register (Used by all modes) Read/Write
Table 2 : ECP Registers

ECP's Extended Control Register (ECR)
------------------------------------------------------------------------ 
--------

The most important register with a Extended Capabilities Parallel Port
is the Extended Control Register (ECR) thus we will target it's
operation first. This register sets up the mode in which the ECP will
run, plus gives status of the ECP's FIFO among other things. You will
find the contents of this register below, in more detail.


Bit Function
7:5 Selects Current Mode of Operation
000 Standard Mode
001 Byte Mode
010 Parallel Port FIFO Mode
011 ECP FIFO Mode
100 EPP Mode
101 Reserved
110 FIFO Test Mode
111 Configuration Mode
4 ECP Interrupt Bit
3 DMA Enable Bit
2 ECP Service Bit
1 FIFO Full
0 FIFO Empty
Table 3 ECR - Extended Control Register

The three MSB of the Extended Control Register selects the mode of
operation. There are 7 possible modes of operation, but not all ports
will support all modes. The EPP mode is one such example, not being
available on some ports. Below is a table of Modes of Operation.



------------------------------------------------------------------------ 
--------
Modes of Operation
------------------------------------------------------------------------ 
--------

Standard Mode Selecting this mode will cause the ECP port to behave as
a Standard Parallel Port, without Bi-directional functionality.
Byte Mode / PS/2 Mode Behaves as a SPP in Bi-directional (Reverse)
mode.
Parallel Port FIFO Mode In this mode, any data written to the Data FIFO
will be sent to the peripheral using the SPP Handshake. The hardware
will generate the handshaking required. Useful with non-ECP devices
such as Printers. You can have some of the features of ECP like FIFO
buffers and hardware generation of handshaking but with the existing
SPP handshake instead of the ECP Handshake.
ECP FIFO Mode Standard Mode for ECP Use. This mode uses the ECP
Handshake, already described.
EPP Mode/Reserved On some chipsets, this mode will enable EPP to be
used. While on others, this mode is still reserved.
Reserved Currently Reserved
FIFO Test Mode While in this mode, any data written to the Test FIFO
Register will be placed into the FIFO and any data read from the Test
FIFO register will be read from the FIFO buffer. The FIFO Full/Empty
Status Bits will reflect their true value, thus FIFO depth, among other
things can be determined in this mode.
Configuration Mode In this mode, the two configuration registers, cnfgA
& cnfgB become available at their designated Register Addresses.

------------------------------------------------------------------------ 
--------



As outlined above, when the port is set to operate in Standard Mode, it
will behave just like a Standard Parallel Port (SPP) with no
bi-directional data transfer. If you require bi-directional transfer,
then set the mode to Byte Mode. The Parallel Port FIFO mode and ECP
FIFO mode both use hardware to generate the necessary handshaking
signals. The only difference between each mode is that The Parallel
Port FIFO Mode uses SPP handshaking, thus can be used with your SPP
printer. ECP FIFO mode uses ECP handshaking.

The FIFO test mode can be used to test the capacity of the FIFO Buffers
as well as to make sure they function correctly. When in FIFO test mode,
any byte which is written to the TEST FIFO (Base + 400h) is placed into
the FIFO buffer and any byte which is read from this register is taken
from the FIFO Buffer. You can use this along with the FIFO Full and
FIFO Empty bits of the Extended Control Register to determine the
capacity of the FIFO Buffer. This should normally be about 16 Bytes
deep.

The other Bits of the ECR also play an important role in the operation
of the ECP Port. The ECP Interrupt Bit, (Bit 4) enables the use of
Interrupts, while the DMA Enable Bit (Bit 3) enables the use of Direct
Memory Access. The ECP Service Bit (Bit 2) shows if an interrupt
request has been initiated. If so, this bit will be set. Resetting this
bit is different with different chips. Some require you to Reset the
Bit, E.g. Write a Zero to it. Others will reset once the Register has
been read.

The FIFO Full (Bit 1) and FIFO Empty (Bit 0) show the status of the
FIFO Buffer. These bits are direction dependent, thus note should be
taken of the Control Register's Bit 5. If bit 0 (FIFO Empty) is set,
then the FIFO buffer is completely empty. If Bit 1 is set then the FIFO
buffer is Full. Thus, if neither bit 0 or 1 is set, then there is data
in FIFO, but is not yet full. These bits can be used in FIFO Test Mode,
to determine the capacity of the FIFO Buffer.


ECP's Configuration Register A (cnfgA)
------------------------------------------------------------------------ 
--------

Configuration Register A is one of two configuration registers which
the ECP Port has. These Configuration Registers are only accessible
when the ECP Port is in Configuration Mode. (See Extended Control
Register) CnfgA can be accessed at Base + 400h.


Bit Function
7 1 Interrupts are level triggered
0 Interrupts are edge triggered (Pulses)
6:4 00h Accepts Max. 16 Bit wide words
01h Accepts Max. 8 Bit wide words
02h Accepts Max. 32 Bit wide words
03h:07h Reserved for future expansion
3 Reserved
2 Host Recovery : Pipeline/Transmitter Byte included in FIFO?
0 In forward direction, the 1 byte in the transmitter pipeline doesn't
affect FIFO Full.
1 In forward direction, the 1 byte in the transmitter pipeline is
include as part of FIFO Full.
1:0 Host Recovery : Unsent byte(s) left in FIFO
00 Complete Pword
01 1 Valid Byte
10 2 Valid Bytes
11 3 Valid Bytes
Table 4 - Configuration Register A

Configuration Register A can be read to find out a little more about
the ECP Port. The MSB, shows if the card generates level interrupts or
edge triggered interrupts. This will depend upon the type of bus your
card is using. Bits 4 to 6, show the buses width within the card. Some
cards only have a 8 bit data path, while others may have a 32 or 16 bit
width. To get maximum efficiency from your card, the software can read
the status of these bits to determine the Maximum Word Size to output
to the port.

The 3 LSB's are used for Host Recovery. In order to recover from an
error, the software must know how many bytes were sent, by determining
if there are any bytes left in the FIFO. Some implementations may
include the byte sitting in the transmitter register, waiting to be
sent as part of the FIFO's Full Status, while others may not. Bit 2
determines weather or not this is the case.

The other problem is that the Parallel Ports output is only 8 bits
wide, and that you many be using 16 bit or 32 bit I/O Instructions. If
this is the case, then part of your Port Word (Word you sent to port)
may be sent. Therefore Bits 0 and 1 give an indication of the number of
valid bytes still left in the FIFO, so that you can retransmit these.

ECP's Configuration Register B (cnfgB)
------------------------------------------------------------------------ 
--------

Configuration Register B, like Configuration Register A is only
available when the ECP Port is in Configuration Mode. When in this
mode, cnfgB resides at Base + 401h. Below is the make-up of the cnfgB
Register.


Bit(s) Function
7 1 Compress outgoing Data Using RLE
0 Do Not compress Data
6 Interrupt Status - Shows the Current Status of the IRQ Pin
5:3 Selects or Displays Status of Interrupt Request Line.
000 Interrupt Selected Via Jumper
001 IRQ 7
010 IRQ 9
011 IRQ 10
100 IRQ 11
101 IRQ 14
110 IRQ 15
111 IRQ 5
2:0 Selects or Displays Status of the DMA Channel the Printer Card Uses

000 Uses a Jumpered 8 Bit DMA Channel
001 DMA Channel 1
010 DMA Channel 2
011 DMA Channel 3
100 Uses a Jumpered 16 Bit DMA Channel
101 DMA Channel 5
110 DMA Channel 6
111 DMA Channel 7
Table 5 - Configuration B Register

The Configuration Register B (cnfgB) can be a combination of read/write
access. Some ports may be software configurable, where you can set the
IRQ and DMA resources from the register. Others may be set via BIOS or
by using jumpers on the Card, thus are read only.

Bit 7 of the cnfgB Register selects whether to compress outgoing data
using RLE (Run Length Encoding.) When Set, the host will compress the
data before sending. When reset, data will be sent to the peripheral
raw (Uncompressed). Bit 6 returns the status of the IRQ pin. This can
be used to diagnose conflicts as it will not only reflect the status of
the Parallel Ports IRQ, but and other device using this IRQ.

Bits 5 to 3 give status of about the Port's IRQ assignment. Likewise
for bits 2 to 0 which give status of DMA Channel assignment. As
mentioned above these fields may be read/write. The disappearing
species of Parallel Cards which have Jumpers may simply show it's
resources as "Jumpered" or it may show the correct Line Numbers.
However these of course will be read only.

von Jochen Pernsteiner (Gast)


Lesenswert?

Wieso postest Du das alles hier?
Hätte nicht ein Link genügt?

von Fix (Gast)


Lesenswert?

Hallo!

Sorry, das war wirklich keine Absicht.
Ich will nur wissen, wer schon mal mit dem "Extended Control Register
(ECR)" was gemacht hat im zusammenhang mit der DLL "inpout32.dll"

von Jochen Pernsteiner (Gast)


Lesenswert?

Was genau willst Du eigentlich wissen?
Du musst schon konkrete Fragen stellen um konkrete Antworten zu
bekommen.

Hast Du schon was programmiert mit der DLL?
Geht dabei irgendwas nicht? Dann poste den Code!

Mir ist nicht ganz klar, was mit diesem Register so schwierig sein
soll. Du kannst es lesen und beschreiben. Was gibt es da groß zu
verstehen?

Die ganzen Register des ECP sind doch auf
www.beyondlogic.org/ecp/ecp.htm haarklein erklärt.
Was willst Du mehr?


Jochen

von Fix (Gast)


Lesenswert?

Ich habe die Erfahrung gemacht, dass die DLL nicht bei allen PCS bzw.
Laptops funktioniert. Egal ob ich ECP bzw. EPP im Bioas eingestellt
habe, kann es sein dass ich nicht von der LPT lesen kann. Deshalb
wollte ich eigentlich nur wissen ob jemand das ECP Register für die
Ansteuerung der LPT unter WIn2000 bzw. WinNT benutzt hat bzw.
Erafahrungen gesammelt hat.

von Jochen Pernsteiner (Gast)


Lesenswert?

>Ich habe die Erfahrung gemacht, dass die DLL nicht bei allen PCS bzw.
>Laptops funktioniert. Egal ob ich ECP bzw. EPP im Bioas eingestellt
>habe, kann es sein dass ich nicht von der LPT lesen kann.

Bei wie vielen PCs und Laptops hast Du es denn probiert?
Bei welchen ging es nicht?
Und was genau geht dann nicht?
Was für Code hast Du benutzt?
Hast Du die Rückgabeparameter der aufgerufenen Funktionen überprüft?
Vielleicht war der Treiber (hwinterface.sys) nicht korrekt
installiert?


Jochen

von Fix (Gast)


Lesenswert?

Hallo Jochen!
Und zwar beim Laptop Toshiba(Win2000) funktionierte es nicht.
Was meinst du mit Treiber (hwinterface.sys) wurde nicht korrekt
installiert? Ich verwende nur die fertige DLL "inpout32.dll"
Auf die Datei "hwinterface.sys" greife ich unter Borland Builder
überhaupt nicht zu.

von Fix (Gast)


Angehängte Dateien:

Lesenswert?

Ich habnoch was vergessen zu Fragen.
Und zwar in der Datei "inpout32drv.cpp" siehe Anhang sind zwei
Funktionen aufgeführt:
-int Opendriver(void);
-void Closedriver(void);

Muss ich diese Funktionen in meinem Hauptprogramm auch benutzen?

von Olaf Stieleke (Gast)


Lesenswert?

Da du dich so gar nicht mit der Materie beschäftigt hast, einmal kurz
umrissen:

Unter WinNT, 2K und XP dürfen Anwendungen NICHT direkt auf Ports
zugreifen.

Aber: Device-Treiber dürfen das. Devicetreiber sind die Dinger mit der
Extension .SYS dran.

Daraus folgt: Natürlich brauchst du den hwinterface.sys-Treiber, denn
DER macht die Portzugriffe.

Das nächste Problem: Das Ansprechen von Device-Treibern ist ein echter
Horror und nichts für den Gelegenheits-Coder. Also bastelt man eine
DLL, damit der Programmierer ein leichteres Leben hat.

Du als Programmierer redest mit der DLL, die redet mit dem *.SYS, der
wiederum redet mit den Ports. Unter Garantie ist dieser Sachverhalt
irgendwo vermerkt (Website des Autors, README.TXT etc).

Mehr muß zu dem Thema nicht gesagt werden.

von Jochen Pernsteiner (Gast)


Lesenswert?

>Auf die Datei "hwinterface.sys" greife ich unter Borland Builder
>überhaupt nicht zu.

Musst Du auch nicht, das macht die DLL im Hintergrund. Laut DLL-Doku
wird der Treiber installiert und geladen, falls er noch nicht vorhanden
ist.

Es könnte ja sein, daß es hier Probleme gibt, d.h. das die Treiberdatei
nicht installiert werden kann oder es sonstwie Probleme beim Zugriff
gibt.

Die Sourcen werden ja mitgeliefert, du kannst sie ja verändern und an
den entsprechenden Stellen Debug-Ausgaben einbauen.

Oder benutze halt mal Filemon (www.sysinternals.com) um zu sehen was
passiert wenn Du auf die DLL zugreifst.


>Und zwar beim Laptop Toshiba(Win2000) funktionierte es nicht.

Du hast immer noch nicht gesagt WAS GENAU nicht funktioniert.
Kannst Du die DLL nicht laden? Stürzt der Rechner ab? Oder was?


Jochen

von Fix (Gast)


Lesenswert?

Hi Olaf!

Ah...so jetzt kommen wir dem Probel schon näher. Ok die DLL kann ich
ohne Probleme benutzen. In der Doku steht nichts drin wo ich die Datei
"hwinterface.sys-Treiber" hinkopieren muss. Zudem weiss ich auch
nicht wie ich dann z.B. die Funktion OpenDriver() in mein Programm
einbinden kann. Wie müsste ich da vorgehen?

von Fix (Gast)


Lesenswert?

Die DLL befindet sich in dem Verzeichniss wo ich auch meine Software
starte.

von Fix (Gast)


Angehängte Dateien:

Lesenswert?

Mit Filemon habe ich die Aktivitäten von meinem Programm mitgeloggt.
Siehe Anhang

von Rufus T. Firefly (Gast)


Lesenswert?

Anscheinend gibt es verschiedene Varianten dieser DLL inpout32.dll.

Die Variante, die man bei Jan Axelson 'runterladen kann
(http://www.lvr.com/parport.htm#Programming) enthält den Devicetreiber
in eingebetter Form (als Bestandteil der Resourcen):

  "Inpout32.dll is compatible with my Win9x inpout32.dll (below)
  but works under all Windows editions from Win95/98/Me to
  WinNT/2000/XP. For Windows NT etc., a kernel mode device
  driver is embedded in the DLL in binary form. Freeware.
  A big thank you to LOGIX4U for coming up with this and making
  it available.
  Download just the DLL(1) or the DLL with source code(2).
  For testing inpout32.dll in Visual Basic 6, see my
  example program Test_inpout32_vb6.zip(3)."

Links
  1) http://www.lvr.com/files/inpout32.dll
  2) http://www.lvr.com/files/pport_source.zip
  3) http://www.lvr.com/files/test_inpout32_vb6.zip

Im Archiv pport_source.zip steht ein nicht ganz unbedeutender Hinweis

  "You must have administrator level privilage to run this software"

Das ist auch verständlich; das dynamische Installieren eines
Devicetreibers erfordert nun mal Administratorrechte.

Im Archiv ist ein C++-Testprogramm, das zeigt, wie ohne DLL direkt mit
dem installierten Devicetreiber kommuniziert werden kann.
Wie man mit der DLL kommuniziert, zeigt ein VB-Testprogramm.

von Fix (Gast)


Lesenswert?

Hallo Rufus!

Danke für die Info!

Das alles verwirrt mich jetzt total. Gibt es dazu ein C Programm.
Ich kenne mich mit VB nicht aus.

von Rufus T. Firefly (Gast)


Lesenswert?

Laut der Kommentare auf http://www.lvr.com/parport.htm#Programming ist
die "neue" Inpout32.dll kompatibel zur alten, Windebil95-Version.

Daher sollten die Hinweise unter http://www.lvr.com/jansfaq.htm auch
zutreffen: "Instructions for using inpout32 with C++ are in Jan's
FAQ."

Naja, die sind nicht wirklich klasse.

Aber das hier http://www.hytherion.com/beattidp/comput/pport/test.c
dürfte Dir weiterhelfen.

von Fix (Gast)


Lesenswert?

Dieses beispiel test.c kenne ich schon. Diesen Code verwende ich in
meinem Programm. Schreiben und lesen funktioniert.
Nur was ich noch wissen will. Kann bzw. Muss ich noch zusätzlich die
Funktionen OpenDriver() und CloseDriver() verwenden?

von Rufus T. Firefly (Gast)


Lesenswert?

Die DLL exportiert exakt zwei Funktionen:

c:\>dumpbin /exports inpout32.dll
Microsoft (R) COFF Binary File Dumper Version 6.00.8447
Copyright (C) Microsoft Corp 1992-1998. All rights reserved.


Dump of file inpout32.dll

File Type: DLL

  Section contains the following exports for INPOUT32.dll

           0 characteristics
    3E4FB78A time date stamp Sun Feb 16 17:08:42 2003
        0.00 version
           1 ordinal base
           2 number of functions
           2 number of names

    ordinal hint RVA      name

          1    0 0000100F Inp32
          2    1 00001019 Out32

  Summary

        7000 .data
        1000 .idata
        3000 .rdata
        2000 .reloc
        2000 .rsrc
       2B000 .text

Daher weiß ich nicht, wo Du diese Funktionen OpenDriver/CloseDriver
gefunden hast.

von Fix (Gast)


Angehängte Dateien:

Lesenswert?

In dieser Datei gibt es die Funktionen OpenDriver und CloseDriver.
Wohin muss ich eigentlich die "hwinterface.sys" kopeiren?

von Rufus T. Firefly (Gast)


Lesenswert?

Die Datei hwtest.cpp zeigt nicht, wie mit der DLL zu kommunizieren
ist, sondern den sehr viel umständlicheren Weg der Kommunikation mit
dem Devicetreiber.
Genau den nimmt Dir die DLL ab.

Das Kopieren des Devicetreibers (hwinterface.sys) irgendwohin bewirkt
überhaupt nichts; damit ein Devicetreiber verwendet werden kann, muss
der installiert werden, was eine recht aufwendige Prozedur ist.
(Funktion inst() in inpout32drv.cpp)

Auch diesen Vorgang nimmt Dir die DLL ab.
Als besonderes Schmankerl wird  der Treiber auch noch dynamisch aus
einer in der DLL enthaltenen Resource extrahiert, so daß Du Dir weder
um die Datei noch um die Installation des Treibers Gedanken machen
musst.

Also:
Du benötigst NUR die DLL und musst NUR die darin enthaltenen Funktionen
Inp32 und Out32 verwenden. Mehr nicht.

von Fix (Gast)


Lesenswert?

Ok jetzt weis ich bescheid. Vielen Dank!

von Fix (Gast)


Lesenswert?

Im Internet habe ich ein kleines Programm gefunden für die Ansteuerung
eines Displays T6963 an die LPT.

Ich verstehe nicht, warum hier "PortReadB(printerport+$402);"
verwendet wird. Was genau soll das bezwecken?

procedure TForm1.WaitDispRdy;
// Warten, bis das Display bereit ist
var tmp: byte;
    t: TDateTime;

begin
  if BiDirLPT THEN begin
    // LPT im ECP-Control-Register auf PS/2-Mode setzen
    // nötig, falls es ein ECP-Port ist
    tmp:=PortReadB(printerport+$402);
    tmp:=tmp AND $1F;
    tmp:=tmp OR $20; // Bidirektionaler Modus = PS/2
    PortWriteB(printerport+$402,tmp);
    t:=now+(5/86400);  // Begrenzt auf 5 Sekunden
    repeat
      // Auf Eingang schalten und abfragen
      PortWriteB(printerport+2,$20+4+2); //In, CD=1, CS=0, Wr=1
      PortWriteB(printerport+2,$20+4+2+8); //In, CD=1, CS=0, Wr=1,
Rd=0
      tmp:=PortReadB(printerport);
      PortWriteB(printerport+2,$20+4+2); //In, CD=1, CS=0, Wr=1
    until ((tmp AND 3)=3) OR (now>t); // Maximal 5 Sekunden warten
    PortWriteB(printerport+2,0);
  end else
    Delay(1); // Ohne bidirektionalen Parallelport ist Handshaking
nicht möglich
end;

von Rufus T. Firefly (Gast)


Lesenswert?

Du hast selbst in diesem Thread gepostet, was der Offset 0x402 für die
Programmierung der Druckerschnittstelle bedeutet

http://www.mikrocontroller.net/forum/read-8-150864.html#152778

Base + 402h Extended Control Register (Used by all modes) Read/Write

Also wird in Deinem Code eben jenes Extended Control Register
verwendet.

Zunächst wird der aktuelle Wert ausgelesen, dann werden Bits 7..5
gelöscht und dann wird Bit 5 gesetzt.

Siehe auch

  Bit Function
  7:5 Selects Current Mode of Operation
  000 Standard Mode
* 001 Byte Mode
  010 Parallel Port FIFO Mode

  Table 3 ECR - Extended Control Register

in Deinem Posting.

Also wird hier der "Byte Mode" eingestellt.

von Fix (Gast)


Lesenswert?

Das verstehe ich jetzt nicht.
Es wird zuerst der Wert gelesen und mit 0x1F (xxx11111)vernüpft.
Anschließend mit 0x20 verodert(xxx11111 oder xx10000 = 00111111).
Dann wird doch dieser wert geschrieben 00111111. Ist das richtig?

Trotzdem verstehe ich nicht ganz genau, warum das Register ECR
verwendet wird. Welchen Zweck erfüllt dieser Code eigentlich?

von Tobi (Gast)


Lesenswert?

"Ist das richtig?"

deine nullen und einsen sind etwas konfus angeordnet. und und oder
verknüpfung bewirken nicht das von dir angegebene

irgendwo oben war so ein sehr schöner link zur beyondlogic seite, sehr
informativ...

von Fix (Gast)


Lesenswert?

Im Code steht nur :
// LPT im ECP-Control-Register auf PS/2-Mode setzen
// nötig, falls es ein ECP-Port ist

Woher weiss ich welchen LPT Port ich habe? Im BIOS?
Wozu dient dieser Code?

von Fix (Gast)


Lesenswert?

Das mit der Verknüpfung hat sich erledigt. Ich habs begriffen. Danke.

Ich möchte nur noch wissen, wofür der Code überhaupt gebarucht wird.

von Rufus T. Firefly (Gast)


Lesenswert?

"Es wird zuerst der Wert gelesen und mit 0x1F (xxx11111)vernüpft.
Anschließend mit 0x20 verodert(xxx11111 oder xx10000 = 00111111).
Dann wird doch dieser wert geschrieben 00111111. Ist das richtig?"

Nein. Ist es nicht.


Wert lesen:

  hgfedcba

Mit 0x1F AND-Verknüpfen

  000edcba

mit 0x20 OR-Verknüpfen

  001edcba

Damit werden die Bits edcba (also Bit5..0) nicht verändert.

Mit diesem Zugriff auf das ECR wird der Byte Mode eingestellt. Andere
einstellbare Modi sind in der von Dir zitierten Tabelle 3 beschrieben.

Und was die bedeuten, ist ebenfalls im von Dir zitierten Dokument
beschrieben. Vielleicht etwas schwer zu finden, weil bei Deinem Posting
die Formatierung draufging.

-------------------
Modes of Operation
-------------------

Standard Mode
  Selecting this mode will cause the ECP port to behave as
  a Standard Parallel Port, without Bi-directional functionality.

Byte Mode / PS/2 Mode
  Behaves as a SPP in Bi-directional (Reverse) mode.

Parallel Port FIFO Mode
  In this mode, any data written to the Data FIFO
  will be sent to the peripheral using the SPP Handshake.
  The hardware will generate the handshaking required.
  Useful with non-ECP devices such as Printers.
  You can have some of the features of ECP like FIFO
  buffers and hardware generation of handshaking but with
  the existing SPP handshake instead of the ECP Handshake.

etc.

von Fix (Gast)


Lesenswert?

Hi Rufus.

Danke erstmal für die Unterstützung.

Und zwar Byte Mode bedeutet wenn ich SPP eingestellt habe dass ich
trotzdem Daten über die LPT empfangen kann.
Oder?

Bitte melde dich an um einen Beitrag zu schreiben. Anmeldung ist kostenlos und dauert nur eine Minute.
Bestehender Account
Schon ein Account bei Google/GoogleMail? Keine Anmeldung erforderlich!
Mit Google-Account einloggen
Noch kein Account? Hier anmelden.