www.pudn.com > webserver.zip > seria.h, change:2011-11-17,size:3108b


#ifndef __SERIAL_H__ 
#define __SERIAL_H__ 
//#include <stm32f10x_cl.h> 
#include <stdio.h> 
#include <string.h> 
#include <RTL.h> 
#include "stm32f10x.h" 
#include <Net_Config.h> 
#define RX_BUF          4     
#define BUF_SIZE        2500 
#define NO_BUF          0xff    
#define OWN 1 
#define NOOWN 0   
#define ZERO 0  
 
#define COM1	0 
#define COM2	1 
#define COM3	2 
#define COM4	3 
#define COM5	4 
#define COM6	5 
#define COM7	6 
#define COM8	7 
#define RELAYTIME 20	//命令间隔时间 
#define COMMAX 8 
#define REAL_COMMAX 4 
#define TCP_NUMSOCKS   10//tcp最大连接数 
 
#define TCP_SERVER_MODE	  0 
#define TCP_CLIENT_MODE	  1 
#define TCP_UDP_MODE	  2 
 
#define VER1 0x01 
#define VER2 0x16  
 
#define NUML  '4' 
#define NUMH  '0' 
 
enum statu {FREE,START,COMPLETE}; 
enum did {DIVIDE,NODIVIDE}; 
enum freeflag {FREEFLAG,NOFREEFLAG}; 
struct re_st{				   //串口信息体 
  u8 re_buf[BUF_SIZE]; 
  vu16 relen; 
  enum statu state; 
  vu16 num;					  
  vu16 own;					 //缓冲区占有标志 
  enum did divide;			 //数据包分割标志 
}; 
 
struct buf_st  {		   	 //网络信息体 
  vu16 ip_port; 
  u8* tx_buf; 
  u8* sendbuf; 
  vu16 tx_len; 
  vu16 tx_num; 
  vu16 socket; 
  vu16 usocket; 
  U8 rip[4]; 
  u16 rport; 
  vu16 num; 
  vu16 own; 
  enum freeflag freest; 
}; 
 
typedef __packed struct   //客户端模式信息体 
{	vu16 net_type[4];		//模式 
	vu32 rip[4];   		//远端主机ip地址 
	vu16 rport[4]; 		//远端主机端口 
	vu32 reserve[4];    //预留 
}client_struct;  
 
typedef __packed struct  
{	vu16   Baud;    // 9600 
	vu16   Parity;   //串口奇偶校验位 
	vu16   WordLength;     //串口数据位 
	vu16   StopBits;    //串口停止位 
}ComConfigStruct;  
 
typedef struct 
{struct buf_st	ro_com_buf[COMMAX]; 
ComConfigStruct ro_ComConfig[COMMAX]; 
LOCALM	ro_localm; 
u8 ro_own_hw_adr[ETH_ADRLEN]; 
u16  ro_state;	//falsh数据完整性标志 
u8 b[26]; //设备型号及名称 
u16 active_time; 
client_struct  ro_client_data; 
}ro_data; 
 
typedef __packed struct 
{u8 id[2];	//软件版本 
u8 active_time; 
u8 x; 
u8 re_ip[4];  
u8 a[4];  
u8 ro_own_hw_adr[ETH_ADRLEN]; 
u8 ip[12]; 
u8 b[26]; 
u16 port[4]; 
ComConfigStruct ro_ComConfig[4]; 
u8 e[2]; 
u8 reserve[2]; 
client_struct  ro_client_data; 
}INFO; 
/*typedef  __packed struct  {           
   U8 IpAdr[IP_ADRLEN];            
   U8 DefGW[IP_ADRLEN];            
   U8 NetMask[IP_ADRLEN];          
}ip_info; */ 
extern const U8 COMNUM; 
extern struct buf_st com_buf[]; 
//extern ComConfigStruct ComConfig[]; 
extern struct re_st se_buf[RX_BUF]; 
extern u8 combufnum[]; 
extern U8       own_hw_adr[]; 
extern u8 client_timeover_flag; 
extern u8 gateway_timeover_flag; 
extern u32  rx_lenth[]; 
extern u32  tx_lenth[]; 
void COM_init(void); 
void send_data(void); 
extern  LOCALM localm[]; 
extern struct tcp_info tcp_socket[]; 
extern INFO * info; 
void set_at_time(void); 
extern void pra_change_pro(void); 
extern void client_time_pro(void); 
extern void gateway_time_pro(void); 
extern void reset_pra(void); 
#define Type(x) info->ro_client_data.net_type[x] 
#define Rip(x)	(u8*)&info->ro_client_data.rip[x] 
#define Rport(x)	info->ro_client_data.rport[x] 
#endif