Talk:Hardware Access

From Lazarus wiki
Revision as of 16:01, 4 November 2007 by Barteam (talk | contribs) (→‎Have a look: added links to msdn and FPC documentation)
Jump to navigationJump to search

Download links

The version of inpout32.dll at www.logix4u.net/inpout32.htm did not work for me and would generate odd errors such as "Control-C hit. Press OK to ignore and risk data corruption" and "Project rased exception class 'External: SIGILL'.

When i switched to the inpout32.dll at http://www.highrez.co.uk/Downloads/InpOut32/default.htm things started to work for me.

I think it can be cited as another option with the same interface. --Sekelsenmat 14:07, 2 November 2007 (CET)

Changes to the headers

Reading the c import unit:

http://www.hytherion.com/beattidp/comput/pport/Test2.c

The changes made are incorrect. Specifically, changing the size of the data sent can potencially cause trouble. I also checked VB code, and even the source of the DLL itself, and I couldn't find anything that suggests that the previous interface was wrong, so I am reverting.

--Sekelsenmat 14:07, 2 November 2007 (CET)

Have a look

I downloaded the sources of InpOut32.dll from

http://logix4u.net/inpout32_source_and_bins.zip

looked at "\inpout32_source_and_bins\Inpout32_dll_source\inpout32drv.cpp"

and it says that the prototype for exported Inp32 and Out32 are:

void _stdcall Out32(short PortAddress, short data);
short  _stdcall Inp32(short PortAddress);

short type range in C language family is -32768..32767 (2 bytes after MSDN) which actually differs from FPC ShortInt -128..127 (1 byte).

So it seems we both were wrong, cause equivalent data type used in prototype for FPC should be SmallInt (after FPCdoc), it's the same size and range.

Besides when one use ShortInt declaration he cannot access ports addressed over 127. I'm using the library to control the parallel port, which address is 888 (0378 in hex), that's why i guessed that data type for address parameter should be Word (computer has no addresses below 0) and data parameter should be Byte (parallel port has 8 pins of data register so it's one byte).

Accordingly to these arguments i think the correct prototypes shoud look like this:

TInp32 = function(Address: SmallInt): SmallInt; stdcall;
TOut32 = procedure(Address: SmallInt; Data: SmallInt); stdcall;   

--Barteam 14:49, 4 November 2007 (CET)