Home > Back-end >  Could you tell me how to write this into my unsigned char tx_Setbuffer [1024]. In the data, writing
Could you tell me how to write this into my unsigned char tx_Setbuffer [1024]. In the data, writing

Time:01-16

Unsigned char tx_Setbuffer [1024].

Tx_Setbuffer [0]=0 xea;
Tx_Setbuffer [1]=0 x33;
Tx_Setbuffer [2]=0 x5c.
Tx_Setbuffer [3]=0 x00;
Tx_Setbuffer [4]=0 x00;
Tx_Setbuffer [5]=0 x00;
Tx_Setbuffer [6]=loading hexadecimal string "32"==this is variable, fixed write so I know tx_Setbuffer [6]=0 x32;
Tx_Setbuffer [7]=0 x00;


Tx_Setbuffer [8-16]=loading string "Versio
"
Tx_Setbuffer [17-18]=loading string "1" here is a decimal 1

The "32" and "Versio" and "1", respectively from the configuration file read they are strings, just do not agree form

The following is the content of the configuration file

; COF package (hexadecimal)
COF package=32
; VER (ASCII)
VER=Versio

; The revised (decimal)
Valuex=10



Please guide me, this what to write, thank you,

CodePudding user response:

For example
Tx_Setbuffer [6]=(unsinged char) strtol (" 32 ", NULL, 16);//string into a digital type
Strcpy (tx_Setbuffer + 8, "Versio");//string strcpy copy
Tx_Setbuffer [17]=((unsinged char)) strtol (" 1 ", NULL, 0);//string into a digital type
  • Related