page generated on
22.12.2024
-
04:45
basic CDI library routines
More...
|
CDI_EXPORT int | cdiRegisterBusCleanup (char *busName, int(*fcn)(int)) |
| registers the bus cleanup function used when CDI closes. More...
|
|
CDI_EXPORT int | cdiRegisterBusHandler (char *busName, void(*fcn)(CdiRequestInfoBlk *)) |
| registers the bus handler dispatch function used for bus io. More...
|
|
CDI_EXPORT int | cdiRegisterBusInitialization (char *busName, int(*fcn)(int, int, int, char *)) |
| registers a bus initialization function to be used by CDI when initializing the bus. More...
|
|
CDI_EXPORT int | cdiRegisterBusScanner (char *busName, int(*fcn)(char *, char *, int)) |
| registers the bus scan function used for CDI diagnostics. More...
|
|
CDI_EXPORT int | cdiRegisterCalibrationFunction (char *fcnName, double(*fcn)(double)) |
| registers a calibration function for use by CDI More...
|
|
basic CDI library routines
◆ cdiRegisterBusCleanup()
CDI_EXPORT int cdiRegisterBusCleanup |
( |
char * |
busName, |
|
|
int(*)(int) |
fcn |
|
) |
| |
registers the bus cleanup function used when CDI closes.
This routine will be called when CDI closes and allows the bus to free up resources, etc.
- Parameters
-
busName | is the bus plug name to be used by database entries refering to this bus plug. |
fcn | is the address of the bus cleanup function to be called when CDI closes. The function must have the prototype
int fcn(int line)
and return '0' if the call was successful. The line parameter will contain the bus line which is being closed. |
example:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include <stdarg.h>
#include <math.h>
#include <errno.h>
#include "cdi.h"
#include "tinecdi.h"
#include "cdiSimulateLib.h"
#define BUSPLUG_NAME "SIMULATE"
char gBusPlugName[64] = BUSPLUG_NAME;
int cdiInitSimulate(void)
{
int cc = 0;
if ((cc=cdiRegisterBusFilter(gBusPlugName,filterSimulation)) != 0 ) goto err;
err:
if (cc)
{
cdilog("%s : failure in bus registration SEDPC",erlst[cc]);
}
return cc;
}
void fixBusPlugName(void)
{
char *ptr = getenv("CDI_SIMULATE_PLUG");
if (ptr != NULL && strlen(ptr) > 0)
{
strncpy(gBusPlugName, ptr, 16);
gBusPlugName[16] = 0;
}
}
#if defined(WIN32)
BOOL WINAPI DllMain(HINSTANCE hInstDll,DWORD fdwReason,LPVOID lpvReserved)
{
switch (fdwReason)
{
case DLL_PROCESS_ATTACH:
fixBusPlugName();
cdiInitSimulate();
break;
case DLL_THREAD_ATTACH:
break;
case DLL_THREAD_DETACH:
break;
case DLL_PROCESS_DETACH:
break;
}
return (TRUE);
}
#elif defined(UNIX)
__attribute__((constructor)) void cdiSedacMain(void)
{
fixBusPlugName();
cdiInitSimulate();
return;
}
#endif
- Returns
- 0 upon success
◆ cdiRegisterBusHandler()
CDI_EXPORT int cdiRegisterBusHandler |
( |
char * |
busName, |
|
|
void(*)(CdiRequestInfoBlk *) |
fcn |
|
) |
| |
registers the bus handler dispatch function used for bus io.
This is the principal dispatch routine used to commuicate with the hardware bus. All 'SEND' and 'RECV' activity flow through this routine. Any calls will provide the complete CdiRequestBlk defining the requested transaction, and it is the duty of the bus plug to process the request and return.
- Parameters
-
busName | is the bus plug name to be used by database entries refering to this bus plug. |
fcn | is the address of the bus handler function to be called when CDI accesses the hardware bus. The function must have the prototype
int fcn(CdiRequestBlk *reqBlk)
and return '0' if the call was successful. The CDI Request Block will define the nature of the requested transaction in its entirety. All associated parameter lists will be provided within this structure. |
example:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include <stdarg.h>
#include <math.h>
#include <errno.h>
#include "cdi.h"
#include "tinecdi.h"
#include "cdiSimulateLib.h"
#define BUSPLUG_NAME "SIMULATE"
char gBusPlugName[64] = BUSPLUG_NAME;
int cdiInitSimulate(void)
{
int cc = 0;
if ((cc=cdiRegisterBusFilter(gBusPlugName,filterSimulation)) != 0 ) goto err;
err:
if (cc)
{
cdilog("%s : failure in bus registration SEDPC",erlst[cc]);
}
return cc;
}
void fixBusPlugName(void)
{
char *ptr = getenv("CDI_SIMULATE_PLUG");
if (ptr != NULL && strlen(ptr) > 0)
{
strncpy(gBusPlugName, ptr, 16);
gBusPlugName[16] = 0;
}
}
#if defined(WIN32)
BOOL WINAPI DllMain(HINSTANCE hInstDll,DWORD fdwReason,LPVOID lpvReserved)
{
switch (fdwReason)
{
case DLL_PROCESS_ATTACH:
fixBusPlugName();
cdiInitSimulate();
break;
case DLL_THREAD_ATTACH:
break;
case DLL_THREAD_DETACH:
break;
case DLL_PROCESS_DETACH:
break;
}
return (TRUE);
}
#elif defined(UNIX)
__attribute__((constructor)) void cdiSedacMain(void)
{
fixBusPlugName();
cdiInitSimulate();
return;
}
#endif
- Returns
- 0 upon success
◆ cdiRegisterBusInitialization()
CDI_EXPORT int cdiRegisterBusInitialization |
( |
char * |
busName, |
|
|
int(*)(int, int, int, char *) |
fcn |
|
) |
| |
registers a bus initialization function to be used by CDI when initializing the bus.
After the CDI database has been read and processed, CDI will call any bus initialization routines which need to be called, so as to set up the hardware bus for hardware io.
- Parameters
-
busName | is the bus plug name to be used by database entries refering to this bus plug. |
fcn | is the address of the bus initialization function to be called when CDI initializes the bus. The function must have the prototype
int fcn(int busLine, int cdiLine, int numberDevices, char *parameterList)
and return '0' if the initialization was successful. This initialization dispatch function will receive (according to the registered database entries) the bus line number (from the database), the CDI line number (a CDI internal line number), the total number of registered devices, and the parameter list (if any) supplied with the bus registration. |
example:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include <stdarg.h>
#include <math.h>
#include <errno.h>
#include "cdi.h"
#include "tinecdi.h"
#include "cdiSimulateLib.h"
#define BUSPLUG_NAME "SIMULATE"
char gBusPlugName[64] = BUSPLUG_NAME;
int cdiInitSimulate(void)
{
int cc = 0;
if ((cc=cdiRegisterBusFilter(gBusPlugName,filterSimulation)) != 0 ) goto err;
err:
if (cc)
{
cdilog("%s : failure in bus registration SEDPC",erlst[cc]);
}
return cc;
}
void fixBusPlugName(void)
{
char *ptr = getenv("CDI_SIMULATE_PLUG");
if (ptr != NULL && strlen(ptr) > 0)
{
strncpy(gBusPlugName, ptr, 16);
gBusPlugName[16] = 0;
}
}
#if defined(WIN32)
BOOL WINAPI DllMain(HINSTANCE hInstDll,DWORD fdwReason,LPVOID lpvReserved)
{
switch (fdwReason)
{
case DLL_PROCESS_ATTACH:
fixBusPlugName();
cdiInitSimulate();
break;
case DLL_THREAD_ATTACH:
break;
case DLL_THREAD_DETACH:
break;
case DLL_PROCESS_DETACH:
break;
}
return (TRUE);
}
#elif defined(UNIX)
__attribute__((constructor)) void cdiSedacMain(void)
{
fixBusPlugName();
cdiInitSimulate();
return;
}
#endif
- Returns
- 0 upon success
◆ cdiRegisterBusScanner()
CDI_EXPORT int cdiRegisterBusScanner |
( |
char * |
busName, |
|
|
int(*)(char *, char *, int) |
fcn |
|
) |
| |
registers the bus scan function used for CDI diagnostics.
This routine will be called when CDI closes and allows the bus to free up resources, etc.
- Parameters
-
busName | is the bus plug name to be used by database entries refering to this bus plug. |
fcn | is the address of the bus scan function to be called when CDI issues a bus scan. It depends completely on the bus as to what consitutes a scan operation. The function must have the prototype
int fcn(char *target,char *result,int resultBufferSize)
and return '0' if the call was successful. The 'target' will simply be a character string giving the desired scan operation (e.g. 'crates', 'addresses'). The 'result' will likewise be a character string giving the results of the scan. 'resultBufferSize' gives the total string capacity of 'result', so that the bus plug can know note to overwrite the given buffer. |
example:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include <stdarg.h>
#include <math.h>
#include <errno.h>
#include "cdi.h"
#include "tinecdi.h"
#include "cdiSimulateLib.h"
#define BUSPLUG_NAME "SIMULATE"
char gBusPlugName[64] = BUSPLUG_NAME;
int cdiInitSimulate(void)
{
int cc = 0;
if ((cc=cdiRegisterBusFilter(gBusPlugName,filterSimulation)) != 0 ) goto err;
err:
if (cc)
{
cdilog("%s : failure in bus registration SEDPC",erlst[cc]);
}
return cc;
}
void fixBusPlugName(void)
{
char *ptr = getenv("CDI_SIMULATE_PLUG");
if (ptr != NULL && strlen(ptr) > 0)
{
strncpy(gBusPlugName, ptr, 16);
gBusPlugName[16] = 0;
}
}
#if defined(WIN32)
BOOL WINAPI DllMain(HINSTANCE hInstDll,DWORD fdwReason,LPVOID lpvReserved)
{
switch (fdwReason)
{
case DLL_PROCESS_ATTACH:
fixBusPlugName();
cdiInitSimulate();
break;
case DLL_THREAD_ATTACH:
break;
case DLL_THREAD_DETACH:
break;
case DLL_PROCESS_DETACH:
break;
}
return (TRUE);
}
#elif defined(UNIX)
__attribute__((constructor)) void cdiSedacMain(void)
{
fixBusPlugName();
cdiInitSimulate();
return;
}
#endif
- Returns
- 0 upon success
◆ cdiRegisterCalibrationFunction()
CDI_EXPORT int cdiRegisterCalibrationFunction |
( |
char * |
fcnName, |
|
|
double(*)(double) |
fcn |
|
) |
| |
registers a calibration function for use by CDI
Bus actions 'SEND' and 'RECV' send and receive raw data to and from the hardware bus according to the bus format registered with the corresponding device. The raw data can be automatically calibrated (receive) or reverse calibrated (send) by CDI if calibration rules are specified. If the calibration rules are too complex to be dealt with be the systematically known rules set, then one can make use of a calibration function registered via this call.
- Parameters
-
fcnName | is the function name in plain text to be stored in the CDI function library. |
fcn | is the address of the function to be called when the calibation rule is to be used. The function must take a one paramter as input (data type double) and return the calibrated parameter (also as data type double). |
example:
#ifdef WIN32
# define FCN_EXPORT __declspec(dllexport)
#else
# define FCN_EXPORT
#endif
FCN_EXPORT double bit12sgn(double v)
{
short w = (short)v;
short sgn = sgn = (w & 0x0800) == 0 ? 1 : -1;
w &= 0x07ff;
w *= sgn;
return (double)w;
}
FCN_EXPORT double nib2exp(double v)
{
short w = (short)v;
return (double)((w&0xfff) * pow(10,-((short)(w>>12))));
}
void cdiRegisterFunctions(void)
{
}
#if defined(WIN32)
BOOL WINAPI DllMain(HINSTANCE hInstDll,DWORD fdwReason,LPVOID lpvReserved)
{
switch (fdwReason)
{
case DLL_PROCESS_ATTACH:
cdiRegisterFunctions();
break;
case DLL_THREAD_ATTACH:
break;
case DLL_THREAD_DETACH:
break;
case DLL_PROCESS_DETACH:
break;
}
return (TRUE);
}
#elif defined(UNIX)
__attribute__((constructor)) void cdiCalibrateMain(void)
{
cdiRegisterFunctions();
return;
}
#endif
- Returns
- 0 upon success
int hasPatternFilter
Definition: cdi.h:297
short inType
Definition: cdi.h:293
CDI_EXPORT int cdiRegisterDevice(char *devName, int devNumber, char *lngName, char *devDesc, int cdiLine, int cdiIndex, int *cdiAddress, int cdiAddressLength, int *devParameters)
Registers a CDI device.
Definition: cdiTineLib.c:429
int inside
Definition: cdi.h:335
CDI_EXPORT void cdiSetGenerateAlarms(int value)
Determines whether or not CDI will generate bus error alarms.
Definition: cdiTineLib.c:185
short pollFlag
Definition: cdi.h:325
short NgroupsReqs
Definition: cdi.h:314
short lockRequestFlag
Definition: cdi.h:326
BYTE patternFilter[CDI_PATTERN_FILTER_SIZE]
Definition: cdi.h:298
int cdiAddr[CDI_ADDR_SIZE]
Definition: cdi.h:239
int callBackIndex
Definition: cdi.h:287
CDI_EXPORT void cdiSetAllowRemoteManagement(int value)
Turns on/off remote management.
Definition: cdiTineLib.c:112
void * ptrReserved
Definition: cdi.h:339
int freeOutDataMemoryOnCancel
Definition: cdi.h:334
int maskValue
Definition: cdi.h:301
short asynCallFlag
Definition: cdi.h:319
short bufLastData[4]
Definition: cdi.h:322
int * perror
Definition: cdi.h:323
int dataOuput2ndSize
Definition: cdi.h:252
short conditionFlag
Definition: cdi.h:309
CDI Request Information Block structure.
Definition: cdi.h:284
BYTE mask[8]
Definition: cdi.h:300
int needsCalibration
Definition: cdi.h:310
short accessFlag
Definition: cdi.h:308
void * pBlockBuffer
Definition: cdi.h:336
int registerTime
Definition: cdi.h:304
int pollTime
Definition: cdi.h:306
sem_t sync_SemId
Definition: cdi.h:329
short NgroupRets
Definition: cdi.h:315
CDI_EXPORT char * cdiGetVersionAsString(void)
Returns the CDI library version as string.
Definition: cdiTineLib.c:166
CdiRule * rvrsRules
Definition: cdi.h:260
unsigned int outLength
Definition: cdi.h:292
int cdiIndex
Definition: cdi.h:236
CdiDeviceInfoBlk * pDev
Definition: cdi.h:288
CDI_EXPORT void cdiSetHardwareAlarmThreshold(int value)
Sets the number of bus io errors which are tolerated before setting a hardware error alarm.
Definition: cdiTineLib.c:189
void * pInData
Definition: cdi.h:289
short userCallDown
Definition: cdi.h:327
char devName[CDI_DEVICE_NAME_SIZE]
Definition: cdi.h:235
CDI_EXPORT int cdiExecLinkEx(char *devName, char *devProperty, DTYPE *dout, DTYPE *din, short access, UINT16 timeout)
Directly executes a synchronous CDI link.
Definition: cdiTineLib.c:895
short groupSyncStart
Definition: cdi.h:317
CDI_EXPORT int cdiRegisterBusScanner(char *busName, int(*fcn)(char *, char *, int))
registers the bus scan function used for CDI diagnostics.
Definition: cdi.c:4089
CDI_EXPORT void SetDefaultQueryPollingInterval(int value)
Sets the default polling interval for local queries.
Definition: cdiTineLib.c:3536
int freeInDataMemoryOnCancel
Definition: cdi.h:333
int dataFormat
Definition: cdi.h:253
void * pOutData
Definition: cdi.h:291
CDI_EXPORT int cdiAttachLinkEx(char *devName, char *devProperty, DTYPE *dout, DTYPE *din, short access, int pollingRate, void(*callback)(int, int), int mode, UINT32 callbackID)
Initiates an asynchronous CDI link.
Definition: cdiTineLib.c:1055
BYTE cpOutData[DEF_INPUT_BYTES]
Definition: cdi.h:321
char description[CDI_DEVICE_DESC_SIZE]
Definition: cdi.h:262
int hasDataMask
Definition: cdi.h:299
short NgrpErrors
Definition: cdi.h:316
void(* callback)(int, int)
Definition: cdi.h:332
int bufIndex
Definition: cdi.h:331
int deviceError
Definition: cdi.h:320
int dataPatternStopIndex
Definition: cdi.h:247
CDI_EXPORT int cdiRegisterBusInitialization(char *busName, int(*fcn)(int, int, int, char *))
registers a bus initialization function to be used by CDI when initializing the bus.
Definition: cdi.c:3940
int requestTime
Definition: cdi.h:305
float minimum
Definition: cdi.h:264
int reqIndex
Definition: cdi.h:312
int devReadyTime
Definition: cdi.h:337
int iReserved
Definition: cdi.h:257
void * pcdiLine
Definition: cdi.h:238
int allowedAccess
Definition: cdi.h:255
BYTE * dataMask
Definition: cdi.h:242
sem_t exec_SemId
Definition: cdi.h:330
int dataMaskStopIndex
Definition: cdi.h:244
short cancelFlag
Definition: cdi.h:328
int * devParameters
Definition: cdi.h:241
int interval
Definition: cdi.h:256
short inFormatCode
Definition: cdi.h:295
char units[CDI_UNITS_SIZE]
Definition: cdi.h:266
BYTE * dataPattern
Definition: cdi.h:245
short dataReturnCondition
Definition: cdi.h:318
CDI_EXPORT int cdiRegisterBusHandler(char *busName, void(*fcn)(CdiRequestInfoBlk *))
registers the bus handler dispatch function used for bus io.
Definition: cdi.c:4024
int numberDeviceError
Definition: cdi.h:240
CDI_EXPORT int cdiInitialize(void)
initializes CDI
Definition: cdiTineLib.c:174
int requestCounter
Definition: cdi.h:307
char * extName
Definition: cdi.h:258
int dataOuputSize
Definition: cdi.h:251
CDI_EXPORT int cdiRegisterBusCleanup(char *busName, int(*fcn)(int))
registers the bus cleanup function used when CDI closes.
Definition: cdi.c:4038
int dataMaskStartIndex
Definition: cdi.h:243
void * groupReq
Definition: cdi.h:313
CDI_EXPORT int cdiGetHardwareAlarmThreshold(void)
Gets the number of bus io errors which are tolerated before setting a hardware error alarm.
Definition: cdiTineLib.c:195
int responseTime
Definition: cdi.h:324
int reqFormat
Definition: cdi.h:254
BYTE * dataInput
Definition: cdi.h:249
short outFormatCode
Definition: cdi.h:296
int devNumber
Definition: cdi.h:237
int requestNumber
Definition: cdi.h:311
float maximum
Definition: cdi.h:263
int active
Definition: cdi.h:286
int dataPatternStartIndex
Definition: cdi.h:246
CDI_EXPORT int cdiSetExportName(char *expName)
Sets the exported TINE device server name to the value given.
Definition: cdiTineLib.c:3209
CdiRule * clbrRules
Definition: cdi.h:259
int dataPatternTrigger
Definition: cdi.h:248
unsigned int inLength
Definition: cdi.h:290
char lngName[CDI_DEVICE_LONGNAME_SIZE]
Definition: cdi.h:261
int devParameters[NUMBER_EXEC_PARAM]
Definition: cdi.h:302
int dataInputSize
Definition: cdi.h:250
char precision[CDI_UNITS_SIZE]
Definition: cdi.h:265
int timeout
Definition: cdi.h:303
short outType
Definition: cdi.h:294
CDI_EXPORT BYTE * cdiVersion(void)
Returns the CDI library version as byte array.
Definition: cdiTineLib.c:159
CDI_EXPORT int cdiRegisterCalibrationFunction(char *fcnName, double(*fcn)(double))
registers a calibration function for use by CDI
Definition: cdi.c:4103
CDI Device Information Block structure.
Definition: cdi.h:233
int nerrors
Definition: cdi.h:338
Impressum
|
Imprint
|
Datenschutzerklaerung
|
Data Privacy Policy
|
Declaration of Accessibility
|
Erklaerung zur Barrierefreiheit
Generated for TINE API by
1.5.8