📄 inc.h
字号:
/******************************************************************************
This head file is used to define sth global.
*******************************************************************************
***/
#ifndef _LOCAL_H
#define _LOCAL_H
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <termios.h>
#include <stdio.h>
#include <errno.h>
#include "sfl.h"
#include "mbbase.h"
#include <sys/ipc.h>
#include <sys/shm.h>
#include <signal.h>
#include <fcntl.h>
#include <unistd.h>
#include <time.h>
#include <errno.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <sys/socket.h> /* for socket(), connect(), sendto(), and recvfrom() */
#include <sys/ioctl.h>
#include <net/if.h>
#include <net/if_arp.h>
#include <arpa/inet.h> /* for sockaddr_in and inet_addr() */
#define TRUE 1
#define FALSE 0
typedef unsigned char BYTE;
/******************************************************
PART 1 Share Memory of each Proc
*******************************************************
***/
#define ROOT_SHAREMEM_KEY 0xFFFFFF00 //share mem key
#define PROCID_GUARD 0x00 //Proc ID of guard,to guard the others proc
#define PROCID_GPS 0x01 //Proc ID of GPSnSpeakStation
#define PROCID_FTP 0x02 //Proc ID of FTP,to download media and SpeakStation file
#define PROCID_KEYB 0x03 //Proc ID of KeyB,to handle the driver's KeyBoard
#define PROCID_MEDIA 0x04 //Proc ID of Media,to play the media file
#define PROCID_DISPATCH 0x05 //Proc ID of Dispatch,to remote control through GSM/CDMA]
#define PROCID_LOG 0x06 //Proc ID of Log
#define PROC_NUMBERS 7
typedef struct
{
pid_t PID; //pid of the proc
time_t ctime; //the time of last change
} Pid_Info;
typedef struct
{
unsigned long longitude; //经度(ms),4字节,1度=60分=3600秒=3600*1000ms.
unsigned long latitude; //纬度(ms),4字节
unsigned short speed; //水平速度(0.1km/h) 2字节
unsigned short direction; //方向(0.1度),正北为0,顺时针方向递增 2字节
time_t datetime; //GMT 时间,since 1970.1.1 00:00:00
unsigned char amount; //当前卫星数(0-12),可选值。 1字节
unsigned char valid; //GPS是否有效,A有效,V无效
unsigned short hpop; //水平几何因子,可选值,2字节,取值(0.5~99.9),发送值=原值*10
unsigned short hpe; //水平误差因子,可先值,2 字节,取值(0.5~999.0),发送值
} GPSDataStruct;
typedef struct
{
Pid_Info Proc_Info;
int NetState; //netcard state: 0 normal
int HddState; //HardDisk state: 0 normal
int FtpState; //FtpServer State: 0 normal
char WlanIP[16]; //Wlan ip address : ***.***.***.***
char ServerIP[16]; //FTP server ip address:***.***.***.***
} Guard_Info;
typedef struct
{
Pid_Info Proc_Info;
unsigned int ComStatus; //32 bits corresponds a serial state
GPSDataStruct GPSData; //GPS data collection
unsigned short StationID; //Current Station ID
unsigned char StationName[31]; //Current Station Name,Chinese in GB
unsigned char NextStationName[31]; //Next Station Name,Chinese in GB
unsigned char StationState; //Boolean ,to show if the station is inside of the stop area 0-in 1-out
char SpeakType; // 'A' : auto speakstation ; 'M' : manly speakstation
char LineID[9]; //Curretn Bus LineID
unsigned char PowerOff; //0 : Power On ; 1 : Power Off
} GPS_Info;
typedef struct
{
Pid_Info Proc_Info;
unsigned short FTPState; //to show if the device is downloading files
} FTP_Info;
typedef struct
{
Pid_Info Proc_Info;
} KeyB_Info;
typedef struct
{
Pid_Info Proc_Info;
} Media_Info;
typedef struct
{
Pid_Info Proc_Info;
unsigned short CarState; //16bits, each bit corresponds a kind of car states
unsigned char CommState; //0 : not connected to server;1 : has connected to server
char CenterAddr[22]; //Bus center IP address and Port number
} Dispatch_Info;
typedef struct
{
Pid_Info Proc_Info;
char LogFile[128]; //the filename of logfile
} Log_Info;
void *IPC_ProcState_Init(key_t key,int flag);
int IPC_ProcState_Read(key_t key,void *pShareMem,void *pData);
int IPC_ProcState_Write(key_t key,void *pShareMem,void *pData);
int LockFile(int fd,int cmd);
/******************************************************
PART 2 Application Msg Queue
*******************************************************
***/
#define MSG_QUEUE_KEY 0xFFFFFF00
typedef struct
{
long DestProc; //the Proc_ID you want to send
unsigned char Data[128]; //the Data you want to send
} AppMsg;
int MSGQ_Init(void);
void MSGQ_Clear(key_t key);
int MSGQ_Send(key_t key,void *data,int datalen);
int MSGQ_Read(key_t key,void *data);
extern int ReceiveMsgQ;
void Sig_Handle(int signo);
void Signal_Init(void);
/******************************************************
PART 3 ComStatus Define
*******************************************************
***/
#define COM_DSR_SET TIOCM_DSR
#define COM_DTR_SET TIOCM_DTR
#define COM_CTS_SET TIOCM_CTS
#define COM_RTS_SET TIOCM_RTS
/******************************************************
PART 4 Config file config.ini access
*******************************************************
***/
//#define SYS_CONFIGFILE
void IniSave(char *Section,char *Key,char *Value);
void *IniLoad(char *Section,char *key,char *defaultval);
#endif /* _LOCAL_H */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -