Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-pascal / 2006-05

porting fpIoctl() to windows

7 messages · 6 people ·

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Marc Santhoff

Hi,

on FreeBSD I use fpOpen, fpIoctl, etc. to drive some generic device. In my porting efforts to win32 I have found the more generic FileOpen, but no equivalent of fpIoctl or it's underlying unix system call ioctl().

An old win32.hlp told me Windows has "DeviceIoCtl()", but I'm not really sure if this is what I need. At least there is ntohing about this funtion in the RTL sources of fps 2.0.2.

How can I port this calls?

TIA,
Marc

Alain Michaud
to Marc Santhoff

Hi,

I use FpIOctl from "BaseUnix" . My platform is Linux. I do FpOpen then FpIOCTL. It works!

However:

The kernel 2.6 has a new naming convention for the function number. See the file: asm/ioctl.h

This file contains many constants and the final call number is assembled from the direction type, device number, function number, etc...

I wanted to write a unit that would simulate this file (ioctl.h), but, this header file contains mainly macros. I do not think that it is possible to write some Pascal code that would in fact be a macro! If someone knows if it possible to write macros in Pascal please tell me.

In the mean time, I calculate the function number "by hand", knowing the device number, function number, IO_RW, etc... Or if I use a precedure do do this, then this will slow the program down.

For the Windows platform, I can not help you sorry.

Thank you

Alain Michaud

Marc Santhoff wrote 19 lines
Hi, on FreeBSD I use fpOpen, fpIoctl, etc. to drive some generic device. In my porting efforts to win32 I have found the more generic FileOpen, but no equivalent of fpIoctl or it's underlying unix system call ioctl(). An old win32.hlp told me Windows has "DeviceIoCtl()", but I'm not really sure if this is what I need. At least there is ntohing about this funtion in the RTL sources of fps 2.0.2. How can I port this calls? TIA, Marc _______________________________________________ fpc-pascal maillist - http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Jonas Maebe
to Alain Michaud
Alain Michaud wrote 5 lines
In the mean time, I calculate the function number "by hand", knowing the device number, function number, IO_RW, etc... Or if I use a precedure do do this, then this will slow the program down.

It should be no problem to use (inline or not)functions. The cost of a system call dwarfs the time that may be needed to shift and "or" a few numbers together (even if you add in the cost of a regular call).

Jonas

Burkhard Carstens
to Marc Santhoff: on FreeBSD I use fpOpen, fpIoctl, etc. to drive some generic device. In my porting…
Marc Santhoff wrote 10 lines
Hi, on FreeBSD I use fpOpen, fpIoctl, etc. to drive some generic device. In my porting efforts to win32 I have found the more generic FileOpen, but no equivalent of fpIoctl or it's underlying unix system call ioctl(). An old win32.hlp told me Windows has "DeviceIoCtl()", but I'm not really sure if this is what I need. At least there is ntohing about this funtion in the RTL sources of fps 2.0.2.

DeviceIOControl is the one I use in Delphi to talk to my vxd driver .. it is linked to kernel32.dll. Should be pretty much what you want.

How can I port this calls?

check, how other winapi calls are implemented ..
I am not that far yet. Did it in Delphi, but now trying to do it on linux ..

Burkhard

Felipe Monteiro de Carvalho
to Alain Michaud: I use FpIOctl from "BaseUnix" . My platform is Linux. I do FpOpen then FpIOCTL. It works!…
Alain Michaud wrote
I wanted to write a unit that would simulate this file (ioctl.h), but, this header file contains mainly macros. I do not think that it is possible to write some Pascal code that would in fact be a macro! If someone knows if it possible to write macros in Pascal please tell me.

You can´t. Transform macros into functions. Some macros can also be substituted directly into the code.

Felipe Monteiro de Carvalho
Marc Santhoff
to Burkhard Carstens: DeviceIOControl is the one I use in Delphi to talk to my vxd driver .. it is linked to…
Burkhard Carstens wrote 14 lines
Am Montag, 29. Mai 2006 22:47 schrieb Marc Santhoff: > Hi, > > on FreeBSD I use fpOpen, fpIoctl, etc. to drive some generic device. > In my porting efforts to win32 I have found the more generic > FileOpen, but no equivalent of fpIoctl or it's underlying unix system > call ioctl(). > > An old win32.hlp told me Windows has "DeviceIoCtl()", but I'm not > really sure if this is what I need. At least there is ntohing about > this funtion in the RTL sources of fps 2.0.2. DeviceIOControl is the one I use in Delphi to talk to my vxd driver .. it is linked to kernel32.dll. Should be pretty much what you want.

Okay, I'll give it a try. I oly wanted to make sure there is no meore general (in sense of platform independant) way to do it and my docs are not to old.

Show quoted text 5 lines
> How can I port this calls? check, how other winapi calls are implemented .. I am not that far yet. Did it in Delphi, but now trying to do it on linux ..

This is where I'm coming from (FreeBSD should be as much Posix as Linux, I think).

Somewhere deep down in the darkness of NT and OS/2 there must be artefacts of Unix in Windows 2k and XP. ;)

Regards,
Marc