Autor Beitrag
ähM_Key
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 88

Windows XP Professional
D7 Enterprise
BeitragVerfasst: Mo 24.11.03 08:39 
Hi Leute!

Ich möchte gerne, wie im Titel beschrieben, auch mit WinXP die Ports ansteuern können. Mit Win98 habe ich es schon hinbekommen (über Asembler), aber ich habe gehört, dass das bei XP nicht mehr so einfach ist! Gibt es da irgendein Tutorial oder so?
Bitte verweist mich nicht auf die Suchfunktion, denn von der tun mir noch die Finger weh :wink: !

Freue mich auf schnelle Antwort, da ich das möglichst für mein Projekt in der Projektwoche nutzen möcht!

Grüße; ähM_Key

_________________
Alles geht ni! Aber ein bissl' was muss!
ähM_Key Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 88

Windows XP Professional
D7 Enterprise
BeitragVerfasst: Do 27.11.03 20:38 
Hi!

Also in Win98 geht es ja bekannter Weise so:

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
procedure TForm1.PortStatus;
  var z:integer;
      p:byte;
  begin
      p:=0;
    for z:=1 to 8 do
    begin
      p:=p+((PortArray[z])*(round(exp((z-1)*ln(2)))));
    end;
  asm
    mov dx,378h
    mov al,p;
    out dx,al
    end;


OK, ist jetzt nicht ganz allgemein, habs einfach aus meinem Prog...

So, und wenn ich dass jetzt unter WinXP ausführe kommt bei jeder Aktion Die Fehlermeldung: "Priveligierte Anweisung" und an den Ports verändert sich nix! Wenn ich aber die Zeile "out dx,al" lösche (oder halt "//"), dann läugt es soweit unter XP, nur die Ports rühern sich nicht!

Wie bring ich dass zum laufen?

Danke für Antwort; Grüße; ähM_Key

_________________
Alles geht ni! Aber ein bissl' was muss!
ähM_Key Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 88

Windows XP Professional
D7 Enterprise
BeitragVerfasst: Fr 28.11.03 22:09 
Also ich habe noch mal audfühlich recharchiert und bin leider nur zu dem Ergebnis gekommen, dass man irgendeine *.dll einbinden muss! Aber wie schreibt man das dann? Und wo bekommt man die her? Und wo muss die hin?

Wäre echt genial, wenn dieses Problem zu lösen wäre, da es immer schwerer ist Win2k-Rechner zu finden (Schule,...); das muss soch irgendwei gehen!!!!!!!!!!

Grüße; ähM_Key

_________________
Alles geht ni! Aber ein bissl' was muss!
Ex0rzist
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 550

Win XP Prof.
Mandrake 10.0

D6
BeitragVerfasst: Sa 29.11.03 04:13 
Hallo

Die DLL, die du dafür benötigst, findest du hier. Dort gibt es dann auch eine englische Dokumentation.

Die DLL wird dann in z.B. so verwendet (gilt für den Parallelport):
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
procedure PortOut(Port : Word; Data : Byte); stdcall; external 'io.dll';

implementation

{$R *.dfm}

procedure TForm1.Button1Click(Sender: TObject);
begin
   PortOut(888,1); // es wird der erste Datenpin auf HIGH gesetzt
end;

procedure TForm1.Button2Click(Sender: TObject);
begin
   PortOut(888,0); // alle Pins werden auf LOW gesetzt
end;


Wenn du verschiedene Pins ansteuern willst, musst du als zweiten Parameter den entsprechenden Integer wert übergeben.
Maximal 8 Bit sind auf dem Parallelport möglich.
Pin 1 und 3 auf HIGH würde dann so aussehen:
00000101 (Binär) -> 5 (Dezimal) --> PortOut(888,5);

Die 888 gibt die Adresse des Ports an. Die kannst du im Gerätemanager herausfinden. Standardmäßig ist das $378 (Hexadezimal) also 888 im Dezimalsystem.

_________________
If accidentally read, induce vomitting.
ähM_Key Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 88

Windows XP Professional
D7 Enterprise
BeitragVerfasst: Sa 29.11.03 14:40 
Dank dir, wrds gleich probieren, und dann berichten, ob's geklappt hat!

Grüße; ähM_Key

_________________
Alles geht ni! Aber ein bissl' was muss!
Moonbiker
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 37



BeitragVerfasst: Sa 29.11.03 15:57 
So richtig funktionieren tut das leider nicht...

Ich weis leider nicht, wie man die io.dll einbindet, und wenn ich es so mache, wie in dem englischen text beschrieben, klappt es leider nicht, da er die external deklariation nicht versteht...

kannst du bitte einen beispielcode (kompletter als der erste) posten?

vielen dank
Ex0rzist
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 550

Win XP Prof.
Mandrake 10.0

D6
BeitragVerfasst: Sa 29.11.03 16:14 
Mach ich doch glatt. :wink:
ausblenden volle Höhe Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
62:
63:
64:
65:
unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls, ExtCtrls;

type
  TForm1 = class(TForm)
    Button1: TButton;
    Label1: TLabel;
    Button2: TButton;
    Timer1: TTimer;  // (Interval = 1000 ,  Enabled = False)
    Button3: TButton;
    procedure Button1Click(Sender: TObject);
    procedure Button2Click(Sender: TObject);
    procedure Timer1Timer(Sender: TObject);
    procedure Button3Click(Sender: TObject);
  private
    { Private-Deklarationen }
  public
    { Public-Deklarationen }
  end;

var
  Form1: TForm1;
  LEDan: Boolean = False;

procedure PortOut(Port : Word; Data : Byte); stdcall; external 'io.dll';

implementation

{$R *.dfm}

procedure TForm1.Button1Click(Sender: TObject);
begin
   PortOut(888,1);
end;

procedure TForm1.Button2Click(Sender: TObject);
begin
   PortOut(888,0);
end;

procedure TForm1.Timer1Timer(Sender: TObject);
begin
If LEDan then
 begin
  PortOut(888,0);
  LEDan := False;
 end
else
 begin
  PortOut(888,1);
  LEDan := True;
 end;
end;

procedure TForm1.Button3Click(Sender: TObject);
begin
Timer1.Enabled := not Timer1.Enabled;
end;

end.


Button 1 gibt Strom auf den ersten Pin. Button 2 setzt den ersten Pin auf LOW.

Mit Button 3 wird eine Timer gestartet/gestoppt, der jede Sekunde zwischen Zustand HIGH und LOW für den ersten Pin wechselt. Das habe ich mal gemacht, um eine LED zum Blinken zu bekommen.

_________________
If accidentally read, induce vomitting.
Moonbiker
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 37



BeitragVerfasst: Sa 29.11.03 16:41 
dann kommt eine fehlermeldung:

[Fehler] RLINK32: Unsupported 16bit resource in file "..\io.dll"

(für .. steht der komplett richtige pfad)

was mache ich denn falsch, habe alles ais deiner unit kopiert...
Ex0rzist
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 550

Win XP Prof.
Mandrake 10.0

D6
BeitragVerfasst: Sa 29.11.03 17:04 
:shock:

Kommt der Fehler beim Compilieren oder beim Ausführen?
Wenn er beim Compilieren kommt, kannst du ja mal versuchen, die DLL dynamisch zu laden. Vielleicht gehts dann. Wie das geht, findest du hier.

Wenn alles nichts hilft, müsstest du mal versuchen, das Ganze mit einer älteren Delphi-Version zu erstellen. Das ist zwar keine Lösung des Problems, aber bei meinem Delphi6 funktioniert der Code wunderbar.

_________________
If accidentally read, induce vomitting.
catweasel
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 487
Erhaltene Danke: 1

Win 7 64bit
Delphi 7 Second Sedition V7.2
BeitragVerfasst: Mo 12.01.04 20:03 
:cry:

Habe einen ähnlichen Fehler.. :

Ich benutze Win XP Prof. und Delphi 6E

hier mal mein Quelltext .:

ausblenden volle Höhe Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls;


type
  TForm1 = class(TForm)
    Button1: TButton;
    procedure Button1Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

procedure PortOut(Port : Word; Data : Byte);
procedure PortWordOut(Port : Word; Data : Word);
procedure PortDWordOut(Port : Word; Data : DWord);
function PortIn(Port : Word) : Byte;
function PortWordIn(Port : Word) : Word;
function PortDWordIn(Port : Word) : DWord;
procedure SetPortBit(Port : Word; Bit : Byte);
procedure ClrPortBit(Port : Word; Bit : Byte);
procedure NotPortBit(Port : Word; Bit : Byte);
function GetPortBit(Port : Word; Bit : Byte) : WordBool;
function RightPortShift(Port : Word; Val : WordBool) : WordBool;
function LeftPortShift(Port : Word; Val : WordBool) : WordBool;
function IsDriverInstalled : Boolean;

var
  Form1: TForm1;

implementation


procedure PortOut(Port : Word; Data : Byte); external 'io.dll';
procedure PortWordOut(Port : Word; Data : Word); external 'io.dll';
procedure PortDWordOut(Port : Word; Data : DWord); external 'io.dll';
function PortIn(Port : Word) : Byte; external 'io.dll';
function PortWordIn(Port : Word) : Word; external 'io.dll';
function PortDWordIn(Port : Word) : DWord; external 'io.dll';
procedure SetPortBit(Port : Word; Bit : Byte); external 'io.dll';
procedure ClrPortBit(Port : Word; Bit : Byte); external 'io.dll';
procedure NotPortBit(Port : Word; Bit : Byte); external 'io.dll';
function GetPortBit(Port : Word; Bit : Byte) : WordBool; external 'io.dll';
function RightPortShift(Port : Word; Val : WordBool) : WordBool; external 'io.dll';
function LeftPortShift(Port : Word; Val : WordBool) : WordBool; external 'io.dll';
function IsDriverInstalled : Boolean; external 'io.dll';

{$R *.dfm}

procedure TForm1.Button1Click(Sender: TObject);
begin
Portout(888,0);
end;

end.


Man sieht also : ausser

Portout(888,0); wird hier kaum was gemacht.

Aber es passier folgendes...:

Beim ersten Klick auf den Button Bekam ich ne Fehlermeldung..:

"IO.dll system is ready but cannot connect to the driver"

Statt "ready" kann auch "present", "installed" oder "available" gestanden haben. Weiss es nicht mehr so genau. Denn die Fehlermeldung habe ich nur einmal gesehen....

Seit dem führt ein Klick auf den Button zum sofortigen Neustart des Rechners.. *ZAPP* :shock:

Danach hat Windows mächtig Sodbrennnen und erzählt Geschichten von einem Neustart nach einem schwerwiegenden Systemfehler..... :hair:

Hab noch nich so viel Erfahrungen, swohl mit Ports als auch mit dem Einbinden von DLLs, deshalb auch der komplette Quelltext der Unit...

Kann mir einer Sagen was ich falschmache ? :?:
Ich mach ja nix kompliziertes... will ja nur den Port befummeln .. :wink:

Catweasel

_________________
Pommes werden schneller fertig wenn man sie vor dem Frittieren einige Minuten in siedendes Fett legt.
ähM_Key Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 88

Windows XP Professional
D7 Enterprise
BeitragVerfasst: Mo 12.01.04 20:34 
Wenn dir das was hilft, dann lad dir doch einfach unser nun funktionierendes Programm unter www.kleines-helferlein.de.vu runter!

Moonbiker könnte dir sicherlich auch noch Tip's geben!

Grüße; ähM_Key

_________________
Alles geht ni! Aber ein bissl' was muss!
Moonbiker
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 37



BeitragVerfasst: Mo 12.01.04 20:36 
Also ich habe mein Program jetzt problemslos laufen unter XP mit der IO.dll,
vielleicht hilft dir meine Seite:

www.kleines-helferlein.de.vu

(Projekte, Software...)

dort sollte auch ein funktionierender Quelltext sein, allerdings weis ich nicht welche Aktualität... ;-)

Cya
Moonbiker
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 37



BeitragVerfasst: Mo 12.01.04 20:39 
P.s.: Fragen kannst du ins Forum oder GB posten oder einfach ne Kurze Mail