165 lines
3.1 KiB
C
165 lines
3.1 KiB
C
![]() |
|
|||
|
|
|||
|
#ifndef USUAL_DEFINES_INCLUDED
|
|||
|
#define USUAL_DEFINES_INCLUDED
|
|||
|
|
|||
|
|
|||
|
#ifdef __cplusplus
|
|||
|
extern "C" {
|
|||
|
#endif
|
|||
|
/************************************************************************/
|
|||
|
|
|||
|
//MMS<4D><53><EFBFBD>У<EFBFBD>һЩ<D2BB><D0A9><EFBFBD><EFBFBD>ͷ<EFBFBD>ļ<EFBFBD><C4BC><EFBFBD>Ҳ<EFBFBD>ǽ<EFBFBD><C7BD><EFBFBD><EFBFBD>õ<EFBFBD><C3B5><EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD>Ű<EFBFBD><C5B0><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ȱ<EFBFBD><C8B0><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
|||
|
#include "glbtypes.h"
|
|||
|
|
|||
|
#include "sysincs.h"
|
|||
|
//#if defined (_WIN32)
|
|||
|
// #include <stdio.h>
|
|||
|
// #include <windows.h>
|
|||
|
//#elif defined (linux)
|
|||
|
// #include <stdio.h>
|
|||
|
// #include <string.h>
|
|||
|
// #include <unistd.h>
|
|||
|
// #include <sys/types.h>
|
|||
|
// #include <sys/stat.h>
|
|||
|
// #include <sys/ioctl.h>
|
|||
|
// #include <sys/time.h>
|
|||
|
//
|
|||
|
// #include <sys/socket.h>
|
|||
|
// #include <netinet/in.h>
|
|||
|
// #include <arpa/inet.h>
|
|||
|
// #include <netdb.h>
|
|||
|
// #include <net/if.h>
|
|||
|
//
|
|||
|
// #include <fcntl.h>
|
|||
|
//
|
|||
|
//#elif defined (VXWORKS)
|
|||
|
// #include "vxWorks.h"
|
|||
|
// #include "logLib.h"
|
|||
|
// #include "taskLib.h"
|
|||
|
//#endif
|
|||
|
|
|||
|
|
|||
|
#ifdef VXWORKS
|
|||
|
|
|||
|
|
|||
|
#define PRINT_PARA_6 ,1,2,3,4,5,6
|
|||
|
#define PRINT_PARA_5 ,2,3,4,5,6
|
|||
|
#define PRINT_PARA_4 ,3,4,5,6
|
|||
|
#define PRINT_PARA_3 ,4,5,6
|
|||
|
#define PRINT_PARA_2 ,5,6
|
|||
|
#define PRINT_PARA_1 ,6
|
|||
|
|
|||
|
#define PRINT_CHAR_TYPE (int)
|
|||
|
|
|||
|
#else
|
|||
|
#define PRINT_PARA_6 /*NONE*/
|
|||
|
|
|||
|
#define PRINT_PARA_5 /*NONE*/
|
|||
|
|
|||
|
#define PRINT_PARA_4 /*NONE*/
|
|||
|
|
|||
|
#define PRINT_PARA_3 /*NONE*/
|
|||
|
|
|||
|
#define PRINT_PARA_2 /*NONE*/
|
|||
|
|
|||
|
#define PRINT_PARA_1 /*NONE*/
|
|||
|
|
|||
|
#define PRINT_CHAR_TYPE /*NONE*/
|
|||
|
|
|||
|
|
|||
|
#endif
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
/***<2A><>Сʱ<D0A1>䣬<EFBFBD><E4A3AC><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD>䷭ת<E4B7AD><D7AA>ʱ<EFBFBD><CAB1>****/
|
|||
|
#define GET_SYSTEM_MIN_TIME_MS 20
|
|||
|
|
|||
|
|
|||
|
/*******<2A><>ʱ<EFBFBD>жϺ<D0B6><CFBA><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Լ<EFBFBD><D4BC><EFBFBD><EFBFBD><EFBFBD>,x <20><>ǰʱ<C7B0><CAB1>*********** || x < GET_SYSTEM_MIN_TIME_MS **/
|
|||
|
#define GET_MS_CHECK_TIMEOUT(x,y) ( (y) && (x > y ) )
|
|||
|
|
|||
|
|
|||
|
|
|||
|
#if defined _WIN32 || defined linux
|
|||
|
|
|||
|
/******<2A><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ********/
|
|||
|
#define PRINT_ERROR printf("\n[File: %s\tLine: %u]\n",__FILE__, __LINE__); printf
|
|||
|
/******<2A><><EFBFBD><EFBFBD>һ<EFBFBD><D2BB><EFBFBD><EFBFBD>¼<EFBFBD><C2BC>Ϣ**********/
|
|||
|
#define PRINT_LOG printf
|
|||
|
|
|||
|
#elif defined VXWORKS
|
|||
|
|
|||
|
/******<2A><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ********/
|
|||
|
#define PRINT_ERROR logMsg("\n[File: %s\tLine: %u]\n",(int)(void *)(__FILE__), __LINE__,3,4,5,6); logMsg
|
|||
|
/******<2A><><EFBFBD><EFBFBD>һ<EFBFBD><D2BB><EFBFBD><EFBFBD>¼<EFBFBD><C2BC>Ϣ**********/
|
|||
|
#define PRINT_LOG logMsg
|
|||
|
|
|||
|
#endif
|
|||
|
|
|||
|
#define USE_PROTDB_CFG //<2F>ӿڳ<D3BF><DAB3><EFBFBD>ʹ<EFBFBD>õ<EFBFBD><C3B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ٴӽӿڿ⣨commdb.sql3<6C><33><EFBFBD>ж<EFBFBD>ȡ,<2C><><EFBFBD>Ǵӱ<C7B4><D3B1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ÿ⣨protdb.sql3<6C><33><EFBFBD>ж<EFBFBD>ȡ
|
|||
|
|
|||
|
/******************<2A><><EFBFBD>õ<EFBFBD>UNION**************************/
|
|||
|
typedef union
|
|||
|
{
|
|||
|
ST_UINT16 unsing_short;
|
|||
|
ST_INT16 sing_short;
|
|||
|
struct{
|
|||
|
|
|||
|
#if SD_BYTE_ORDER==SD_LITTLE_ENDIAN /* little-endian (like Intel) */
|
|||
|
ST_UCHAR lowByte0;
|
|||
|
ST_UCHAR lowByte1;
|
|||
|
#elif SD_BYTE_ORDER==SD_BIG_ENDIAN
|
|||
|
ST_UCHAR lowByte1;
|
|||
|
ST_UCHAR lowByte0;
|
|||
|
#else
|
|||
|
#error UnDefine BYTE_PRDER
|
|||
|
#endif
|
|||
|
|
|||
|
} buffChar;
|
|||
|
} UNION_SHORT;
|
|||
|
|
|||
|
|
|||
|
typedef union
|
|||
|
{
|
|||
|
ST_FLOAT sing_float;
|
|||
|
ST_INT32 sing_int;
|
|||
|
ST_UINT32 unsing_int;
|
|||
|
|
|||
|
struct{
|
|||
|
|
|||
|
#if SD_BYTE_ORDER==SD_LITTLE_ENDIAN /* little-endian (like Intel) */
|
|||
|
ST_UCHAR lowByte0;
|
|||
|
ST_UCHAR lowByte1;
|
|||
|
ST_UCHAR lowByte2;
|
|||
|
ST_UCHAR lowByte3;
|
|||
|
#elif SD_BYTE_ORDER==SD_BIG_ENDIAN /* sun or vxworks etc */
|
|||
|
ST_UCHAR lowByte3;
|
|||
|
ST_UCHAR lowByte2;
|
|||
|
ST_UCHAR lowByte1;
|
|||
|
ST_UCHAR lowByte0;
|
|||
|
#else
|
|||
|
#error UnDefine BYTE_PRDER
|
|||
|
#endif
|
|||
|
|
|||
|
} buffChar;
|
|||
|
|
|||
|
// <09><>ֹ<EFBFBD><D6B9><EFBFBD>ȳ<EFBFBD><C8B3>Ȳ<EFBFBD>Ϊ4
|
|||
|
// struct{
|
|||
|
// UNION_SHORT short_low;
|
|||
|
// UNION_SHORT short_high;
|
|||
|
// } union_short;
|
|||
|
} UNION_FLOAT;
|
|||
|
|
|||
|
|
|||
|
/************************************************************************/
|
|||
|
#ifdef __cplusplus
|
|||
|
}
|
|||
|
#endif
|
|||
|
|
|||
|
|
|||
|
#endif
|