This repository has been archived by the owner on Aug 31, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 18
/
extApiPlatform.h
89 lines (78 loc) · 3.55 KB
/
extApiPlatform.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
#ifndef _EXTAPIPLATFORM__
#define _EXTAPIPLATFORM__
#ifdef __cplusplus
extern "C" {
#endif
#ifdef _WIN32
/* on older win compilers stdint.h can be missing */
typedef unsigned char uint8_t;
typedef short int16_t;
typedef unsigned short uint16_t;
typedef int int32_t;
typedef unsigned int uint32_t;
#else
#include <stdint.h>
#endif
#define SOCKET_MAX_PACKET_SIZE 1300 /* in bytes. Keep between 200 and 30000 */
#define SOCKET_HEADER_LENGTH 6 /* WORD0=1 (to detect endianness), WORD1=packetSize, WORD2=packetsLeftToRead */
#define SOCKET_TIMEOUT_READ 10000 /* in ms */
typedef char simxChar; /* always 1 byte */
typedef uint8_t simxUChar; /* always 1 byte */
typedef int16_t simxShort; /* always 2 bytes */
typedef uint16_t simxUShort; /* always 2 bytes */
typedef int32_t simxInt; /* always 4 bytes */
typedef uint32_t simxUInt; /* always 4 bytes */
typedef float simxFloat; /* always 4 bytes */
typedef double simxDouble; /* always 8 bytes */
typedef void simxVoid;
#ifdef _WIN32
#define SIMX_THREAD_RET_TYPE simxVoid
#define SIMX_THREAD_RET_LINE return
#elif defined (__linux) || defined (__APPLE__)
#define SIMX_THREAD_RET_TYPE simxVoid*
#define SIMX_THREAD_RET_LINE return(0)
#endif
/* Following functions only needed for testing endianness robustness */
simxShort extApi_endianConversionShort(simxShort shortValue);
simxUShort extApi_endianConversionUShort(simxUShort shortValue);
simxInt extApi_endianConversionInt(simxInt intValue);
simxFloat extApi_endianConversionFloat(simxFloat floatValue);
simxDouble extApi_endianConversionDouble(simxDouble floatValue);
/* Following functions might be platform specific */
simxFloat extApi_getFloatFromPtr(const simxUChar* ptr);
simxInt extApi_getIntFromPtr(const simxUChar* ptr);
simxUChar* extApi_allocateBuffer(simxInt bufferSize);
simxVoid extApi_releaseBuffer(simxUChar* buffer);
simxVoid extApi_createMutexes(simxInt clientID);
simxVoid extApi_deleteMutexes(simxInt clientID);
simxVoid extApi_lockResources(simxInt clientID);
simxVoid extApi_unlockResources(simxInt clientID);
simxVoid extApi_lockSendStart(simxInt clientID);
simxVoid extApi_unlockSendStart(simxInt clientID);
simxVoid extApi_createGlobalMutex();
simxVoid extApi_deleteGlobalMutex();
simxVoid extApi_globalSimpleLock();
simxVoid extApi_globalSimpleUnlock();
simxInt extApi_getTimeInMs();
simxInt extApi_getTimeDiffInMs(simxInt lastTime);
simxVoid extApi_initRand();
simxFloat extApi_rand();
simxVoid extApi_sleepMs(simxInt ms);
simxVoid extApi_switchThread();
simxUChar extApi_areStringsSame(const simxChar* str1,const simxChar* str2);
simxInt extApi_getStringLength(const simxChar* str);
simxUChar* extApi_readFile(const simxChar* fileName,simxInt* len);
simxUChar extApi_launchThread(SIMX_THREAD_RET_TYPE (*startAddress)(simxVoid*));
simxVoid extApi_endThread();
simxUChar extApi_connectToServer_socket(simxInt clientID,const simxChar* theConnectionAddress,simxInt theConnectionPort);
simxVoid extApi_cleanUp_socket(simxInt clientID);
simxInt extApi_send_socket(simxInt clientID,const simxUChar* data,simxInt dataLength);
simxInt extApi_recv_socket(simxInt clientID,simxUChar* data,simxInt maxDataLength);
simxUChar extApi_connectToServer_sharedMem(simxInt clientID,simxInt theConnectionPort);
simxVoid extApi_cleanUp_sharedMem(simxInt clientID);
simxInt extApi_send_sharedMem(simxInt clientID,const simxUChar* data,simxInt dataLength);
simxUChar* extApi_recv_sharedMem(simxInt clientID,simxInt* dataLength);
#ifdef __cplusplus
}
#endif
#endif /* _EXTAPIPLATFORM__ */