Neonode zForce(TM) SDK
Transport.h
Go to the documentation of this file.
1 
12 #if !defined(TRANSPORT_TRANSPORT_H) && !defined(CONTAINS_TRANSPORT)
13 
14 #ifndef ZFORCECOMMON_H
15  #error Please include "zForceCommon.h" before this file.
16 #endif // ZFORCECOMMON_H
17 
22 {
27 };
28 
29 /*
30  * Forward declaration required in order to break the cycle where
31  * Transport needs TransportEntry, and
32  * TransportEntry needs Transport.
33  */
36 
40 typedef struct Transport Transport;
46 struct Transport
47 {
48 #endif // !defined(TRANSPORT_TRANSPORT_H) && !defined(CONTAINS_TRANSPORT)
49 #if !defined(TRANSPORT_TRANSPORT_H) || defined(CONTAINS_TRANSPORT)
50 
69  char ConnectionString [TRANSPORTPROTOCOL_MaxOptionParameterLength + 1];
74  volatile bool Terminate;
82  bool IsOpen;
83  bool Opening;
88 
109  bool ( * Open)(Transport * self);
122  bool ( * Close)(Transport * self);
137  DataFrame * ( * Read)(Transport * self);
151  bool ( * Write)(Transport * self, DataFrame * payload);
159  uint64_t ( * GetTimeOutValue)(Transport * self);
174  bool ( * EnqueueDataFrame)(Transport * self, DataFrame * dataFrame);
180  void ( * Destructor )(Transport * self);
186  void ( * TransportLost)(Transport * self);
191 #endif // !defined(TRANSPORT_TRANSPORT_H) || defined(CONTAINS_TRANSPORT)
192 #if !defined(TRANSPORT_TRANSPORT_H) && !defined(CONTAINS_TRANSPORT)
193 };
194 
195 // Exported Functions (prefixed with module name and underscore)
196 
197 #ifdef __cplusplus
198 extern "C"
199 {
200 #endif // __cplusplus
201 
234 DLLEXTERNAL Transport * Transport_GetInstance (Connection * connection, char * connectionString, char * dataFrameType);
235 
260 DLLEXTERNAL bool Transport_AddTransport(TransportEntry * transportEntry);
261 
282 DLLINTERNAL bool Transport_Initialize (void);
283 
297 DLLINTERNAL void Transport_Uninitialize (void);
298 
299 #ifdef USE_SERIALTRANSPORT
300  DLLINTERNAL bool SerialTransport_AddSerialTransportEntry (void);
301 #endif // USE_SERIALTRANSPORT
302 
303 #ifdef USE_HIDPIPETRANSPORT
304  DLLINTERNAL bool HidPipeTransport_AddHidPipeTransportEntry (void);
305 #endif // USE_HIDPIPETRANSPORT
306 
307 #ifdef __cplusplus
308 }
309 #endif // __cplusplus
310 
311 #define TRANSPORT_TRANSPORT_H
312 #endif // !defined(TRANSPORT_TRANSPORT_H) && !defined(CONTAINS_TRANSPORT)
313 
DLLINTERNAL void Transport_Uninitialize(void)
Uninitialize the Transport module.
bool(* Write)(Transport *self, DataFrame *payload)
Function pointer to Transport's Write.
Definition: Transport.h:151
The main Connection struct.
Definition: Connection.h:64
bool(* Open)(Transport *self)
Open the generic Transport.
Definition: Transport.h:109
volatile ReadWriteThreadStatus ReadThreadStatus
Thread is active.
Definition: Transport.h:87
DLLINTERNAL bool SerialTransport_AddSerialTransportEntry(void)
Internal call to add a SerialTransport to the list of available transports.
Transport struct. This structure represents the base class of all Transport definitions.
Definition: Transport.h:46
bool StopCommunication
Boolean value that indicates that there is no longer any communication. Internal use only...
Definition: Transport.h:190
zForce * zForce
A pointer to the global zForce instance.
Definition: Transport.h:62
bool IsOpen
A flag indicating if the Transport is open (true) or not (false).
Definition: Transport.h:82
Thread is Initializing.
Definition: Transport.h:24
void(* Destructor)(Transport *self)
Destructor frees all the resources that have been allocated.
Definition: Transport.h:180
volatile ReadWriteThreadStatus WriteThreadStatus
Thread is active.
Definition: Transport.h:86
DLLEXTERNAL bool Transport_AddTransport(TransportEntry *transportEntry)
Add a new Transport to the list of those available.
Thread is Terminating.
Definition: Transport.h:26
Thread is not running.
Definition: Transport.h:23
Transport * Base
Base pointer to the immediate base Transport class. The inheritance is nested so for example WinSerTr...
Definition: Transport.h:56
The Queue struct.
Definition: Queue.h:25
bool Opening
Transport is in Opening phase.
Definition: Transport.h:83
Struct containing the DataFrame information.
Definition: DataFrame.h:26
DLLINTERNAL bool HidPipeTransport_AddHidPipeTransportEntry(void)
Internal call to add a HidPipeTransport to the list of available transports.
struct TransportEntry TransportEntry
Definition: Transport.h:35
uint64_t(* GetTimeOutValue)(Transport *self)
Function pointer to Transport's GetTimeOutValue.
Definition: Transport.h:159
void zForceThread
Typecast to underlying (system) type.
Definition: OsAbstractionLayer.h:20
DLLINTERNAL bool Transport_Initialize(void)
Initialize the Transport module.
void(* TransportLost)(Transport *self)
Signals the transport that it has been lost and acts accordingly.
Definition: Transport.h:186
Main struct.
Definition: zForce.h:28
DLLEXTERNAL Transport * Transport_GetInstance(Connection *connection, char *connectionString, char *dataFrameType)
This is the Transport factory function.
zForceThread * WriteThread
Write Thread pointer.
Definition: Transport.h:84
char ConnectionString[TRANSPORTPROTOCOL_MaxOptionParameterLength+1]
Connection string. This string contain the type of transport and the option parameters on the followi...
Definition: Transport.h:69
volatile bool Terminate
A flag indicating if the Transport Read and Write threads should terminate (true) or not (false)...
Definition: Transport.h:74
Queue * WriteQueue
A pointer to the Write queue used by EnqueueDataFrame.
Definition: Transport.h:78
bool(* Close)(Transport *self)
Close the generic Transport.
Definition: Transport.h:122
Connection * Connection
Each Transport is linked to one Connection.
Definition: Transport.h:60
Thread is Running.
Definition: Transport.h:25
ReadWriteThreadStatus
Enum describing the current status of a Read or Write thread.
Definition: Transport.h:21
zForceThread * ReadThread
Read Thread pointer.
Definition: Transport.h:85
bool(* EnqueueDataFrame)(Transport *self, DataFrame *dataFrame)
Enqueue given dataframe.
Definition: Transport.h:174