CHAILink SDK  Version 1.3
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
CLC_Main.h
Go to the documentation of this file.
1 //*********************************************************
2 // File: CLC_Main.h
3 // Project: CopperLan CHAILink Client SDK
4 // Version: 1.3
5 // Release Date: 2014/04/15
6 //*********************************************************
7 
8 /********************************************************************
9 Software License Agreement: CHAILink Client source code
10 
11 The software supplied herewith by Klavis Technology (the “Company”) is intended and
12 supplied to you, the Company’s customer, for use solely and exclusively on embedded
13 CopperLan products needing a CHAILink Client.
14  The software is owned by the Company and/or its supplier, and is protected
15  under applicable copyright laws. All rights are reserved. Any use in violation of the
16  foregoing restrictions may subject the user to criminal sanctions under applicable laws,
17 as well as to civil liability for the breach of the terms and conditions of this license.
18 
19 THIS SOFTWARE MUST REMAIN UNMODIFIED. NO WARRANTIES, WHETHER EXPRESS,
20  IMPLIED OR STATUTORY, INCLUDING, BUT NOT LIMITED TO, IMPLIED WARRANTIES OF
21  MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE APPLY TO THIS SOFTWARE
22 IN CASE OF SOURCE CODE CHANGE BY THE CUSTOMER. IN CASE OF SUCH CHANGE, THE
23 COMPANY SHALL NOT BE LIABLE FOR SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES
24 OF ANY KIND.
25 ********************************************************************/
26 
27 #ifndef _CLC_MAIN_H_
28 #define _CLC_MAIN_H_
29 
30 // MACRO for Transport protocol
31 #define _CLTP_CLIENTMODE
32 
33 #include "CLC_CustomizationVerif.h"
34 #include "CLCm_Defines.h"
35 #include "CLC_Types.h"
36 #include "CLC_Enums.h"
37 
38 #include "CLCm_TransportProtocol.h"
39 #include "CLCm_Utils.h"
40 
41 #include "CLC_Utils.h"
42 #include "CLC_Fct_Async.h"
43 
44 #include "CLC_Fct_Value.h"
45 
46 #include "CLC_Fct_EventMessage.h"
49 #include "CLC_Fct_TextMessage.h"
51 
52 #include "CLC_Fct_CHAI.h"
53 #include "CLC_Fct_LocalDevice.h"
54 #include "CLC_Fct_CP2Midi.h"
55 #include "CLC_Fct_Midi2CP.h"
56 #include "CLC_Fct_HybridMidi.h"
58 #include "CLC_Fct_SharedDisplay.h"
59 #include "CLC_Fct_VMIDILink.h"
60 #include "CLC_Fct_Input.h"
61 #include "CLC_Fct_Output.h"
62 #include "CLC_Fct_Pipe.h"
63 #include "CLC_Fct_RemoteDevice.h"
64 
65 #include "CLC_Fct_HookedObject.h"
66 #include "CLC_Fct_Server.h"
67 
68 #include "CLC_Callbacks.h"
69 
70 #ifdef __cplusplus
71 extern "C" {
72 #endif
73 
74 //=========================================================================
75 // runtime check defines
76 //=========================================================================
77 #ifdef ENABLE_RUNTIMECHECK
78 #define CHECK_INSYSTEMPROCESS() if (!(g_CLCWD.eStatus & CLCS_InCPProcess)) \
79  return CLC_ErrorCode_General_CannotCallFromSystem;
80 #else
81 #define CHECK_INSYSTEMPROCESS()
82 #endif
83 
84 //=========================================================================
85 // CHAILink control
86 //=========================================================================
87 
95 CLC_SDK_API CPBOOLEAN CLC_Init(
96  CLC_Callbacks const * const pCB,
97  CLT_Interface const * const pTransportInterface,
98  CPBOOLEAN const fKeepAliveActive );
99 
104 CLC_SDK_API CPBOOLEAN CLC_StartScheduler(void);
105 
110 CLC_SDK_API CPBOOLEAN CLC_StopScheduler(void);
111 
112 #ifdef ENABLE_THREADING
115 #else
116 #define CLC_RequestProcessing()
117 #endif
118 
121 CLC_SDK_API void CLC_DoProcess(void);
122 
125 CLC_SDK_API CPBOOLEAN CLC_IsReady(void);
126 
129 CLC_SDK_API CPBOOLEAN CLC_IsInitialized(void);
130 
136 
138 
139 //=========================================================================
140 // Timeout Values
141 //=========================================================================
142 #define CLC_FUNCTIONRETURN_TIMEOUTMS (5000000)
143 
144 //=========================================================================
145 // Complex data empty values
146 //=========================================================================
147 extern CLC_SDK_API CPDEVICEID const EmptyDeviceID;
148 extern CLC_SDK_API CPENDPOINT const EmptyEndPoint;
149 extern CLC_SDK_API CPPARAMETERID const EmptyParameterID;
150 extern CLC_SDK_API CPSECTIONID const NullSectionID;
151 extern CLC_SDK_API CPSECTIONID const AnySectionID;
152 extern CLC_SDK_API CPPARAMETERID const NullParameterID;
153 
154 //=========================================================================
155 // For internal use only
156 //=========================================================================
157 
158 typedef enum
159 {
160  CLCS_None = 0x0000,
161  CLCS_CLTPConnected = 0x0001, // CHAILink Transport Protocol connected to server
162  CLCS_WaitingForRT = 0x0002, // CHAILink is waiting for a function call response
163  CLCS_RTToProcess = 0x0004, // CHAILink has received a function response
164  CLCS_AHToProcess = 0x0008, // CHAILink has received an asynchronous handler to process
165  CLCS_InCPProcess = 0x0010, // CHAILink is in CopperLan pseudo process
166  CLCS_NotifyConnectionStateChanged = 0x0020, // CHAILink has to notify the OnConnectionStateChanged callback
167  CLCS_StopRequired = 0x0040 // CHAILink scheduler has to stop (CLC_StartScheduler will exit after this call)
168 }CLC_Status;
169 
170 typedef struct
171 {
172  //---------------------------------------------------------------------
173  // Transport protocol data
174  //---------------------------------------------------------------------
175  CLTP_Working CLTPVariables;
176  //---------------------------------------------------------------------
177  // Function returns and ARH and NH management
178  //---------------------------------------------------------------------
179  CPBYTE *pAHBuffer;
180  CPBYTE *pRTBuffer;
181  // data for buffers management
182  CPHOBJECT hAHObj;
183  CPUINT16 wRTMethodID;
184  CPUINT16 wRTCHAILinkError;
185  CPUINT16 wRTPayloadSize;
186  CPUINT16 wAHPayloadSize;
187  CPUINT16 wAHMethodID;
188  //---------------------------------------------------------------------
189  // Connection status
190  //---------------------------------------------------------------------
191  volatile CLC_Status eStatus;
192  CPUINT16 wResetCode;
193  // Buffer for Async handler (ARH & NH)
194 #if defined(ENABLE_ETHERNET_PASSTHRU)
195  CPBYTE arbAHBufferT[sizeof(CPUINT16) + CLMSG_ETHERNETFRAMEMAXSIZE + 3];
196 #else
197  CPBYTE arbAHBufferT[CLMSG_PAYLOADMAXSIZE + 3];
198 #endif
199  // Buffer for Return data type
200  CPBYTE arbRTBufferT[CLMSG_PAYLOADMAXSIZE + 3];
201 } CLC_WorkingData;
202 
203 extern CLC_WorkingData g_CLCWD;
204 
205 CLC_ErrorCode _CLC_SendCopperLanCMDMessage( CPHOBJECT hObject, CPUINT16 wMethodID );
206 CLC_ErrorCode _CLC_FinishAndSendMessage( CPUINT16 wMethodID, CPBYTE * pEndPointer );
207 
208 void _CLC_Error( CLC_ErrorCode eErrorCode );
209 
211 
212 #ifdef __cplusplus
213 }
214 #endif
215 
216 #endif // _CLC_MAIN_H_
CPBOOLEAN CLC_Init(CLC_Callbacks const *const pCB, CLT_Interface const *const pTransportInterface, CPBOOLEAN const fKeepAliveActive)
CHAILink Client Initialization.
#define CLC_SDK_API
Definition: CLCm_Platform.h:37
Container structure for Section ID Each Input is associated to a SectionID giving information about i...
Definition: CLC_Types.h:67
CPBOOLEAN CLC_IsInitialized(void)
Check if the CHAILink is initialized.
CLC_ErrorCode
Error code Enumeration. Error codes from 0x01 to 0xFF are related to a CopperLan functions return cod...
Definition: CLCm_Defines.h:469
void CLC_CallSystemDoProcess(void)
Call the SystemDoProcess This API enables external components to call the SystemDoProcess. For instance the transport that should perform send request synchronously can call this function in order that the system continues processing others IO while the transport is waiting for an event.
CPBOOLEAN CLC_StopScheduler(void)
CHAILink Client Scheduler stop This function allows the internal scheduler to stop.
CPBOOLEAN CLC_IsReady(void)
Check if the CHAILink is ready.
unsigned short CPUINT16
Word Integer (16 bit unsigned)
Definition: PlatformTypes.h:45
Container structure for Parameter ID. Knowing a ParameterID and its owning Device gives enough inform...
Definition: CLC_Types.h:76
Container structure for Endpoint.
Definition: CLC_Types.h:48
Container structure for Device ID.
Definition: CLC_Types.h:39
Structure containing all CHAILink client callbacks.
Definition: CLC_Callbacks.h:1988
CPBOOLEAN CLC_StartScheduler(void)
CHAILink Client Scheduler start.
CPUINT32 CPHOBJECT
Handle on Object.
Definition: CLCm_Types.h:57
CHAI Link Transport Interface.
Definition: CLCm_Transport.h:82
#define CLC_RequestProcessing()
Definition: CLC_Main.h:116
void CLC_DoProcess(void)
CHAILink Client DoProcess.