commCPU_SUPV/code/general/inc/general_defines.h
2025-04-30 16:24:29 +08:00

165 lines
3.1 KiB
C
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#ifndef USUAL_DEFINES_INCLUDED
#define USUAL_DEFINES_INCLUDED
#ifdef __cplusplus
extern "C" {
#endif
/************************************************************************/
//MMS库中一些基本头文件也是仅在用到的时候才包含在这里先包含了
#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
/***最小时间,用于在时间翻转的时候****/
#define GET_SYSTEM_MIN_TIME_MS 20
/*******超时判断函数,自己定义,x 当前时间*********** || x < GET_SYSTEM_MIN_TIME_MS **/
#define GET_MS_CHECK_TIMEOUT(x,y) ( (y) && (x > y ) )
#if defined _WIN32 || defined linux
/******输出错误信息********/
#define PRINT_ERROR printf("\n[File: %s\tLine: %u]\n",__FILE__, __LINE__); printf
/******输出一般记录信息**********/
#define PRINT_LOG printf
#elif defined VXWORKS
/******输出错误信息********/
#define PRINT_ERROR logMsg("\n[File: %s\tLine: %u]\n",(int)(void *)(__FILE__), __LINE__,3,4,5,6); logMsg
/******输出一般记录信息**********/
#define PRINT_LOG logMsg
#endif
#define USE_PROTDB_CFG //接口程序使用的配置项不再从接口库commdb.sql3中读取,而是从保护配置库protdb.sql3中读取
/******************有用的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;
// 防止长度长度不为4
// struct{
// UNION_SHORT short_low;
// UNION_SHORT short_high;
// } union_short;
} UNION_FLOAT;
/************************************************************************/
#ifdef __cplusplus
}
#endif
#endif