Neonode zForce(TM) SDK

Transport.h
Go to the documentation of this file.
1
10 #ifndef TRANSPORT_TRANSPORT_H
11 #define TRANSPORT_TRANSPORT_H 1
12
13 #ifndef ZFORCECOMMON_H
14 #error Please include "zForceCommon.h" before this file.
15 #endif // ZFORCECOMMON_H
16
18 typedef enum ReadWriteThreadStatus ReadWriteThreadStatus;
20 enum ReadWriteThreadStatus
21 {
22 ThreadIsNotRunning,
23 ThreadIsInitializing,
24 ThreadIsRunning,
25 ThreadIsTerminating
26 };
27
28 /*
29 * Forward declaration required in order to break the cycle where Transport needs TransportEntry, and
30 * TransportEntry needs Transport.
31 */
33 typedef struct TransportEntry TransportEntry;
34
38 typedef struct Transport Transport;
42 struct Transport
43 {
50 Transport * Base;
51
57 Connection * Connection;
58
64 zForce * zForce;
65
74 char ConnectionString [TRANSPORTPROTOCOL_MaxOptionParameterLength + 1];
75
81 volatile bool Terminate;
82
88 Queue * WriteQueue;
89
95 bool IsOpen;
96
102 bool Opening;
103
109 zForceThread * WriteThread;
110
116 zForceThread * ReadThread;
117
123 volatile ReadWriteThreadStatus WriteThreadStatus;
124
130 volatile ReadWriteThreadStatus ReadThreadStatus;
131
152 bool ( * Open) (Transport * self);
153
168 bool ( * Close) (Transport * self);
169
184 DataFrame * ( * Read) (Transport * self);
185
201 bool ( * Write) (Transport * self, DataFrame * payload);
202
212 uint64_t ( * GetTimeOutValue) (Transport * self);
213
230 bool ( * EnqueueDataFrame) (Transport * self, DataFrame * dataFrame);
231
239 void ( * Destructor ) (Transport * self);
240
248 void ( * TransportLost) (Transport * self);
249
255 bool StopCommunication;
256 };
257
258 // Exported Functions (prefixed with module name and underscore)
259
260 #ifdef __cplusplus
261 extern "C"
262 {
263 #endif // __cplusplus
264
290 DLLEXTERNAL Transport * Transport_GetInstance (Connection * connection, char * connectionString, char * dataFrameType);
291
309 DLLEXTERNAL bool Transport_AddTransport(TransportEntry * transportEntry);
310
326 DLLINTERNAL bool Transport_Initialize (void);
327
339 DLLINTERNAL void Transport_Uninitialize (void);
340
341 #ifdef USE_SERIALTRANSPORT
342 DLLINTERNAL bool SerialTransport_AddSerialTransportEntry (void);
343 #endif // USE_SERIALTRANSPORT
344
345 #ifdef USE_HIDPIPETRANSPORT
346 DLLINTERNAL bool HidPipeTransport_AddHidPipeTransportEntry (void);
347 #endif // USE_HIDPIPETRANSPORT
348
349 #ifdef __cplusplus
350 }
351 #endif // __cplusplus
352
353 #endif // TRANSPORT_TRANSPORT_H
354
HidPipeTransport_AddHidPipeTransportEntry
DLLINTERNAL bool HidPipeTransport_AddHidPipeTransportEntry(void)
Internal call to add a HidPipeTransport to the list of available transports.
zForceThread
void zForceThread
Typecast to underlying (system) type.
Definition: OsAbstractionLayer.h:20
SerialTransport_AddSerialTransportEntry
DLLINTERNAL bool SerialTransport_AddSerialTransportEntry(void)
Internal call to add a SerialTransport to the list of available transports.
TransportEntry
struct TransportEntry TransportEntry
Definition: Transport.h:33
Transport_AddTransport
DLLEXTERNAL bool Transport_AddTransport(TransportEntry *transportEntry)
Add a new Transport to the list of those available.
Transport_GetInstance
DLLEXTERNAL Transport * Transport_GetInstance(Connection *connection, char *connectionString, char *dataFrameType)
Transport factory function.
ReadWriteThreadStatus
ReadWriteThreadStatus
Enum describing the current status of a Read or Write thread.
Definition: Transport.h:21
ThreadIsInitializing
@ ThreadIsInitializing
Thread is Initializing.
Definition: Transport.h:23
ThreadIsRunning
@ ThreadIsRunning
Thread is Running.
Definition: Transport.h:24
ThreadIsNotRunning
@ ThreadIsNotRunning
Thread is not running.
Definition: Transport.h:22
ThreadIsTerminating
@ ThreadIsTerminating
Thread is Terminating.
Definition: Transport.h:25
Transport_Initialize
DLLINTERNAL bool Transport_Initialize(void)
Initialize the Transport module.
Transport_Uninitialize
DLLINTERNAL void Transport_Uninitialize(void)
Uninitialize the Transport module.
Connection
The main Connection struct.
Definition: Connection.h:66
DataFrame
Struct containing the DataFrame information.
Definition: DataFrame.h:25
Queue
The Queue struct.
Definition: Queue.h:25
Transport
Transport struct. This structure represents the base class of all Transport definitions.
Definition: Transport.h:43
Transport::zForce
zForce * zForce
A pointer to the global zForce instance.
Definition: Transport.h:64
Transport::TransportLost
void(* TransportLost)(Transport *self)
Signals the transport that it has been lost and acts accordingly.
Definition: Transport.h:248
Transport::ReadThreadStatus
volatile ReadWriteThreadStatus ReadThreadStatus
Thread is active.
Definition: Transport.h:130
Transport::Connection
Connection * Connection
Each Transport is linked to one Connection.
Definition: Transport.h:57
Transport::WriteThread
zForceThread * WriteThread
Write Thread pointer.
Definition: Transport.h:109
Transport::ConnectionString
char ConnectionString[TRANSPORTPROTOCOL_MaxOptionParameterLength+1]
Connection string.
Definition: Transport.h:74
Transport::Base
Transport * Base
Base pointer to the immediate base Transport class.
Definition: Transport.h:50
Transport::EnqueueDataFrame
bool(* EnqueueDataFrame)(Transport *self, DataFrame *dataFrame)
Enqueue given dataframe.
Definition: Transport.h:230
Transport::GetTimeOutValue
uint64_t(* GetTimeOutValue)(Transport *self)
Function pointer to Transport's GetTimeOutValue.
Definition: Transport.h:212
Transport::Close
bool(* Close)(Transport *self)
Close the generic Transport.
Definition: Transport.h:168
Transport::Terminate
volatile bool Terminate
A flag indicating if the Transport Read and Write threads should terminate (true) or not (false).
Definition: Transport.h:81
Transport::Write
bool(* Write)(Transport *self, DataFrame *payload)
Function pointer to Transport's Write.
Definition: Transport.h:201
Transport::ReadThread
zForceThread * ReadThread
Read Thread pointer.
Definition: Transport.h:116
Transport::Open
bool(* Open)(Transport *self)
Open the generic Transport.
Definition: Transport.h:152
Transport::IsOpen
bool IsOpen
A flag indicating if the Transport is open (true) or not (false).
Definition: Transport.h:95
Transport::WriteThreadStatus
volatile ReadWriteThreadStatus WriteThreadStatus
Thread is active.
Definition: Transport.h:123
Transport::Destructor
void(* Destructor)(Transport *self)
Destructor frees all the resources that have been allocated.
Definition: Transport.h:239
Transport::StopCommunication
bool StopCommunication
Boolean value that indicates that there is no longer any communication. Internal use only.
Definition: Transport.h:255
Transport::WriteQueue
Queue * WriteQueue
A pointer to the Write queue used by EnqueueDataFrame.
Definition: Transport.h:88
Transport::Opening
bool Opening
Transport is in Opening phase.
Definition: Transport.h:102
zForce
Main struct.
Definition: zForce.h:29