I am trying to translate some headers with _IOR. In Raspian _IOR is defined as
#ifndef _IOR
# define _IOR(x,y,z) (((x)<<8)|y)
#endif
So if I have this:
#define SPI_IOC_MAGIC 'k'
#define SPI_IOC_RD_MODE _IOR(SPI_IOC_MAGIC, 1, __u8)
I did this:
const
SPI_IOC_MAGIC = ord('k');
SPI_IOC_RD_MODE = (SPI_IOC_MAGIC shl 8) or 1;
which does not seem to work:
var
devPath : string = '/dev/spidev0.0';
var
ModePtr: ^Byte;
Mode: Byte;
IOCtlResult: Integer;
begin
handle := fpopen(devPath,O_RDWR);
Mode := SPI_IOC_RD_MODE;
ModePtr := @Mode;
IOCtlResult := fpIOCtl(handle, SPI_IOC_RD_MODE, ModePtr);
IOCtlResult returns -1.
It appears the "Z" parameter is not used in the macro and the dummy parameter is the "__u8"
What I am doing wrong?
I do get a valid handle from fpopen()
Jim