Problem z komemdą Port

0

mam niestety problem:

znalazłem kod odczytu procka w Delphi, oto on (sorx za zaśmiecanie):

Cytat:

unit Cputemp1; 

interface 

uses 
SysUtils, WinTypes, WinProcs, Messages, Classes, Graphics, Controls, 
Forms, Dialogs, StdCtrls, ExtCtrls; 

type 
TForm1 = class(TForm) 
Label1: TLabel; 
Timer1: TTimer; 
Label2: TLabel; 
procedure FormCreate(Sender: TObject); 
procedure Timer1Timer(Sender: TObject); 
private 
{ Private declarations } 
public 
cnt: integer; 
{ Public declarations } 
end; 

var 
Form1: TForm1; 

implementation 

{$R *.DFM} 

procedure TForm1.FormCreate(Sender: TObject); 
begin 
Label1.caption := 'T(MB)'+' °C'; 
Label2.caption := 'T(CPU)'+' °C'; 
end; 

procedure TForm1.Timer1Timer(Sender: TObject); 
var 
i: integer ; 
mtm: integer; 
ts: integer; 
tm: integer; 
ct: integer; 
temp: real; 
cond: boolean; 
s: string; 
s1: string; 
begin 
Timer1.Interval := 3000; 
{Read temperature} 
Port[$295] := $27; 
i := port [$296]; 
str(i:2,s); 
Label1.caption := 'T(MB) = '+s+' °C'; 
{ read cpu temp} 
mtm :=10; 
ts:=port[$e800] ; 
tm:=0; 
while (((ts and 1) = 1)and (tm < mtm)) do 
begin 
ts:=port[$e800]; 
tm := tm+1; 
end; 
if (tm >= mtm) then Label2.caption := 'lm78 timeout1'; 
tm:=0; 
if (((ts and $1e) <> 0)and (tm < mtm)) then 
begin 
port[$e800]:=ts; 
tm:=tm+1; 
end; 
if (tm >= mtm) then Label2.caption := 'lm78 timeout2'; 
port[$e803]:=0; 
port[$e804]:=$93; 
ct:=port[$e802]; 
ct:=(ct and $e0)or $c; 
port[$e802]:=ct; 
port[$e802]:=ct or $40; 
tm:=0; 
while (((port[$e800] and 1)= 1) and ( tm < mtm)) do tm:=tm+1; 
if (tm >= mtm) then Label2.caption := 'lm78 timeout3' ; 
temp:= port[$e805] ; 
ts := port[$e806] ; 
ts:= ts shr 7; 
ts := ts and 1; 
temp := temp +8; 
if (ts = 1) then temp:= temp + 0.5; 
str(temp:4:1,s1); 
Label2.caption := 'T(CPU) = '+s1+' °C'; 
end; 
end. 

skopiowałem go do Delphi, zainstalowałem odpowiednie biblioteki, i mam błąd, to znaczy Delphi, nie rozumie co to jest: Port, użyty np. w

port[$e803]:=0; 

czy ktoś zna rozwiązanie

0

Port po prostu w delphi nie ma. Musisz użyć albo wstawki assemblerowej (kręci się gdzieś na forum, mozesz szukać pod hasłem LPT) dla systemów win9x, lub jakiegoś specjalnego sterownika (np. zlportio) dla systemów opartych na NT (na 9x też działają).

0
function PortIn(Port:word):Byte;
var Help:Byte;
begin
 asm
  mov DX   ,Port
  in  AL   ,DX
  mov Help ,AL
 end;
 PortIn:=Help;
end;

procedure PortOut(Port:word;Value:Byte);assembler;
asm
  mov DX,Port
  mov AL,Value
  out DX,AL
end;
procedure TForm1.Timer1Timer(Sender: TObject);
  var
i: integer ;
mtm: integer;
ts: integer;
tm: integer;
ct: integer;
temp: real;
cond: boolean;
s: string;
s1: string;
begin
Timer1.Interval := 3000;
  {Read temperature}
   PortOut($295,$27) ;
   i := portIn($296);
   str(i:2,s);
    Label1.caption := 'T(MB)  = '+s+' °C';
   { read cpu temp}
   mtm :=10;
   ts:=portIn($e800);
   tm:=0;
   while (((ts and 1) = 1)and (tm < mtm)) do
   begin
   ts:=portIn($e800);
   tm := tm+1;
   end;
   if (tm >= mtm) then Label2.caption := 'lm78 timeout1';
   tm:=0;
   if (((ts and $1e) <> 0)and (tm < mtm)) then
   begin
   portOut($e800, ts);
   tm:=tm+1;
   end;
   if (tm >= mtm) then Label2.caption := 'lm78 timeout2';
   portOut($e803, 0);
   portOut($e804, $93);
   ct:=portIn($e802);
   ct:=(ct and $e0)or $c;
   portOut($e802,ct);
   portOut($e802,ct or $40);
   tm:=0;
   while (((portIn($e800) and 1)= 1) and ( tm < mtm)) do tm:=tm+1;
   if (tm >= mtm) then Label2.caption := 'lm78 timeout3' ;
  temp:= portIn($e805);
  ts := portIn($e806);
   ts:= ts shr 7;
   ts := ts and 1;
     temp := temp +8;
   if (ts = 1) then temp:= temp + 0.5;
   str(temp:4:1,s1);
   Label2.caption := 'T(CPU)  = '+s1+' °C';
end;
0

Jedno pytanie: T(CPU) mozna sie domyslic, ze chodzi o temp. procka. A czego temperatura jest T(MB)?? Kostki ramu??

0

<font color="blue">M</span>other<font color="blue">B</span>oard..

1 użytkowników online, w tym zalogowanych: 0, gości: 1