Serial communication between UNO and Lazarus or Delphi

Hi,

I tried to make communicate an UNO board and a program wrote with Lazarus 1.8.4 using serial line.

I use TLazSerial on PC side and .

Problem : Most of the time, when UNO board send (for example) "8110010000", using Serial.print("8110010000"), the same string is received in the RxData event but sometimes the string is split into 2 part and the two parts are transmit.

Example : Printing the received string in a memo I see :

8110010000
8110010000
811
0010000
8110010000
8110010000
8110010000
81100100
00
8110010000
811001
0000
8110010000
8110010000
8110010000

etc.

Same problem using Delphi 7.1 !

An idea ?

(deleted)

An idea ?

The characters in the string are sent one at a time. It is the receiving application that is making invalid assumptions about that constitutes a complete packet. Fix the receiving code.

Have a look at the 3rd example in Serial Input Basics and note how the start- and end-markers are used to inform the Arduino that it has the complete message.The same technique can be used in your PC program.

Your Arduino can send data in a compatible format with code like this

Serial.print('<'); // start marker
Serial.print(value1);
Serial.print(','); // comma separator
Serial.print(value2);
Serial.println('>'); // end marker

...R