ADTF  3.18.2
IDeviceabstract

The IDevice interface wraps I/O devices. More...

Inheritance diagram for IDevice:
[legend]

Classes

struct  tDeviceConfig
 Device configuration structure. More...
 
struct  tDeviceInfo
 Device information. More...
 

Public Types

enum  tIOCTL_Command : uint16_t {
  IOCTL_Unknown = 0 , IOCTL_GetDeviceInfo = 1 , IOCTL_RegisterHandler = 2 , IOCTL_UnregisterHandler = 3 ,
  IOCTL_GetDataSize = 4 , IOCTL_GetDataTime = 5 , IOCTL_Start = 6 , IOCTL_Stop = 7 ,
  IOCTL_Pause = 8 , IOCTL_GetConfig = 9 , IOCTL_SetConfig = 10 , IOCTL_BusWakeup = 11 ,
  IOCTL_BusSleep = 12 , IOCTL_User = 0x0100
}
 Device I/O control commands. More...
 
enum  tDeviceMode : uint8_t { DM_Unknown = 0 , DM_Read = 1 , DM_Write = 2 , DM_ReadWrite = 3 }
 Device access modes. More...
 
enum  tDeviceFlags { DF_None = 0x00 , DF_AsyncIO = 0x01 }
 Device operation flags. More...
 

Public Member Functions

 ADTF_IID (IDevice, "device.ant.ucom.adtf.iid")
 Marks the IDevice to be castable with the ucom_cast<> More...
 
virtual tResult Open (const char *strDeviceName, int nMode=0)=0
 Open device. More...
 
virtual tResult Close ()=0
 Close device. More...
 
virtual int Read (void *pvBuffer, int nBufferSize)=0
 Read data from device. More...
 
virtual int Write (const void *pvBuffer, int nBufferSize)=0
 Write data to device. More...
 
virtual int IOCtl (int nCommand, void *pvData=NULL, int nDataSize=0)=0
 Execute I/O control command. More...
 
- Public Member Functions inherited from IObject
 ADTF_IID (IObject, "object.ant.ucom.adtf.iid")
 Marks the IObject to be castable with the ucom_cast() More...
 

Protected Member Functions

 ~IDevice ()=default
 Protected destructor --> Use implemented Destroy() instead of delete!
 
- Protected Member Functions inherited from IObject
 ~IObject ()=default
 Protected destructor --> Use implemented Destroy() instead of delete!
 

Detailed Description

The IDevice interface wraps I/O devices.

Definition at line 23 of file device_intf.h.

Member Enumeration Documentation

◆ tDeviceFlags

Device operation flags.

Enumerator
DF_None 

No flags specified.

DF_AsyncIO 

Device needs to by synchronized to frequency.

Definition at line 119 of file device_intf.h.

◆ tDeviceMode

enum tDeviceMode : uint8_t

Device access modes.

Enumerator
DM_Unknown 

Unknown mode.

DM_Read 

Device will be opened for read-only access.

DM_Write 

Device will be opened for write-only access.

DM_ReadWrite 

Device will be opened for read-write access.

Definition at line 103 of file device_intf.h.

◆ tIOCTL_Command

enum tIOCTL_Command : uint16_t

Device I/O control commands.

Enumerator
IOCTL_Unknown 

Unknown.

IOCTL_GetDeviceInfo 

Get device info.

IOCTL_RegisterHandler 

Register callback handler.

IOCTL_UnregisterHandler 

Unregister callback handler.

IOCTL_GetDataSize 

Get data size.

IOCTL_GetDataTime 

Get data time.

IOCTL_Start 

Start device.

IOCTL_Stop 

Stop device.

IOCTL_Pause 

Pause device.

IOCTL_GetConfig 

Get device configuration.

IOCTL_SetConfig 

Set device configuration.

IOCTL_BusWakeup 

Wakeup bus.

IOCTL_BusSleep 

Suspend bus.

IOCTL_User 

Start identifier for user control commands.

Definition at line 44 of file device_intf.h.

Member Function Documentation

◆ ADTF_IID()

ADTF_IID ( IDevice  ,
"device.ant.ucom.adtf.iid"   
)

Marks the IDevice to be castable with the ucom_cast<>

See also
ADTF_IID(_interface, _striid)

◆ Close()

virtual tResult Close ( )
pure virtual

Close device.

The Close method closes a device.

Returns
Returns a standard result code.

◆ IOCtl()

virtual int IOCtl ( int  nCommand,
void *  pvData = NULL,
int  nDataSize = 0 
)
pure virtual

Execute I/O control command.

The IOCtl method executes a device specific I/O control command.

Parameters
[in]nCommandCommand identifier.
[in]pvDataPointer to command specific data.
[in]nDataSizeSize of command specific data.
Returns
Returns a command specific value, usually -1 if the command failed.

◆ Open()

virtual tResult Open ( const char *  strDeviceName,
int  nMode = 0 
)
pure virtual

Open device.

The Open method opens a device.

Parameters
[in]strDeviceNameName or identifier to be used to specifiy the device.
[in]nModeAccess mode to be opened the device for.
Returns
Returns a standard result code.

◆ Read()

virtual int Read ( void *  pvBuffer,
int  nBufferSize 
)
pure virtual

Read data from device.

The Read method reads data from an opened device.

Parameters
[in]pvBufferPointer to an existing buffer.
[in]nBufferSizeSize in bytes of the existing buffer.
Returns
Returns the number of bytes read from the device or -1 if failed.

◆ Write()

virtual int Write ( const void *  pvBuffer,
int  nBufferSize 
)
pure virtual

Write data to device.

The Write method writes data to an opened device.

Parameters
pvBuffer[in] Pointer to an existing buffer.
nBufferSize[in] Size in bytes of the existing buffer.
Returns
Returns the number of bytes written to the device or -1 if failed.