在串口通信中,计算机和仪器通信使用的是字符串,例如:
2000020008000000000000000000000000000000000000000000000000002a00
但编写软件时,我们定义发送的包是结构体,而且所有的包的前两个字节
始终是包的大小。
//登录码
LoginWord = record
Length: integer;
CommandType: integer;
FileNum: integer;
UserName: array[1..16] of char;
Password: array[1..8] of char;
end;
这样我们就需要将记录转换为
var
SendData: array[0..length] of char;能不能写一个函数,将所有的记录转换为字符串呢?
2000020008000000000000000000000000000000000000000000000000002a00
但编写软件时,我们定义发送的包是结构体,而且所有的包的前两个字节
始终是包的大小。
//登录码
LoginWord = record
Length: integer;
CommandType: integer;
FileNum: integer;
UserName: array[1..16] of char;
Password: array[1..8] of char;
end;
这样我们就需要将记录转换为
var
SendData: array[0..length] of char;能不能写一个函数,将所有的记录转换为字符串呢?
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货