I send 31 bytes that end with $7E. I recive back only the first two bytes then the $7E byte.
Below is my code.
Ray.
******* Sent Data ********
24 1A 00 80 A3 07 00 35 01 35 01 E2 01 38 00 99 01 66 02 0A 02 00 00 06 04 00 00 FF FB 1D 7E
******* Recived Data ********
24 1A 7E 00 12 00 00 00 01 00 00 00 02 00 00 00 35 36 00 00 12 00 00 00 01 00 00 00 03 00 00
Code: Select all
var
Rxdata: array[1..31] of Byte;
gotPCdata: Boolean;
xv: Byte;
{----------------------- GetSerialData; ----------------------}
procedure GetSerialData;
var
x: Byte;
begin
Rxdata[1]:= UART1_Read();
if Rxdata[1] = $24 then begin
Rxdata[2]:= UART1_Read();
for x:= 3 to Rxdata[2] + 2 do begin
Rxdata[x]:= UART1_Read();
end;
gotPCdata:= True;
end;
end;
{********************* Main Program ******************}
begin
{ Main program }
UART1_Init(57600);
Delay_ms(100);
while (TRUE) do begin
if (UART1_Data_Ready() <> 0) then begin
GetSerialData;
if gotPCdata = True then begin
for xv:= 1 to 31 do begin
UART1_Write(Rxdata[xv]);
end;
gotPCdata:= False;
end;
end;