多功能嵌入式解碼軟件(2)

多功能嵌入式解碼軟件(2)

 驗證類庫

 通訊協議

下面進行一個示例:this

    下位機須要向上位機發送3中數據幀,數據幀以功能碼來識別,每種數據幀的協議以下3個表格所示,上位機須要把這些數據按照協議解碼出來,並進行保存以便分析。blog

通訊協議:io

 

 

準備協議文件

  按照通訊協議編寫協議文件
 function

/*
this is a protocol
2019-03-28
正文中不能夠出現註釋
e.g. 正文//註釋內容
e.g. 正文
//註釋內容
正文開頭第一行必須是frameType
*/
/*
目前最後一行必須是空行
*/
frameType=header2 function
header1=0xA0
header2=0xA1
body=1
function=0xB1
index=1,type=unsigned char
index=2,type=unsigned short
index=3,type=unsigned int
index=4,type=short
index=5,type=int
index=6,type=float
index=7,type=double
endbody
body=2
function=0xB2
index=1,type=unsigned char
index=2,type=unsigned short
index=3,type=unsigned int
index=4,type=short
index=5,type=int
index=6,type=float
index=7,type=double
endbody
body=3
function=0xB3
index=1,type=unsigned char
index=2,type=unsigned short
index=3,type=unsigned int
index=4,type=short
index=5,type=int
index=6,type=float
index=7,type=double
endbody
check=CRC-CCITT
-----END FILE-----軟件

模擬下位機發送數據

  爲了方便分析,這裏使用虛擬串口助手在電腦上模擬出兩個串口端口float

  編寫軟件模擬下位機按照協議發送數據im

相關文章
相關標籤/搜索