Home > Back-end >  The inside of the great god, and how to extract a package of each frame at the back of the data, the
The inside of the great god, and how to extract a package of each frame at the back of the data, the

Time:09-20

A serial port to send data format is meet two packages to send order, including 1 package is f5 0 03 fa _ _ a _ fa _ _ _ fa _ _ _... Fa _ _ _c0 00 and pack 2 is f5 0 02 b fb _ _ fb_ _ fb _ _... Fb _ _ c0 00
(including f5 oa o3 and f5 ob o2 in baotou, 03 and 02 is behind the length of the data frame) c0 00 is tail, fa and fb is each frame head, how to extract each frame at the back of the line of three or two data and display in the iplot box), and end at the front of the two figures in the memo box recently applied to the design of curriculum, study for a month, these things are not
Here is my code where is wrong?
For I:=b to do a - 1
The begin
If (indata [I]=$f5) and (indata [I + 1)=$0 a) then
The begin
If (indata [I + 2]=$3) then
The begin
For d:=I to do a - 1
The begin
If (indata [d + 3]=$fa) then
The begin
Y1:=indata [I + 4] * 256 + indata + 5 [d] * 256 + indata + 6 [d].
Y11:=y1;
Y111:=FormatFloat (' 00.000 'y11);
If TryStrToFloat (y111, c1) then
The begin
Iplot1. Channel [0]. AddXY (j/h, c1);
The end;
Inc (j);
End
The else
If (indata [d + 3]=$c0) and (indata [d + 4]=$00) then
The begin
Y2:=indata [d + 1);
Y3:=indata [d + 2];

Y22:=FormatFloat (' 00.000 ', y2);
Y33:=FormatFloat (' 00.000 ', y3);

Memo2. Lines. The Clear;
Memo2. Lines. The Add (y22);
Memo3. Lines. The Clear;
Memo3. Lines. The Add (y33);
The end;
The end;
The end;
break;
End
The else
If (indata [I]=$f5) and (indata [I + 1)=$0 b) then
The begin
If (indata [I + 2]=$02) then
The begin
For c:=I to do a - 1
The begin
If (indata + 3 [c]=$fb) then
The begin
Y4:=indata [c + 4] * 256 + indata + 5 [c];
Y44:=FormatFloat (' 00.000 ', y4);
If TryStrToFloat (y44, c2) then
The begin
Iplot1. Channel [1]. AddXY (j/h, c2);
The end;
Inc (j);
End
The else
If (indata + 3 [c]=$c0) and (indata [c + 4]=$00) then
The begin
Y5:=indata [c + 1);
Y6:=indata [c + 2];

Y55:=FormatFloat (' 00.000 'y5);
Y66:=FormatFloat (' 00.000 'y6);

Memo4. Lines. The Add (y55);
Memo5. Lines. The Add (y66);
The end;
The end;
The end;
The end;
break;
The end;

CodePudding user response:

Must first clear packets of data structure, read to be effective,

CodePudding user response:

Packets of data structure generally refers to what?

CodePudding user response:

@ lyhoo163 packet data structure generally refers to what?

CodePudding user response:

Packets of data structure, the provisions of the sender and the receiver, such as

Record TInfomationData=https://bbs.csdn.net/topics/packed
TakeTime: string [28];//photo time
TakeAdr: string [50];//photographed
TakePixel: string [10].//picture pixel
ImageName: string [50];//picture name
The end;
PInfomationData=https://bbs.csdn.net/topics/^ TInfomationData;

//TCP packet
Record TTCPData=https://bbs.csdn.net/topics/packed
TdType: Word;//package type
TdLength: Cardinal;//the length of the data items (tdInfo + tdPicture)
TdInfo: TInfomationData;
TdPicture: an array of byte;//to store image data
The end;
PTCPData=https://bbs.csdn.net/topics/^ TTCPData;

Etc., determine the structure of the data packets, you can read correctly,

CodePudding user response:

Packets of data structure, you can ask the software editor's request,

CodePudding user response:

You can also through the analysis, from already draw its structure,

CodePudding user response:

The first step: according to the frame structure frame, take the legal frame of
Step 2: take the frame data

 
Procedure TForm1. Button1Click (Sender: TObject);
Var
Str_RecFrame: string;
Sl_FrameList: TStringList;
The begin
Sl_FrameList:=TStringList. Create;
Try
Str_RecFrame:=StringReplace (Str_RecFrame, ' ', ' ', [rfReplaceAll]);
//frame
While str_RecFrame & lt;> ' 'do
The begin
Delete (Str_RecFrame, 1, Pos (' f50a) - 1);
If the Copy (Str_RecFrame, 1, 4)='f50a' then
The begin
I_Index:=StrToInt (' $' + Copy (Str_RecFrame, 5, 2)) * 2 + 6 + 1;//frame head length + fixed length + 1, would be wrong here
If the Copy (Str_RecFrame i_Index, 4)='c000' then
The begin
Sl_FrameList. Add (Copy (Str_RecFrame, 1, i_Index + 3));
The end;
End the else
The begin
Delete (Str_RecFrame, 1, Length (Str_RecFrame));
End
The end;

//Add your code to take the frame data
The finally
Sl_Framelist. Free;
The end;
The end;

Note: the code debugging, according to my train of thought structure is like that
  • Related