Delphi-PRAXiS
Seite 1 von 3  1 23      

Delphi-PRAXiS (https://www.delphipraxis.net/forum.php)
-   Win32/Win64 API (native code) (https://www.delphipraxis.net/17-win32-win64-api-native-code/)
-   -   Delphi Comparing functions (https://www.delphipraxis.net/98537-comparing-functions.html)

Razor 28. Aug 2007 20:06


Comparing functions
 
From IO driver #1

Delphi-Quellcode:
 procedure GetPCIRDWord(dwBus, dwDev, dwFunc, offs: byte; var pdata: DWord);
 procedure SetPCIRDWord(dwBus, dwDev, dwFunc, offs: byte; pdata: DWord);


From IO driver #2

Delphi-Quellcode:
function GetPCRD(Bus, Dev, Func, Reg : byte): dword;
procedure SetPCRD(Bus, Dev, Func, Reg : byte; value : dword);

Can driver 2 functions be used same as driver 1 in this way

Delphi-Quellcode:
var
  dwResult : DWORD;
begin
  //-------Reading a temperature of the Core0----------
  dwResult:=GetPCRD(0,24,$03,$E4);
  SetPCRD(0,24,$03,$E4, dwResult and not (1 shl 2)); //Core0 select
  dwResult:=GetPCRD(0,24,$03,$E4);
  C0:= Format('%d °C',[(dwResult shr 16 and $FF)-49]);
  Label0.Caption := C0;
  Form1.Caption:= C0;
  Application.Title:= C0;
  if not Core2Present then Exit;

  //-------Reading a temperature of the Core1----------
  dwResult:=GetPCRD(0,24,$03,$E4);
  SetPCRD(0,24,$03,$E4, dwResult or (1 shl 2)); //Core1 select
  dwResult:=GetPCRD(0,24,$03,$E4);
  Label1.Caption := Format('%d °C',[(dwResult shr 16 and $FF)-49]);


I have tried it this way but i can't even compile this becouse IDE gives an error Internal L1333 error.:(

Delphi-Quellcode:
var
  pdata : DWORD;
begin
  //-------Reading a temperature of the Core0----------
  GetPCIRDWord(0,24,$03,$E4,pdata);
  SetPCIRDWord(0,24,$03,$E4, pdata and not (1 shl 2)); //Core0 select
  GetPCIRDWord(0,24,$03,$E4,pdata);
  C0:= Format('%d °C',[(pdata shr 16 and $FF)-49]);
  Label0.Caption := C0;
  Form1.Caption:= C0;
  Application.Title:= C0;
  if not Core2Present then Exit;

  //-------Reading a temperature of the Core1----------
  GetPCIRDWord(0,24,$03,$E4,pdata);
  SetPCIRDWord(0,24,$03,$E4, pdata or (1 shl 2)); //Core1 select
  GetPCIRDWord(0,24,$03,$E4,pdata);
  Label1.Caption := Format('%d °C',[(pdata shr 16 and $FF)-49]);





Thanks!

Mackhack 28. Aug 2007 21:06

Re: Comparing functions
 
Did you write this code or did you copy and paste it again like all the other code fragments you've showed us so far?

Der_Unwissende 29. Aug 2007 09:38

Re: Comparing functions
 
Zitat:

Zitat von Razor
Can driver 2 functions be used same as driver 1 in this way

Well, take a minute (just one minute, ok!) to think about it! How could you expect two different functions to work the same way? They don't even have the same signature.

I don't know how you could expect meeting your deadline without having any knowledge about the pure Delphi-basics at all. Sorry man, but if you don't even get the meaning of these lines you've posted...

Razor 29. Aug 2007 10:20

Re: Comparing functions
 
Yes i do understand them,they both read dword from pci bus,but maybe is it better to join the 2 driver to 1 single driver?What you think about that?

Muetze1 29. Aug 2007 10:35

Re: Comparing functions
 
Both driver offer the same functionality so device which one to use and then change your code to use the selected one...

Razor 29. Aug 2007 10:37

Re: Comparing functions
 
So basicly here goes for an old version of a driver and a new version of a driver wich has also x64,x86.But why does it delphi give out L1333 internal error I dont understand this... :oops:


The second driver also provides msr read functions basicly both do.... :!:

OlafSt 29. Aug 2007 11:36

Re: Comparing functions
 
Where does this highly interesting code comes from ?

Razor 29. Aug 2007 11:40

Re: Comparing functions
 
Basicly this can't compile...:x

Delphi-Quellcode:
var
pdata:Cardinal;
begin

omcdrv.GetPCIRDWord(0,24,$03,$E4,pdata); // Here i get Internal error L1333
omcdrv.SetPCIRDWord(0,24,$03,$E4, pdata and not (1 shl 2));

C0:= Format('%d °C',[(pdata shr 16 and $FF)-49]);
Label0.Caption := C0;



//procedure GetPCIRDWord(dwBus, dwDev, dwFunc, offs: byte; var pdata: Cardinal);

Torpedo 29. Aug 2007 12:10

Re: Comparing functions
 
Zitat:

Zitat von OlafSt
Where does this highly interesting code comes from ?

Found some parts with Google Code
URL

Razor 29. Aug 2007 12:12

Re: Comparing functions
 
Yes that is AMD64 Core Temperature!Posted by hathor made by deamonES...Do i need to say more?

Razor 29. Aug 2007 16:07

Re: Comparing functions
 
Maybe someone can write an example how to use PortIO (getpcrd,setpcrd) with omcdrv (GetPCIRDWord,SetPCIRDWord).

I dont understand what Muetze ment.

Phoenix 29. Aug 2007 16:20

Re: Comparing functions
 
What did we say about double-posting?
You're doing it again, so take this (again) as a warning to NOT double post.

Muetze confused a word. He did not mean device but decide.
You have to decide what driver is needed to be called and then you have to call the function of the correct driver.

Razor 29. Aug 2007 16:22

Re: Comparing functions
 
He said both offer same functionality so i have to decide wich one to use but its impossible to use 2 becouse i get BSOD(BLUE SCREEN OF DEATH)if i use it,get it? :zwinker:


As i said an example would be perfect just how to make this compilable


omcdrv.GetPCIRDWord(0,24,$03,$E4,pdata);

Muetze1 29. Aug 2007 16:31

Re: Comparing functions
 
Zitat:

Zitat von Phoenix
Muetze confused a word. He did not mean device but decide.
You have to decide what driver is needed to be called and then you have to call the function of the correct driver.

Ups, sorry. Phoenix is right - the word was wrong - decide is what i mean.

Zitat:

Zitat von Razor
He said both offer same functionality so i have to decide wich one to use but its impossible to use 2 becouse i get BSOD(BLUE SCREEN OF DEATH)if i use it,get it? :zwinker:

Yes, we all understand this. And I said you have to decide which one you want to use and then transform all your code using the other driver to use the new selected one. So, do you get it? :zwinker:

That you can't use both is completly logical and so you have to decide which one to use. So decide and then change the sources to use onyl the selected one...

Razor 29. Aug 2007 16:34

Re: Comparing functions
 
[delphi]Alright alright and thanks buuut


[pre]procedure GetPCIRDWord(dwBus, dwDev, dwFunc, offs: byte; var pdata: Cardinal);
procedure SetPCIRDWord(dwBus, dwDev, dwFunc, offs: byte; pdata: Cardinal);


omcdrv.GetPCIRDWord(0,24,$03,$E4,pdata); [/pre]



[pre]var
dwresult:dword;

function GetPCRD(Bus, Dev, Func, Reg : byte): dword;
procedure SetPCRD(Bus, Dev, Func, Reg : byte; value : dword);


dwResult:=GetPCRD(0,24,$03,$E4); [/pre]


Now how in heaven can i change this this arent theh same functions...

Muetze1 29. Aug 2007 16:39

Re: Comparing functions
 
Delphi-Quellcode:
procedure GetPCIRDWord(dwBus, dwDev, dwFunc, offs: byte; var pdata: Cardinal);
function GetPCRD(Bus, Dev, Func, Reg : byte): dword;
dwBus = Bus
dwDev = Dev
dwFunc = Func
offs = Reg div 4
pData = result

Delphi-Quellcode:
procedure SetPCIRDWord(dwBus, dwDev, dwFunc, offs: byte; pdata: Cardinal);
procedure SetPCRD(Bus, Dev, Func, Reg : byte; value : dword);
dwBus = Bus
dwDev = Dev
dwFunc = Func
offs = Reg div 4
pData = value

Razor 29. Aug 2007 17:02

Re: Comparing functions
 
Zitat:

Zitat von Muetze1
Delphi-Quellcode:
procedure GetPCIRDWord(dwBus, dwDev, dwFunc, offs: byte; var pdata: Cardinal);
function GetPCRD(Bus, Dev, Func, Reg : byte): dword;
dwBus = Bus
dwDev = Dev
dwFunc = Func
offs = Reg div 4
pData = result

Delphi-Quellcode:
procedure SetPCIRDWord(dwBus, dwDev, dwFunc, offs: byte; pdata: Cardinal);
procedure SetPCRD(Bus, Dev, Func, Reg : byte; value : dword);
dwBus = Bus
dwDev = Dev
dwFunc = Func
offs = Reg div 4
pData = value

Well so it goes like this then

Delphi-Quellcode:
var
pdata:cardinal;
begin
GetPCIRDWord(0,24,$03,$E4,pdata)
form1.caption:=pdata //???

Muetze1 29. Aug 2007 17:44

Re: Comparing functions
 
Basicly it is ok so, but I think you have to divide the given offset by four. The code is ok, but the line with the question-marks are Delphi basics and not hw specific.

Razor 29. Aug 2007 18:50

Re: Comparing functions
 
I don't know what i am doing wrong :wall:

http://img172.imagevenue.com/img.php..._122_419lo.JPG

Muetze1 29. Aug 2007 19:46

Re: Comparing functions
 
http://www.elists.org/pipermail/delp...il/026837.html

other search result says clear all DCU's and build again

Razor 29. Aug 2007 20:01

Re: Comparing functions
 
:wall: Muetze can you test this please!

Delphi-Quellcode:

//omcdrv.tGetPCIRDWord(0,24,03,$E4 ,pdata) ; //Compile


omcdrv.tGetPCIRDWord(0,24,03,$E4 ,pdata) ; //WONT Compile [Fatal Error]Internal L1333

Razor 30. Aug 2007 08:53

Re: Comparing functions
 
Can somebody test this please.Becouse only then i will know that it isnt my delphi that is wrong and currupted. :oops:

Razor 31. Aug 2007 11:45

Re: Comparing functions
 
*push*

Razor 2. Sep 2007 12:55

Re: Comparing functions
 
For crying out loud,cant nobody test this?

Muetze1 2. Sep 2007 13:38

Re: Comparing functions
 
Oh, sorry. I've tested it some days ago and it works without any problems. Even due the fact of an internal error, I would suggest to reinstall Delphi or install the updates.

Works on D5 Ent UP 2 and D7 Ent UP1...

Razor 2. Sep 2007 13:39

Re: Comparing functions
 
Thank you!!!!!!!!


Now i know my delphi is currupted:?

Razor 4. Nov 2007 15:50

Re: Comparing functions
 
No sadly this still won't work i have tried every possilbe combo but no,and yea my delphi dosent need update and its not curruped.

So help still needed.

Razor 4. Nov 2007 19:00

Re: Comparing functions
 
i know its basics but how to call this

tPCIIO = class(TInterfacedObject, IPCIIO)
private
FIPortIORef: IPortIO;
procedure GetPCIRDWord(dwBus, dwDev, dwFunc, offs: Byte; var pdata: DWord); <<<<<< +This
procedure SetPCIRDWord(dwBus, dwDev, dwFunc, offs: Byte; pdata: DWord); <<<<<<< This
procedure GetPCIRWord(dwBus, dwDev, dwFunc, offs: Byte; var pdata: Word);
procedure GetPCIRByte(dwBus, dwDev, dwFunc, offs: Byte; var pdata: Byte);
procedure SetPCIRByte(dwBus, dwDev, dwFunc, offs, pdata: Byte);
function ProbeDevice(dwBus, dwDev: Byte): boolean;
procedure FindDevice(VendorID, DeviceID: DWord; var fPCIDevice: tPCIDevice);
public
constructor Create(const IPortIORef: IPortIO);
destructor Destroy; override;
end;

dominikkv 4. Nov 2007 19:43

Re: Comparing functions
 
1.
Zitat:

Zitat von Phoenix
What did we say about double-posting?
You're doing it again, so take this (again) as a warning to NOT double post.

2. These two Methods are private, so you can call them only in the class, but not from outside.

Razor 4. Nov 2007 19:55

Re: Comparing functions
 
I know but how exactly...i know becouse they are private only inside and not outside.

But i call it via


Delphi-Quellcode:
procedure tform1.load;
var
omc:tomcdrv;
begin

{omc.>what goes here to have > procedure GetPCIRDWord(dwBus, dwDev, dwFunc, offs: Byte; var pdata: DWord);

with pdata:dword and not pdata:cardinal becouse it wont work}

end;

Muetze1 4. Nov 2007 19:59

Re: Comparing functions
 
Learn the basics. It is increadibly how you show us your missing knowledge...

Ok, back to topic: what do you think does "outside" and "inside" mean?

mkinzler 4. Nov 2007 19:59

Re: Comparing functions
 
That'd be a new kind of OOP. Methods being hidden to the class itself and only accessable by others.

Razor 4. Nov 2007 20:05

Re: Comparing functions
 
Liste der Anhänge anzeigen (Anzahl: 1)
Okay guys if you help me with this i promise i will post the final and finished product :-D ...and yea i have a looot to learn.newbie i am...

Back to the problem..i made a pic


So why is it there var pdata:cardinal and in the omcdrv.pas its var pdata:dword; dont really really get it; and plus why cant i call that function.... :shock:

Muetze1 4. Nov 2007 21:56

Re: Comparing functions
 
Take a look in the help to get the facts about cardinal and dword and their sizes, properties, etc.

Razor 4. Nov 2007 22:02

Re: Comparing functions
 
Muetze1 you said something bout dividing by 4 what did you mean? :?

Razor 4. Nov 2007 22:07

Re: Comparing functions
 
Anyways i wanted to post this also...


Old functions


Delphi-Quellcode:
function GetPCRD(Bus, Dev, Func, Reg : byte): dword;
begin
  SetPortLong($0CF8, $80000000 or (dword(Bus) shl 16) or ((dword(Dev) and
             $1f) shl 11) or ((dword(Func) and $07) shl 8) or (Reg and $fc));
  GetPCRD:=GetPortLong($0CFC);
end;

procedure SetPCRD(Bus, Dev, Func, Reg : byte; value : dword);
begin
  SetPortLong($0CF8,$80000000 or (dword(Bus) shl 16) or ((dword(Dev) and
              $1f) shl 11) or ((dword(Func) and $07) shl 8) or (Reg and $fc));
  SetPortLong($0CFC, value);
end;

New functions
Delphi-Quellcode:
procedure tPCIIO.GetPCIRDWord( dwBus, dwDev, dwFunc, offs : byte; var pdata:DWord );
begin
  FIPortIORef.WritePortL(PCRAddress,$80000000 or (longint(dwBus) shl 16) or ((longint(dwDev) and $1f) shl 11) or
            ((longint(dwFunc) and $07 ) shl 8) or (offs and $fc));
  pdata := FIPortIORef.ReadPortL(PCRData);
end;

procedure tPCIIO.SetPCIRDWord(dwBus, dwDev, dwFunc, offs:byte; pdata:DWord);
//var IPort: IPortIO;
begin


  //IPort := oHWIO.IPortIORef;
  FIPortIORef.WritePortL(PCRAddress,$80000000 or (longint(dwBus) shl 16) or ((longint(dwDev) and $1f) shl 11) or
              ((longint(dwFunc) and $07) shl 8) or (offs and $fc));
  FIPortIORef.WritePortL(PCRData, pdata);
end;







What i tried to do

Delphi-Quellcode:
procedure tmainfrm.amd64x2start;
var
C0:string;
GetInstance:tomcdrv;
pdata: DWord;
begin

       GetInstance.IPCIIORef.GetPCIRDWord(0,24,$03,$E4,pdata);
       GetInstance.IPCIIORef.SetPCIRDWord(0,24,$03,$E4, pdata and not (1 shl 2));
       GetInstance.IPCIIORef.GetPCIRDWord(0,24,$03,$E4,pdata);
       C0:=Format('%d °C',[(pdata shr 16 and $FF)-49]);
       RzLabel99.caption:=C0;

//But then i get [Warning] Temperatures.inc(117): Variable 'GetInstance' might not have been initialized
Or.....


Delphi-Quellcode:
procedure tmainfrm.amd64x2start;
var
C0:string;

pdata: DWord;
begin

       OMCDRV.tGetPCIRDWord(0,24,$03,$E4,pdata);
       OMCDRV.tSetPCIRDWord(0,24,$03,$E4, pdata and not (1 shl 2));
       OMCDRV.tGetPCIRDWord(0,24,$03,$E4,pdata);
       C0:=Format('%d °C',[(pdata shr 16 and $FF)-49]);
       RzLabel99.caption:=C0;

//But then i get [Fatal Error]Internal error: BA1993 or [Fatal Error] Internal error: L1333

Hilfee!!!! :wall:

DevidEspenschied 5. Nov 2007 07:12

Re: Comparing functions
 
Zitat:

Zitat von Razor
So why is it there var pdata:cardinal and in the omcdrv.pas its var pdata:dword; dont really really get it; and plus why cant i call that function.... :shock:

To help you with this problem I need a view into OMCDrv.pas, because the GetPCIRDWord function have to be validated.

Mackhack 5. Nov 2007 07:31

Re: Comparing functions
 
What is that unit exactly for? Sounds like an interesting project!

Razor 5. Nov 2007 07:32

Re: Comparing functions
 
As i said the project will be realased when finished but hilfeee!!! :(

Mackhack 5. Nov 2007 07:33

Re: Comparing functions
 
Zitat:

Zitat von Razor
As i said the project will be realased when finished but hilfeee!!! :(

Ok, is crystal clear and we all do understand it :roll: but I still would like to know what this is for and the unit you just posted so we might be able to help more out here!


Alle Zeitangaben in WEZ +1. Es ist jetzt 06:38 Uhr.
Seite 1 von 3  1 23      

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024-2025 by Thomas Breitkreuz