unsigned char tx_Setbuffer[1024];
tx_Setbuffer[0] = 0xEA;
tx_Setbuffer[1] = 0x33;
tx_Setbuffer[2] = 0x5C;
tx_Setbuffer[3] = 0x00;
tx_Setbuffer[4] = 0x00;
tx_Setbuffer[5] = 0x00;
tx_Setbuffer[6] =裝載 十六進制字串 “32”== 這里是變數,固定的我知道這么寫 tx_Setbuffer[6] =0x32;
tx_Setbuffer[7] = 0x00;
tx_Setbuffer[8---16] =裝載 字串 “Versio”
tx_Setbuffer[17-18] = 裝載 字串 “1” 這里的 1 是 十進制的 1
上述 的 “32” 和 “Versio” 和 “1” 分別是從組態檔讀到的 他們都是以字串存在的,只是形式不一致
下述就是組態檔的內容
; COF(16進制)
COF=32
; VER(ASCII)
VER=Versio
; 整體修正值(10進制)
valuex=10
請高手指導我下 ,這個該怎么寫。謝謝了。
uj5u.com熱心網友回復:
for exampletx_Setbuffer[6] =(unsinged char)strtol("32", NULL, 16); //字串轉成數字型別
strcpy(tx_Setbuffer+8, "Versio"); //字串用strcpy拷貝的方式
tx_Setbuffer[17]=((unsinged char))strtol("1", NULL, 0); //字串轉成數字型別
轉載請註明出處,本文鏈接:https://www.uj5u.com/houduan/249139.html
標籤:C語言
下一篇:自閉中
