Talk:Hardware Access

From Free Pascal wiki

Download links

The version of inpout32.dll at 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 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:

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

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)

Yes, you are right. I mistaked ShortInt with SmallInt. Another problem is that types in c are dependent on compiler and system, but I beliave using a 16 bits type will most of the time be correct. --Sekelsenmat 18:36, 4 November 2007 (CET)

Serial communication

I added an code-example in the Serial - Connection Section, because the old example has an bug in it. Maybe it caused only on my system the annoying situation, that I had to reboot everytime I wanted to relaunch the application after quitting it. The problem is better described in the article.

However, I did NOT delete the old code - example, I just added my version (which works for me really fine). I did not know, if I should delete the old version or not. But in my view, we can delete the old version, if there's enough good response and acceptance to my contribution (and of course if there's no bug in it)