Recent

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

MarkMLl

  • Hero Member
  • *****
  • Posts: 6682
Re: TLazSerial : serial port component for Lazarus (windows and linux).
« Reply #390 on: October 04, 2021, 10:00:51 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?

Just to get some oddments "into the record". I've been tidying up various serial-port code today, noting that very often that was working with an interface chip built into an instrument rather than a conventional RS232 port etc.

I can confirm that at least some of the counterfeit FTDI chips do not have writeable EEPROM: these can be identified in eBay etc. photos by bring serialised as G0370111 on the FT232RL chip, and possibly also by having a beige plastic-encapsulated capacitor next to the USB port rather than a ceramic device.

There must be at least one other counterfeit variant around, since a device with R/O EEPROM probably couldn't be bricked by a Windows driver.

Using Linux I was able to manipulate the serial number on a genuine chip using https://github.com/yogggoy/ftdi_eeprom_writer , and this leaves me able to locate which device (i.e. /dev/ttyUSBxxx) has a module in a particular role by its serial number... although it's hard work.

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

CM630

  • Hero Member
  • *****
  • Posts: 1086
  • Не съм сигурен, че те разбирам.
    • http://sourceforge.net/u/cm630/profile/
Re: TLazSerial : serial port component for Lazarus (windows and linux).
« Reply #391 on: August 24, 2022, 08:59:34 am »
Is there a way to make these setting of TLazSerial:


Code: Pascal  [Select][+][-]
  1. IOCTL_SERIAL_SET_QUEUE_SIZE: Set queue size
  2.    · Input       = 2048
  3.    · Output      = 2048
  4. IOCTL_SERIAL_SET_TIMEOUTS: Set timeouts
  5.    · Read interval               = 1
  6.    · Read total multiplier       = 0
  7.    · Read total constant         = 0
  8.    · Write total multiplier      = 0
  9.    · Write total constant        = 0
I found no properties for QueueSize and for the timeouts.
Лазар 3,2 32 bit (sometimes 64 bit); FPC3,2,2; rev: Lazarus_3_0 on Win10 64bit.

sstvmaster

  • Sr. Member
  • ****
  • Posts: 299
Re: TLazSerial : serial port component for Lazarus (windows and linux).
« Reply #392 on: August 24, 2022, 12:42:26 pm »
In LazSerial I don't think so, maybe JurassicPork knows more.

In TComPort there are these options.
greetings Maik

Windows 10,
- Lazarus 2.2.6 (stable) + fpc 3.2.2 (stable)
- Lazarus 2.2.7 (fixes) + fpc 3.3.1 (main/trunk)

Jurassic Pork

  • Hero Member
  • *****
  • Posts: 1228
Re: TLazSerial : serial port component for Lazarus (windows and linux).
« Reply #393 on: August 24, 2022, 03:43:38 pm »
Hello,
In LazSerial I don't think so, maybe JurassicPork knows more.
I don't think : LazSerial use synaser and i haven't seen these properties in the TBlockSerial class of Synaser.

There is a SizeRecvBuffer property.

Friendly, J.P
« Last Edit: August 24, 2022, 03:45:49 pm by Jurassic Pork »
Jurassic computer : Sinclair ZX81 - Zilog Z80A à 3,25 MHz - RAM 1 Ko - ROM 8 Ko

CM630

  • Hero Member
  • *****
  • Posts: 1086
  • Не съм сигурен, че те разбирам.
    • http://sourceforge.net/u/cm630/profile/
Re: TLazSerial : serial port component for Lazarus (windows and linux).
« Reply #394 on: August 26, 2022, 10:04:31 am »
I am trying to connect a multimeter (GDM-461) to the PC.
I succeeded to make it work with TBlockSerial with the following settings:

Code: Pascal  [Select][+][-]
  1.  
  2. procedure TForm1.Button1Click(Sender: TObject);
  3. var
  4.   ComDataPacket2: TComDataPacket;
  5. begin
  6.   ComPort2.Port:= 'COM1';
  7.   ComPort2.BaudRate:=br19200;
  8.   ComPort2.FlowControl.ControlDTR:= dtrEnable; //The DMM does NOT send data over RS232 without this line
  9.   Comport2.DataBits:= dbSeven;   //Communication works without it, but is unreadable
  10.   ComPort2.Parity.Bits:= prOdd;  //Communication works without it, but looks odd
  11.  
  12.  
  13.   ComDataPacket2:= TComDataPacket.Create(ComPort2); //The DMM does NOT send data over RS232 without this line
  14.   ComDataPacket2.ComPort:= ComPort2; //The DMM does NOT send data over RS232 without this line
  15.  
  16.  
  17.  //Next values are used by the original DMM software, but they seem to have no effect
  18.   ComPort2.FlowControl.ControlRTS:= rtsDisable; //Default
  19.   ComPort2.FlowControl.XoffChar:='0';
  20.   ComPort2.FlowControl.XonChar:='0';
  21.   ComPort2.FlowControl.FlowControl:=CPort.TFlowControl.fcNone;
  22.   ComPort2.Buffer.InputSize:=2048;
  23.   ComPort2.Buffer.OutputSize:=2048;
  24.   ComPort2.StopBits:= sbOneStopBit;
  25.   ComPort2.Timeouts.ReadInterval:=1;
  26.   ComPort2.Timeouts.ReadTotalConstant:=1;
  27.   ComPort2.Timeouts.WriteTotalConstant:=0;
  28.   ComPort2.Timeouts.WriteTotalMultiplier:=0;
  29.  
  30.  
  31.   Label1.Caption:='';
  32.   ComPort2.Open;end;    



I have also tried TLazSerial, but the DMM sends no data with the following source:
 
Code: Pascal  [Select][+][-]
  1. LazSerial1.Device:= 'COM1';
  2.   LazSerial1.BaudRate:=br_19200;
  3.   LazSerial1.FlowControl:= fcXonXoff;
  4.   LazSerial1.DataBits:=db7bits;
  5.   LazSerial1.Parity:=pOdd;
  6.   LazSerial1.Open;
« Last Edit: August 26, 2022, 10:26:29 am by CM630 »
Лазар 3,2 32 bit (sometimes 64 bit); FPC3,2,2; rev: Lazarus_3_0 on Win10 64bit.

MarkMLl

  • Hero Member
  • *****
  • Posts: 6682
Re: TLazSerial : serial port component for Lazarus (windows and linux).
« Reply #395 on: August 26, 2022, 10:29:52 am »
I am trying to connect a multimeter (GDM-461) to the PC.
...
I have also tried TLazSerial, but the DMM sends no data with the following source:

I usually use the standard serial unit for that sort of thing, with a background thread if necessary.

https://github.com/MarkMLl/Mastech_ms2115b

It's years since I did any maintenance on that, in part because one of the platforms I used for testing was SPARC SunOS/Solaris which I no longer have running. Somebody recently suggested some Windows-specific changes to it, but in the general case I prefer to make sure that the low-level handle is accessible so that OS-specific stuff can be added at the app level: I've done that in one specific use case where I needed an estimate of how much data Linux had buffered internally.

MarkMLl
MT+86 & Turbo Pascal v1 on CCP/M-86, multitasking with LAN & 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: 88
Re: TLazSerial : serial port component for Lazarus (windows and linux).
« Reply #396 on: August 26, 2022, 11:44:12 am »
I am trying to connect a multimeter (GDM-461) to the PC.
I have also tried TLazSerial, but the DMM sends no data with the following source:
 
Code: Pascal  [Select][+][-]
  1. LazSerial1.Device:= 'COM1';
  2.   LazSerial1.BaudRate:=br_19200;
  3.   LazSerial1.FlowControl:= fcXonXoff;
  4.   LazSerial1.DataBits:=db7bits;
  5.   LazSerial1.Parity:=pOdd;
  6.   LazSerial1.Open;
You do not have all comm settings as the DMM likes it, like DTR setting, lazSerial.SetDTR etc

CM630

  • Hero Member
  • *****
  • Posts: 1086
  • Не съм сигурен, че те разбирам.
    • http://sourceforge.net/u/cm630/profile/
Re: TLazSerial : serial port component for Lazarus (windows and linux).
« Reply #397 on: August 26, 2022, 12:40:46 pm »

You do not have all comm settings as the DMM likes it, like DTR setting, lazSerial.SetDTR etc

I have added LazSerial1.SetDTR(True); but still the device sends nothing.
Also, the PC floods the DMM with “IOCTL: IOCTL_SERIAL_GET_COMMSTATUS”.
And I do not know what TComDataPacket does, but without it the magic does not work.

I usually use the standard serial unit for that sort of thing, with a background thread if necessary.https://github.com/MarkMLl/Mastech_ms2115b
Thanks, I do not know what the “standart serial unit” is, I will check your code.
« Last Edit: August 26, 2022, 12:43:06 pm by CM630 »
Лазар 3,2 32 bit (sometimes 64 bit); FPC3,2,2; rev: Lazarus_3_0 on Win10 64bit.

MarkMLl

  • Hero Member
  • *****
  • Posts: 6682
Re: TLazSerial : serial port component for Lazarus (windows and linux).
« Reply #398 on: August 26, 2022, 12:59:28 pm »
Thanks, I do not know what the “standart serial unit” is, I will check your code.[/size][/font]

It is the serial unit which is supplied, as standard, with FPC.

Tested and used regularly with Linux, tested with Windows in the W2K era, tested with Solaris/SunOS on SPARC, not tested on Macs.

The protocol of your meter appears to be well understood, https://sigrok.org/wiki/GW_Instek_GDM-397 which is a close relation, I'd expect there to be plenty of projects on Github etc. that interface with it so the use case for FPC/Lazarus is if you have specific output format requirements or want to "pretty it up".

MarkMLl
« Last Edit: August 26, 2022, 02:08:50 pm by MarkMLl »
MT+86 & Turbo Pascal v1 on CCP/M-86, multitasking with LAN & 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: 1228
Re: TLazSerial : serial port component for Lazarus (windows and linux).
« Reply #399 on: August 26, 2022, 02:42:39 pm »
Hello,
I have also tried TLazSerial, but the DMM sends no data with the following source:
  [/size]
Code: Pascal  [Select][+][-]
  1. LazSerial1.Device:= 'COM1';
  2.   LazSerial1.BaudRate:=br_19200;
  3.   LazSerial1.FlowControl:= fcXonXoff;
  4.   LazSerial1.DataBits:=db7bits;
  5.   LazSerial1.Parity:=pOdd;
  6.   LazSerial1.Open;
why LazSerial1.FlowControl:= fcXonXoff;  ?
with the tcomport component you have Flowcontrol to dtrEnable
try to use fcNone for tlazserial flowcontrol ( fcHardware use the signal RTS/CTS not use in your code).

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

CM630

  • Hero Member
  • *****
  • Posts: 1086
  • Не съм сигурен, че те разбирам.
    • http://sourceforge.net/u/cm630/profile/
Re: TLazSerial : serial port component for Lazarus (windows and linux).
« Reply #400 on: September 01, 2022, 01:38:41 pm »
Indeed, the working setting for TComPort is:
Code: Pascal  [Select][+][-]
  1. ComPort2.FlowControl.FlowControl:=CPort.TFlowControl.fcNone;
  2. ComPort2.FlowControl.ControlDTR:= dtrEnable;


But even with LazSerial1.FlowControl:= fcNone; I cannot make it with TLazSerial:


Code: Pascal  [Select][+][-]
  1. procedure TForm1.Button3Click(Sender: TObject);
  2. begin
  3.   LazSerial1.Device:= 'COM1';
  4.   LazSerial1.BaudRate:=br_19200;
  5.   LazSerial1.FlowControl:= fcNone;
  6.   LazSerial1.SetDTR(True);
  7.   LazSerial1.DataBits:=db7bits;
  8.   LazSerial1.StopBits:=TStopBits.sbOne;
  9.   LazSerial1.Parity:=pOdd;
  10.   LazSerial1.Open;
  11. end;
  12.  
  13.  
  14. procedure TForm1.LazSerial1RxData(Sender: TObject);
  15. var
  16.   SerData: string='';
  17. begin
  18.   SerData := LazSerial1.ReadData;
  19.   Memo1.Text :=  Memo1.Text + SerData;
  20. end;



It is the serial unit which is supplied, as standard, with FPC.
...The protocol of your meter appears to be well understood, https://sigrok.org/wiki/GW_Instek_GDM-397 which is a close relation, I'd expect there to be plenty of projects on Github etc. that interface with it so the use case for FPC/Lazarus is if you have specific output format requirements or want to "pretty it up".
MarkMLl
Sigrok looks interesting, the protocol is not hard to interprete, anyway.
The FPC serial does not look good but I might try it as a last resort.
« Last Edit: September 01, 2022, 02:15:22 pm by CM630 »
Лазар 3,2 32 bit (sometimes 64 bit); FPC3,2,2; rev: Lazarus_3_0 on Win10 64bit.

eldonfsr

  • Sr. Member
  • ****
  • Posts: 447
Re: TLazSerial : serial port component for Lazarus (windows and linux).
« Reply #401 on: September 14, 2022, 04:02:40 pm »
Hi Can possible on Tlazserial when can not connect to port change to null value or something, not rise exception or a other way to handle the error...

 if FSynSer.Handle=INVALID_HANDLE_VALUE then
    raise Exception.Create('Could not open device '+ FSynSer.Device);

when handle this error, on this line i try but i don't know how i can put a different option..

thanks..

mas steindorff

  • Hero Member
  • *****
  • Posts: 532
Re: TLazSerial : serial port component for Lazarus (windows and linux).
« Reply #402 on: September 14, 2022, 08:52:41 pm »
my guess is your looking for an error code on opening the port since your handle will not be affected if an open port goes away.

in synaser (the original code LazSerial is based on) an error code could be accessed as ".LastError".   you can check this code for "sOK" after most port operations to see if things worked (are still working).   
windows 10 &11, Ubuntu 21+ - fpc 3.0.4, IDE 2.0 general releases

eldonfsr

  • Sr. Member
  • ****
  • Posts: 447
Re: TLazSerial : serial port component for Lazarus (windows and linux).
« Reply #403 on: September 15, 2022, 05:42:07 pm »
Yes, because that error trigger and my app ask
Code: Pascal  [Select][+][-]
  1.         if (cPort <> '' and serial.Active=false) then begin
  2.           try
  3.             Serial.SynSer.Connect( Serial.Device);
  4.             Serial.Active:=true;
  5.             StatusBar1.panels[0].Text := ' Connected to Port: ' + Serial.Device +' BaudRate:'+ BaudRateToStr(Serial.BaudRate)+' Databits:'+DataBitsToStr(Serial.DataBits)+' StopBits: '+StopBitsToStr(Serial.StopBits)+' Parity :'+ParityToStr(Serial.Parity);
  6.             Serial.WriteData(chr(27));
  7.  
  8.           except
  9.            showmessage('Can not open serial port , Check if connections is ok');
  10.           end;
  11.  
  12.  

two message tgrger with same message....
for that i think if resurn some different not rise on exception could be possible to handle that...
 

geraldholdsworth

  • Full Member
  • ***
  • Posts: 195
Re: TLazSerial : serial port component for Lazarus (windows and linux).
« Reply #404 on: October 02, 2022, 11:46:04 am »
Hi all,

I'm just trying to use this package, but I am falling on the first hurdle - installation.

I'm doing this on Lazarus 2.2.0 on macOS Catalina - as I noticed that, as of version 0.6, TLazSerial supports macOS. I've opened the package file, then clicked on Use -> Install. I get prompted to re-compile Lazarus, which I do, and it stops with the error
Code: Pascal  [Select][+][-]
  1. idewindowintf.pas(26,3) Fatal: Cannot find IDEOptionsIntf used by IDEWindowIntf, incompatible ppu=/Applications/Lazarus/components/buildintf/units/x86_64-darwin/ideoptionsintf.ppu, multiple packages: BuildIntf, IDEIntf

Many thanks,

Gerald.

 

TinyPortal © 2005-2018