Recent

Author Topic: Bug on LazSerial  (Read 341 times)

tadryanom

  • New Member
  • *
  • Posts: 15
Bug on LazSerial
« on: July 02, 2019, 04:36:20 am »
Hello everyone, I do not know if this is the right place to post this topic, but please, Mr. admin move it to the appropriate location.

First of all I apologize for my bad English, I am a Brazilian boy. Well, my problem is this...
I'm using the lazserial component version 0.2 and I made an access control system using cross-compille, my environment being Ubuntu Linux 18.04 x86_64, Lazarus 1.8.4 and FPC 3.0.4 to run on the target platform: Linux 4.19.42-v7 armv7l (specifically a raspberrypi 3). A rasberrypi connection is made with a teensy++2.0 board across the serial port (where serial communication is controlled by the arduino components, but I use the rx/tx pins together with the IC max232 and on the other end I have an HL-340 USB-Serial adapter).
However, everything works fine if the data starts in the following order: Raspi->teensy, teensy->Raspi
But, I have problems receiving the latest data if they are trafficked in this way: teensy->Raspi, Raspi->teensy, teensy->Raspi

I did the same test using a Blue Pill Board (based on STM32F103C8), the board emulates a usb-serial connection. Being the Blue Pill Board usb port attached directly to the usb port of RaspberryPi (I also used the arduino-based libraries, specifically the stm32duino) and to my surprise I had the same result.

Can anyone give me some light on why this problem??

Another curious thing is that this appears sporadically. Sometimes everything is working normally, but suddenly things get weird and everything works incorrectly, as I described above. And even restarting the application continues with the problem.

Note1: I use the onRxData event to process incoming messages using the following commands:
if Serial.DataAvailable then
    Str := Serial.ReadData;

Note2: And to send the data I use the commands:
if Serial.Active then
    Serial.WriteData(Str);

Note3: The baud rate was set to 9600 bounds, both at the interface controlled by the lazserial and on the boards using the arduino libraries.
« Last Edit: July 02, 2019, 04:47:15 am by tadryanom »

tadryanom

  • New Member
  • *
  • Posts: 15
Re: Bug on LazSerial
« Reply #1 on: July 02, 2019, 10:28:15 pm »
I was able to solve the problem. I rewrote the function handled by the onRxData event, since when it was executed, one information was received in a way tied to another, so I added some commands to compare the string size and check where the separator character, in this case, I used the CR.