Recent

Author Topic: TLazSerial : serial port component for Lazarus (windows and linux).  (Read 270652 times)

Joek

  • New Member
  • *
  • Posts: 24
Re: TLazSerial : serial port component for Lazarus (windows and linux).
« Reply #330 on: February 22, 2021, 10:32:23 pm »
I have a simple application using TLazSerial. So far, I am reading data from the device using the button - the reading event will take place only once. But using the button increases the CPU load to 25%, even though the application theoretically no longer does anything. The load drops after the Serial.Close event. Windows7, Lazarus v 2.0.10, LazSerialPort 0.3.
Excuse my English - I use a Goggle translator.
Does anyone know what I'm doing wrong?
Here is the reading procedure:

procedure TForm1.BtDataClick(Sender: TObject);
var Str : string;
begin
  Str :='#APP:cw:data?' + #13 + #10;   //Request to send data
  try
    Serial.WriteData(Str);
    Str :=  Serial.ReadData;
    Memo1.Append(Str);
    Serial.SynSer.Flush;
  except
    On E :Exception do
    begin
      ShowMessage(  E.Message);
    end;
  end;
end; 

Jurassic Pork

  • Hero Member
  • *****
  • Posts: 962
Re: TLazSerial : serial port component for Lazarus (windows and linux).
« Reply #331 on: February 22, 2021, 11:27:17 pm »
hello,
TLazSerial is an event-driven component
don't use Serial.ReadData in a procedure or function.
With TLazSerial there is a thread that listens the serial port. When some data come to the serial port , they are read in the SerialRxData procedure. See how it works in the demo project of Lazserial.


Friendly, J.P
« Last Edit: February 22, 2021, 11:29:44 pm by Jurassic Pork »
Jurassic computer : Sinclair ZX81 - Zilog Z80A à 3,25 MHz - RAM 1 Ko - ROM 8 Ko

Joek

  • New Member
  • *
  • Posts: 24
Re: TLazSerial : serial port component for Lazarus (windows and linux).
« Reply #332 on: February 23, 2021, 07:51:24 am »
Thank you for the quick information. Unfortunately, I will not get to the device with which the application works until Thursday. I will redesign the application and announce the result.

Joek

  • New Member
  • *
  • Posts: 24
Re: TLazSerial : serial port component for Lazarus (windows and linux).
« Reply #333 on: February 25, 2021, 12:33:02 pm »
Behavior of the SerTest sample application included with TLazSerial:
My configuration: Windows7, Lazarus v 2.0.10, LazSerialPort 0.3., Profilic USB-COM1 - HW connection of pins 2 and 3.
- Connection COM1 OK, Start simulator OK - reading and writing data OK, processor load approx. 0-3%
- Stop simulator - OK, CPU load approx. 0%
- COM closing, application termination - CPU load 25% (!!!), COM can no longer be opened, application cannot be terminated
- application cannot be terminated, SerialRXData thread apparently blocks COM and prevents execution of Application.Terminate

Some ideas?

Jurassic Pork

  • Hero Member
  • *****
  • Posts: 962
Re: TLazSerial : serial port component for Lazarus (windows and linux).
« Reply #334 on: February 25, 2021, 12:56:07 pm »
hello,
Behavior of the SerTest sample application included with TLazSerial:
My configuration: Windows7, Lazarus v 2.0.10, LazSerialPort 0.3., Profilic USB-COM1 - HW connection of pins 2 and 3.
- Connection COM1 OK, Start simulator OK - reading and writing data OK, processor load approx. 0-3%
- Stop simulator - OK, CPU load approx. 0%
- COM closing, application termination - CPU load 25% (!!!), COM can no longer be opened, application cannot be terminated
- application cannot be terminated, SerialRXData thread apparently blocks COM and prevents execution of Application.Terminate
Some ideas?

Strange  %)  i have no problem on windows 10  with two FTDI USB-COM ports.  Have you another software using your port ? Have you added code to sertest project ?

Friendly,  J.P
Jurassic computer : Sinclair ZX81 - Zilog Z80A à 3,25 MHz - RAM 1 Ko - ROM 8 Ko

Joek

  • New Member
  • *
  • Posts: 24
Re: TLazSerial : serial port component for Lazarus (windows and linux).
« Reply #335 on: February 25, 2021, 01:07:13 pm »
COM1 is separate, not occupied by other SW (windows would not even allow it).
I did not interfere with the app. sertest

Jurassic Pork

  • Hero Member
  • *****
  • Posts: 962
Re: TLazSerial : serial port component for Lazarus (windows and linux).
« Reply #336 on: February 25, 2021, 01:24:51 pm »
have you connected your serial device to your usb serial port ?
Jurassic computer : Sinclair ZX81 - Zilog Z80A à 3,25 MHz - RAM 1 Ko - ROM 8 Ko

Joek

  • New Member
  • *
  • Posts: 24
Re: TLazSerial : serial port component for Lazarus (windows and linux).
« Reply #337 on: February 25, 2021, 01:38:29 pm »
I tried SerTest on another computer with Win7 and native COM1. Everything OK, no problem.
On the same computer with profilic USB-COM (COM16) the same behavior as on my computer.
So the problem is caused by the USB-COM profile converter. But to this day no problem with other applications.
Is it possible to influence the behavior of SerialRXData in any way?

Jurassic Pork

  • Hero Member
  • *****
  • Posts: 962
Re: TLazSerial : serial port component for Lazarus (windows and linux).
« Reply #338 on: February 25, 2021, 01:59:59 pm »
i have tried to connect an USB-COM with prolific  chip :    i can't connect to it   too old !    (see attachment)
with  FTDI USB-COM  i have no problem.
Jurassic computer : Sinclair ZX81 - Zilog Z80A à 3,25 MHz - RAM 1 Ko - ROM 8 Ko

MarkMLl

  • Hero Member
  • *****
  • Posts: 2368
Re: TLazSerial : serial port component for Lazarus (windows and linux).
« Reply #339 on: February 25, 2021, 02:09:08 pm »
i have tried to connect an USB-COM with prolific  chip :    i can't connect to it   too old !    (see attachment)
with  FTDI USB-COM  i have no problem.

Are you aware that Prolific has always had a massive problem with counterfeits? A substantial proportion of Prolific-badged chips in cheap serial converters are actually generic microcontrollers programmed to emulate the basic Prolific functionality... if you want something reliable than buy something with an FTDI chip in it from a reputable source.

MarkMLl
Turbo Pascal v1 on CCP/M-86, multitasking with LAN and graphics in 128Kb.
Pet hate: people who boast about the size and sophistication of their computer.
GitHub repositories: https://github.com/MarkMLl?tab=repositories

hansotten

  • Jr. Member
  • **
  • Posts: 68
Re: TLazSerial : serial port component for Lazarus (windows and linux).
« Reply #340 on: February 25, 2021, 04:33:06 pm »
i have tried to connect an USB-COM with prolific  chip :    i can't connect to it   too old !    (see attachment)
with  FTDI USB-COM  i have no problem.
Even the non-counterfeit version of the Prolifics, fucntioning well, are treated as 'too old' by the latest drivers.
Get an old version of the driver: http://retro.hansotten.nl/other-retro-articles/serial-usb-adapters-testing/ search for Prolific, and get the archive from there.

hansotten

  • Jr. Member
  • **
  • Posts: 68
Re: TLazSerial : serial port component for Lazarus (windows and linux).
« Reply #341 on: February 25, 2021, 04:36:25 pm »
i have tried to connect an USB-COM with prolific  chip :    i can't connect to it   too old !    (see attachment)
with  FTDI USB-COM  i have no problem.

Are you aware that Prolific has always had a massive problem with counterfeits? A substantial proportion of Prolific-badged chips in cheap serial converters are actually generic microcontrollers programmed to emulate the basic Prolific functionality... if you want something reliable than buy something with an FTDI chip in it from a reputable source.

MarkMLl
I  have one counterfeit FTDI IC in a Mega2560. The Windows driver by FTDI bricks it, unbricked it in Linux and now works fine in Linux. I regularly read people still getting a counterfeit FTDI in a cheap USB serial.

MarkMLl

  • Hero Member
  • *****
  • Posts: 2368
Re: TLazSerial : serial port component for Lazarus (windows and linux).
« Reply #342 on: February 25, 2021, 05:02:04 pm »
I  have one counterfeit FTDI IC in a Mega2560. The Windows driver by FTDI bricks it, unbricked it in Linux and now works fine in Linux. I regularly read people still getting a counterfeit FTDI in a cheap USB serial.

Which is why I used the words "reputable source": this has been a problem with Prolifics for a /long/ time... quite a few years before FTDI had their patience tested beyond endurance.

The Linux FTDI utility allows you to do things like writing a serial number to the chip: does that work properly, or it there some other easy way of detecting an FTDI counterfeit?

MarkMLl
Turbo Pascal v1 on CCP/M-86, multitasking with LAN and graphics in 128Kb.
Pet hate: people who boast about the size and sophistication of their computer.
GitHub repositories: https://github.com/MarkMLl?tab=repositories

Jurassic Pork

  • Hero Member
  • *****
  • Posts: 962
Re: TLazSerial : serial port component for Lazarus (windows and linux).
« Reply #343 on: February 25, 2021, 05:35:31 pm »
i have tried to connect an USB-COM with prolific  chip :    i can't connect to it   too old !    (see attachment)
with  FTDI USB-COM  i have no problem.
Even the non-counterfeit version of the Prolifics, fucntioning well, are treated as 'too old' by the latest drivers.
Get an old version of the driver: http://retro.hansotten.nl/other-retro-articles/serial-usb-adapters-testing/ search for Prolific, and get the archive from there.
thanks hansotten for the driver, now i can connect to my prolific USB-COM, transferring some data between this USB-COM and a FTDI USB-COM , close the port but i have the same problem than Joek -> i can't close the sertest application (by the cross) i need to kill it.   This problem does'nt come with FTDI USB-COM.
Jurassic computer : Sinclair ZX81 - Zilog Z80A à 3,25 MHz - RAM 1 Ko - ROM 8 Ko

Joek

  • New Member
  • *
  • Posts: 24
Re: TLazSerial : serial port component for Lazarus (windows and linux).
« Reply #344 on: February 25, 2021, 07:51:45 pm »
Sorry to add to your expert discussion, but WIn7 downloaded the drivers for my Profilic USB-COM port itself,
he did not report any counterfeits and we have not had a problem with them to this day. I usually program various types of radios with it (Motorola, Mototrbo, Hytera and various Chinese products). It also joins the two timekeepers when measuring races. Seamlessly.
I would like to find out where the problem is, but if it doesn't work with LazSerial, I won't do anything about it ....
By the way ... for Jurassic Pork: is the ZX1 still functional? If so, my admiration ...

 

TinyPortal © 2005-2018