struct MemoryTag1;
typedef struct MemoryTag1{
char a[8]= {'+','0','2','6','.','5','EA','\r'}; // setpoint temperature value
char b[8]= {'-','0','2','4','.','5','EB','\r'};
char c[6]= {'+','0','2','0','EC','\r'};
}Memory1;
//这是一个消息结构,我想通过串行接口(interface)(RS232)传输该消息结构,然后将其转换为整数值。请在这方面指导我。
最佳答案
你的语法有点不对劲 - 试试这个:
// declare Memory1 struct type to hold data
typedef struct MemoryTag1 {
char a[9]; // setpoint temperature value
char b[9];
char c[7];
} Memory1;
// allocate and initialise a Memory1 struct
Memory1 m = { {'+','0','2','6','.','5','E','A','\r'},
{'-','0','2','4','.','5','E','B','\r'},
{'+','0','2','0','E','C','\r'} };
关于c - 如何将结构体中的字符值写入串行接口(interface)并转换为整数值?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16666690/