ADTF  3.18.2
device_intf.h
Go to the documentation of this file.
1 
8 #ifndef _ADTF_UCOM_ANT_DEVICE_INTERFACE_INCLUDES_HEADER_
9 #define _ADTF_UCOM_ANT_DEVICE_INTERFACE_INCLUDES_HEADER_
10 
11 namespace adtf
12 {
13 namespace ucom
14 {
15 namespace ant
16 {
17 
23 class DOEXPORT IDevice : public IObject
24 {
25 public:
30  ADTF_IID(IDevice, "device.ant.ucom.adtf.iid");
31 
32 public:
34  typedef struct
35  {
37  char strIdentifier[128];
38 
40  uint32_t ui32Flags;
41  } tDeviceInfo;
42 
44  typedef enum : uint16_t
45  {
47  IOCTL_Unknown = 0,
48 
50  IOCTL_GetDeviceInfo = 1,
51 
53  IOCTL_RegisterHandler = 2,
54 
56  IOCTL_UnregisterHandler = 3,
57 
59  IOCTL_GetDataSize = 4,
60 
62  IOCTL_GetDataTime = 5,
63 
65  IOCTL_Start = 6,
66 
68  IOCTL_Stop = 7,
69 
71  IOCTL_Pause = 8,
72 
74  IOCTL_GetConfig = 9,
75 
77  IOCTL_SetConfig = 10,
78 
80  IOCTL_BusWakeup = 11,
81 
83  IOCTL_BusSleep = 12,
84 
86  IOCTL_User = 0x0100
87  } tIOCTL_Command;
88 
90  typedef struct
91  {
93  const char* strConfigName;
94 
96  const void* pvValue;
97 
100  } tDeviceConfig;
101 
103  typedef enum : uint8_t
104  {
106  DM_Unknown = 0,
107 
109  DM_Read = 1,
110 
112  DM_Write = 2,
113 
115  DM_ReadWrite = 3
116  } tDeviceMode;
117 
119  typedef enum
120  {
122  DF_None = 0x00,
123 
125  DF_AsyncIO = 0x01
126  } tDeviceFlags;
127 
128 public:
138  virtual tResult Open(const char* strDeviceName, int nMode=0) = 0;
139 
146  virtual tResult Close() = 0;
147 
158  virtual int Read(void* pvBuffer, int nBufferSize) = 0;
159 
170  virtual int Write(const void* pvBuffer, int nBufferSize) = 0;
171 
184  virtual int IOCtl(int nCommand, void* pvData=NULL, int nDataSize=0) = 0;
185 
186 protected:
188  ~IDevice() = default;
189 };
190 
191 }//namespace ant
192 
195 
196 }//namespace ucom
197 }//namespace adtf
198 
199 //*************************************************************************************************
200 #endif //_ADTF_UCOM_ANT_DEVICE_INTERFACE_INCLUDES_HEADER_
The IDevice interface wraps I/O devices.
Definition: device_intf.h:24
virtual int Write(const void *pvBuffer, int nBufferSize)=0
Write data to device.
virtual int IOCtl(int nCommand, void *pvData=NULL, int nDataSize=0)=0
Execute I/O control command.
ADTF_IID(IDevice, "device.ant.ucom.adtf.iid")
Marks the IDevice to be castable with the ucom_cast<>
virtual int Read(void *pvBuffer, int nBufferSize)=0
Read data from device.
virtual tResult Close()=0
Close device.
~IDevice()=default
Protected destructor --> Use implemented Destroy() instead of delete!
virtual tResult Open(const char *strDeviceName, int nMode=0)=0
Open device.
Base class for every interface type within the uCOM.
Definition: object_intf.h:31
ant::IDevice IDevice
Alias always bringing the latest version of ant::IDevice into scope.
Definition: device_intf.h:194
Namespace for entire ADTF SDK.
Device configuration structure.
Definition: device_intf.h:91
const char * strConfigName
Parameter name.
Definition: device_intf.h:93
const void * pvValue
Parameter value.
Definition: device_intf.h:96
uint32_t ui32Flags
Device flags as defined in tDeviceFlags.
Definition: device_intf.h:40