Recent

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

Joek

  • New Member
  • *
  • Posts: 24
Re: TLazSerial : serial port component for Lazarus (windows and linux).
« Reply #345 on: February 25, 2021, 08:09:58 pm »
I'm starting to feel like a fool: I found a noname USB-COM converter in stock. Windows identified it as an FTDI device without any specification, without a digital signature, an unknown provider. SerTest works without any hesitation ....

Jurassic Pork

  • Hero Member
  • *****
  • Posts: 963
Re: TLazSerial : serial port component for Lazarus (windows and linux).
« Reply #346 on: February 26, 2021, 12:42:51 am »
For the zx81 i don't know : i don't dare to power on again :  i am afraid to destroy it. I
i have tried my prolific UQ on Ubuntu 20.04 --> no problem  i can close my serial application.
Quote
[   12.235225] usbserial: USB Serial support registered for pl2303
[   12.235249] pl2303 1-5:1.0: pl2303 converter detected
[   12.236333] usb 1-5: pl2303 converter now attached to ttyUSB0
and for the driver under windows 10 :
Quote
NOTE:

Windows 8/8.1/10 are NOT supported in PL-2303HXA and PL-2303X EOL chip versions.
Run PL2303 CheckChipVersion tool program in Windows XP/Vista/7 to check chip version.
Windows Vista, XP, 2000, 98 and Windows ME driver technical support are discontinued.
Prolific recommends to use PL-2303HXD (HX Rev D) or PL2303TA chip.
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 #347 on: February 26, 2021, 01:14:00 am »
PL2303 CheckChipVersion marked my chip as type PL-2303H. I installed the latest version of Profilic drivers - no compatibility issue (Win7 support). But the situation has not changed - I can not close the application. We probably won't solve it - thank you for your effort.

Jurassic Pork

  • Hero Member
  • *****
  • Posts: 963
Re: TLazSerial : serial port component for Lazarus (windows and linux).
« Reply #348 on: February 26, 2021, 10:13:40 am »
hello,
i have played with my prolific USB-COM and sertest on debug  and i have found where there is a problem :

it is in the DeviceClose procedure :

Code: Pascal  [Select][+][-]
  1. procedure TLazSerial.DeviceClose;
  2. begin
  3.   // flush device
  4.   if FSynSer.Handle<>INVALID_HANDLE_VALUE then begin
  5.     FSynSer.Flush;
  6.     FSynSer.CloseSocket;
  7.  //   FSynSer.Purge;
  8.   end;
  9.  
  10.   // stop capture thread
  11.   if ReadThread<>nil then begin
  12.     ReadThread.FreeOnTerminate:=false;
  13.     ReadThread.MustDie:= true;
  14.     while not ReadThread.Terminated do begin
  15.       Application.ProcessMessages;
  16.     end;
  17.     ReadThread.Free;
  18.     ReadThread:=nil;
  19.   end;  
     

with no breakpoint if i open the serial port and close the port , closing the port i don't reach ReadThread.Free : seems to be stayed in the ReadThread.Terminated loop.
if i put a breakpoint at the beginning of the procedure (line  if FSynSer.Handle) no problem running after the program . I reach the end of the procedure.
I have tried to put a delay at the beginning of the procedure with no success.
I don't understand why the breakpoint solve the problem.
friendly, J.P
« Last Edit: February 26, 2021, 10:16:02 am 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 #349 on: February 26, 2021, 03:45:46 pm »
Amazing discovery !!! For me, it works the same as for you. But ... what about that? I don't get it very well either - this is too much for me.

Joek

  • New Member
  • *
  • Posts: 24
Re: TLazSerial : serial port component for Lazarus (windows and linux).
« Reply #350 on: February 26, 2021, 03:57:02 pm »
I noticed that the flush device and the close device are the same codes. I canceled the flush. I don't know what I messed up, but it works ....
Code: Pascal  [Select][+][-]
  1. procedure TLazSerial.DeviceClose;
  2. begin
  3.   // flush device
  4.  // if FSynSer.Handle<>INVALID_HANDLE_VALUE then begin
  5.  //   FSynSer.Flush;
  6.  //   FSynSer.CloseSocket;
  7.  ////   FSynSer.Purge;
  8.  // end;
  9.  
  10.   // stop capture thread
  11.   if ReadThread<>nil then begin
  12.     ReadThread.FreeOnTerminate:=false;
  13.     ReadThread.MustDie:= true;
  14.     while not ReadThread.Terminated do begin
  15.       Application.ProcessMessages;
  16.     end;
  17.     ReadThread.Free;
  18.     ReadThread:=nil;
  19.   end;
  20.  
  21.   // close device
  22.   if FSynSer.Handle<>INVALID_HANDLE_VALUE then begin
  23.     FSynSer.Flush;
  24.     FSynSer.CloseSocket;
  25.   end;
  26. end;                    

Jurassic Pork

  • Hero Member
  • *****
  • Posts: 963
Re: TLazSerial : serial port component for Lazarus (windows and linux).
« Reply #351 on: February 26, 2021, 04:21:10 pm »
thanks for the Info  Joek,   i think that there is a   wrong closeSocket  at the beginning of the DeviceClose procedure.

this should be :

Code: Pascal  [Select][+][-]
  1. procedure TLazSerial.DeviceClose;
  2. begin
  3.   // flush device
  4.   if FSynSer.Handle<>INVALID_HANDLE_VALUE then begin
  5.     FSynSer.Flush;
  6. //    FSynSer.CloseSocket;
  7.     FSynSer.Purge;
  8.   end;
  9.  
  10.   // stop capture thread
  11.   if ReadThread<>nil then begin
  12.     ReadThread.FreeOnTerminate:=false;
  13.     ReadThread.MustDie:= true;
  14.     while not ReadThread.Terminated do begin
  15.       Application.ProcessMessages;
  16.     end;
  17.     ReadThread.Free;
  18.     ReadThread:=nil;
  19.   end;
  20.  
  21.   // close device
  22.   if FSynSer.Handle<>INVALID_HANDLE_VALUE then begin
  23.     FSynSer.Flush;
  24.     FSynSer.CloseSocket;
  25.   end;
  26. end;  

1 - Flush and purge the serial port
2 - Terminate the read thread
3 - close the serial port

i must check if this code always works and why there is a "lost" closesocket at the beginning of the code.


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 #352 on: February 26, 2021, 04:38:15 pm »
Thank you very very much for solving the problem. It looks like I'll be able to complete my timekeeper app!

Jurassic Pork

  • Hero Member
  • *****
  • Posts: 963
Re: TLazSerial : serial port component for Lazarus (windows and linux).
« Reply #353 on: February 27, 2021, 09:50:15 am »
hello,
i must check if this code always works and why there is a "lost" closesocket at the beginning of the code.
i confirm that there is a wrong code in the deviceClose procedure of lazserial.pas since the version 0.2   :-[
the wrong code can prevent the read thread to be terminated. It is the case for USB-COM adapter with prolific chip on windows.
A new version of lazserial is available on my repository (with  a fixed code for the DeviceClose procedure  of Lazserial.Pas. The new version is the 0.4. Soon on onlinepackagemanager.

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

hansotten

  • Jr. Member
  • **
  • Posts: 68
Re: TLazSerial : serial port component for Lazarus (windows and linux).
« Reply #354 on: February 27, 2021, 11:06:55 am »
That is good news! Thank you for maintaining TLazSerial!

sstvmaster

  • Full Member
  • ***
  • Posts: 241
Re: TLazSerial : serial port component for Lazarus (windows and linux).
« Reply #355 on: February 27, 2021, 11:49:24 am »
Thank you J.P.!
Windows 10 (64 bit)
Lazarus: 2.0.12 / Trunk x32

Joek

  • New Member
  • *
  • Posts: 24
Re: TLazSerial : serial port component for Lazarus (windows and linux).
« Reply #356 on: March 12, 2021, 11:53:54 pm »
I apologize for the stupid question, but I would welcome advice: How do I test when using LazSerial that the connected device is turned off - it does not return any data (the OnRxData event does not occur)? Now I send a request for data with a timer, OnRxData collects and analyzes it. It is not interconnected. Somehow I ran out of ideas ...

Jurassic Pork

  • Hero Member
  • *****
  • Posts: 963
Re: TLazSerial : serial port component for Lazarus (windows and linux).
« Reply #357 on: March 13, 2021, 03:05:40 am »
hello,
have a look here or here
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 #358 on: March 13, 2021, 06:27:54 am »
Yes, the most complex problems have simple solutions .... and vice versa. Thank you very very much!!!

CJ

  • New Member
  • *
  • Posts: 10
Re: TLazSerial : serial port component for Lazarus (windows and linux).
« Reply #359 on: March 21, 2021, 05:35:55 pm »
Hi, I have a working PC-dimmer version now, build with Lazarus. I use ComportDriverThread.pas (https://static.elitesecurity.org/uploads/3/1/316386/ComportDriverThread.pas).
I did not have to make a lot of changes to make PC-dimmer work starting from the try-out with ComDrv32. I have listed the changes in differences.txt. The file content is the result of the Unix diff command (https://unix.stackexchange.com/questions/81998/understanding-of-diff-output)
The source files are attached.
Many thanks on all who helped me in this conversion (see also Class ”TPage” not found posts).
I am ready just in time because the evaluation licence I used to make a Delphi version (Embarcadero 10.4) run out of time and the licence fee they ask is not affordable to me.

 

TinyPortal © 2005-2018