实用数据处理

#include <stdio.h>

typedef   unsigned char     BOOL_T; 
typedef   unsigned char     U8_T; 
typedef   signed   char     S8_T; 
typedef   unsigned short    U16_T; 
typedef   signed   short    S16_T; 
typedef   unsigned int      U32_T; 
typedef   signed   int      S32_T;
typedef   unsigned long long  U64_T;
typedef   long long         S64_T;
typedef   float             F32_T; 
typedef   double            F64_T; 
typedef   char *            STR_T;

#define  DATA_TYPE_U8   0
#define  DATA_TYPE_U16  1
#define  DATA_TYPE_U32  2
#define  DATA_TYPE_F32  3

typedef struct
{
	U8_T  u8_value1; 
	U32_T u32_value2; 
	U8_T  u8_value3; 
	U32_T u32_value4; 
	S32_T s32_value5; 
	U8_T  u8_value6; 
}REAL_T;

typedef struct
{
	void *value;
	U8_T type; 
}INFO_T;

static REAL_T m_t_real1, m_t_real2;

static INFO_T m_t_info1[] = 
{
	{&m_t_real1.u8_value1, 			DATA_TYPE_U8},	
	{&m_t_real1.u32_value2, 		DATA_TYPE_U32},
	{&m_t_real1.u8_value3, 			DATA_TYPE_U8},
	{&m_t_real1.u32_value4, 		DATA_TYPE_U32},
	{&m_t_real1.s32_value5, 		DATA_TYPE_U32},
	{&m_t_real1.u8_value6, 			DATA_TYPE_U8},
	
};

static INFO_T m_t_info2[] = 
{
	{&m_t_real2.u8_value1, 			DATA_TYPE_U8},	
	{&m_t_real2.u32_value2, 		DATA_TYPE_U32},
	{&m_t_real2.u8_value3, 			DATA_TYPE_U8},
	{&m_t_real2.u32_value4, 		DATA_TYPE_U32},
	{&m_t_real2.s32_value5, 		DATA_TYPE_U32},
	{&m_t_real2.u8_value6, 			DATA_TYPE_U8},
	
};

typedef struct
{
	INFO_T *t_info;
}PACKET_T;

static PACKET_T m_t_paket[]= 
{	
	{m_t_info1},
	{m_t_info2},
	
}; 

int main(int argc, char *argv[])
{
	unsigned char i;
	INFO_T *t_info;
	
	m_t_real1.u8_value1 = 1;
	m_t_real1.u32_value2 = 0x0AABBCCDD;
	m_t_real1.u8_value3 = 0x02;
	m_t_real1.u32_value4 = 0xFFFFAADD;
	m_t_real1.s32_value5 = 123;
	m_t_real1.u8_value6 = 11;
	
	m_t_real2.u8_value1 = 4;
	m_t_real2.u32_value2 = 0x0CCBBCCFF;
	m_t_real2.u8_value3 = 0x02;
	m_t_real2.u32_value4 = 0xAAFFAADD;
	m_t_real2.s32_value5 = 333;
	m_t_real2.u8_value6 = 123;
	
	printf("**********m_t_info1***********\r\n");
	for (i = 0; i < 6; i++)
	{
		if (m_t_info1[i].type == DATA_TYPE_U8) 
			printf("U8_T value = %x\n", *((U8_T*)(m_t_info1[i].value)));
		else if (m_t_info2[i].type == DATA_TYPE_U32) 
			printf("U32_T value = %x \n", *((U32_T*)(m_t_info1[i].value)));
	
	}
	
	printf("**********m_t_info2***********\r\n");
	for (i = 0; i < 6; i++)
	{
		if (m_t_info2[i].type == DATA_TYPE_U8) 
			printf("U8_T value = %x\n", *((U8_T*)(m_t_info2[i].value)));
		else if (m_t_info2[i].type == DATA_TYPE_U32) 
			printf("U32_T value = %x \n", *((U32_T*)(m_t_info2[i].value)));
	
	}
	
#if 1	
	printf("**********t_info1***********\r\n");
	t_info = m_t_paket[0].t_info;
	for (i = 0; i < 6; i++)
	{
		if (t_info[i].type == DATA_TYPE_U8) 
			printf("U8_T value = %x\n", *((U8_T*)(t_info[i].value)));
		else if (t_info[i].type == DATA_TYPE_U32) 
			printf("U32_T value = %x \n", *((U32_T*)(t_info[i].value)));
		
	}
#endif	
	printf("**********t_info2************\r\n");
	t_info = m_t_paket[1].t_info;
	for (i = 0; i < 6; i++)
	{
		if (t_info[i].type == DATA_TYPE_U8) 
			printf("U8_T value = %x\n", *((U8_T*)(t_info[i].value)));
		else if (t_info[i].type == DATA_TYPE_U32) 
			printf("U32_T value = %x \n", *((U32_T*)(t_info[i].value)));
		
	}


	return 0;
}

在这里插入图片描述

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

天使也有爱

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值