通信编程总结

本文主要总结了通信编程中如何通过解析控制域的bit位来确定帧类型,讲解了不同帧在通信过程中的作用。
摘要由CSDN通过智能技术生成

通信编程总结

#include<stdio.h>
#include<stdlib.h>
enum protocal_name_t
{
	TCP = 0,
	local,
};

//通道所挂载的协议
struct commmunication_protocal_list_t
{
	enum protocal_name_t protocal_name; //协议名称
	int  communication_root_id;//协议通道挂载的文件id
	struct communication_protocal_list_t *next;
};
//通信时:每个通信通道都必须的数据结构
struct communication_root_data_t
{
	int *frame; //帧的长度
	int root_id;//用来区分是哪个通信通道
	struct communication_protocal_list_t *communication_protocal_list;//各个通信通道所挂载的协议 
	int *data_buf;//底层串口真正的buf长度
};
struct communication_root_data_t *communication_root_data = 0;

//每个协议具体的配置:初始化,发送,解析,处理
struct protocal_concrete_config_t
{
	struct communication_protocal_list_t *(*init) (struct communication_root_data_t *communication_root_data);
	int(*send) (struct communication_root_data_t *communication_root_data);
	int(*parse) (struct communication_root_data_t *communication_root_data);
	int(*process) (struct communication_root_data_t *communication_root_data);
};
struct protocal_cfg_t
{
	struct protocal_concrete_config_t  *protocal_concrete_config;//具体的协议
	int *clint;//每个协议对应的客户端 
};

int  clint[] = { 0x10,0x20,0x30,0x40,0x50 };
int  clint1[] = { 0x20,0x30,0x40,0x50,0x60,0x70};//TCP和本地协议的客户端


struct communication_protocal_list_t * init(struct c
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
1. RS-232-C 详解………………………………………………………2 2. 串口通信基本接线方法………………………………………………12 3. 串口通讯的概念及接口电路…………………………………………13 4. 有关 RS232和RS485接口的问答……………………………………14 5. 同步通信方式…………………………………………………………16 6. 通信协议…………………………………………………………………19 7. 实战串行通讯……………………………………………………………25 8. 全双工和半双工方式…………………………………………………33 9. 浅析 PC 机串口通讯流控制……………………………………………34 10. 奇偶校验 ………………………………………………………………35 11. 开发通信软件的技术与技巧…………………………………………36 12. 接口技术的基本知识…………………………………………………41 13. 一个单片机串行数据采集/传输模块的设计…………………………44 14. 单工、半双工和全双工的定义………………………………………48 15. 从 RS232 端口获得电源…………………………………………………49 16. 串行同步通信的应用……………………………………………………50 17. 串行通信波特率的一种自动检测方法…………………………………53 18. RS-232、RS-422 与RS-485 标准及应用………………………………56 19. 串口泵…………………………………………………………………64
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值