Accept send data from the single chip microcomputer, program now no syntax errors, but cannot receive data, the trouble to find out which is wrong, thank you
The unit Unit2.
Interface
USES the
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls SPComm;
Type
TForm1=class (TForm)
Comm1: TComm;
Memo1: TMemo;
Procedure FormShow (Sender: TObject);
Procedure FormClose (Sender: TObject; Var Action: TCloseAction);
Procedure Comm1ReceiveData (Sender: TObject; Buffer: Pointer;
BufferLength: Word);
Private
{Private declarations}
Public
{Public declarations}
end;
Var
Form1: TForm1;
Viewstring: string;
I: integer;
Rbuf: array [16] 1.. of byte;
Implementation
{$R *. DFM}
Procedure TForm1. FormShow (Sender: TObject);
The begin
Comm1. StartComm;
end;
//open the serial port
Procedure TForm1. FormClose (Sender: TObject; Var Action: TCloseAction);
The begin
Comm1. StopComm;
end;
//close a serial port
Procedure TForm1.Com m1ReceiveData (Sender: TObject; Buffer: Pointer;
BufferLength: Word);
Var
I: integer;
The begin
Move (buffer ^, pchar (@ rbuf) ^, bufferlength);
For I:=1 to bufferlength do
Viewstring:=viewstring + inttohex (rbuf [I], 2) + ";
Viewstring:='accept' + viewstring;
Memo1. Lines. The Add (viewstring);
Memo1. Lines. The Add (");
end;
End.
CodePudding user response:
move (buffer ^, rbuf [1], the bufferlength);
So try and be careful not to cross,
CodePudding user response:
You can make sure in the event the breakpoint, if you have to break to determine other factors, if not broken, do you consider your communication component set if there is a problem, such as baud rate, serial number, suggest first to get to the Internet to find a serial port debug tool, do further testingCodePudding user response:
The top 2 floor,Comm1ReceiveData breakpoint () to see if the process is executed,
CodePudding user response:
Rbuf [1] tried, no effect, the serial debugging assistants to receive data, exactly the wrong, depressedCodePudding user response:
May be caused by microcontroller send data too fast,Try changing ReadIntervalTimeOut attribute value to 1
CodePudding user response: