Home > Back-end >  Delphi serial programming the feeling after the data buffer. See the content, a great god for help.
Delphi serial programming the feeling after the data buffer. See the content, a great god for help.

Time:10-15

I use the API function to WriteFile (), but the problem is when sending 0 for the first time, again send 1 or 0 all have no effect, and when after sending the 1, then this time or send 1, strives for the great god taught, specific function is
Var Temp: string; The Irc:
LongWord; Inbuff: an array of Char [0.. 2047]; NBytesRead dwEvent, dwError: LongWORD; Cs: TCOMSTAT;
The begin
Timer4. Enabled:=false; If (hComm=0) then the exit; Temp:=inttostr (xinhao);
^ WriteFile (hComm, PChar (Temp), length (Temp), Irc, nil);
ClearCommError (hComm, dwError, @ CS);
If cs. CbInQue> Sizeof (inbuff) then the begin
PurgeComm (hComm, PURGE_RXCLEAR and PURGE_TXABORT);
exit;
end;
READFILE (hComm inbuff, cs. CbInQue nBytesRead, nil); Temp:=Copy (inbuff, 1, cs. CbInQue); Edit8. Text:='accept' + Temp; Mainly is the realization of single-chip led brightness, now the problem is to send 1 light, after the next send 0 or 1 that was bright, a meeting will only 0 of the lights
But first send 0 is also the same problem,

CodePudding user response:

Don't understand what you said problems not clear

CodePudding user response:

Is the forehead, and single chip microcomputer sends data, sending data feeling there will be a repeat send,,

CodePudding user response:

Which version of Delphi use? Have a look at the following code lines

Var
Temp: AnsiString;
The Irc: LongWord;
The begin
Temp:=AnsiString (inttostr (xinhao));
^ WriteFile (hComm PAnsiChar (Temp), length (Temp), Irc, nil);
end;

CodePudding user response:

When you have a WriteFile, what is the content of the Temp?
  • Related