Recent

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

Thaddy

  • Hero Member
  • *****
  • Posts: 14205
  • Probably until I exterminate Putin.
Re: TLazSerial : serial port component for Lazarus (windows and linux).
« Reply #270 on: December 15, 2018, 07:01:03 pm »
Don't you mean a linefeed instead of a carriage return? i.e. #10?. Also you can code chr(13) better as #13... e.g. astring+#13
Specialize a type, not a var.

BeaglePi

  • New Member
  • *
  • Posts: 32
Re: TLazSerial : serial port component for Lazarus (windows and linux).
« Reply #271 on: December 15, 2018, 08:10:54 pm »
Hi

Nope - the documentation states to use a carriage return.  I tried a line feed just now and the device doesn't respond.

Ha ha!  I like to smatter chr() and # randomly through my code!  I suppose that I'm hoping that the compiler is smart enough to turn them into the same thing!

Thanks!

Hil

Jurassic Pork

  • Hero Member
  • *****
  • Posts: 1228
Re: TLazSerial : serial port component for Lazarus (windows and linux).
« Reply #272 on: December 15, 2018, 11:26:56 pm »
hello BeaglePI,
What is your O.S ?  because of this :
Quote
procedure Flush; virtual;
Waits until all data to is sent and buffers are emptied. Warning: On Windows systems is this method returns when all buffers are flushed to the serial port controller, before the last byte is sent!
Have you tried to remove the flush operation ?

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

BeaglePi

  • New Member
  • *
  • Posts: 32
Re: TLazSerial : serial port component for Lazarus (windows and linux).
« Reply #273 on: December 16, 2018, 12:34:58 am »
Hi J.P.

Yup, I only put flush in because I saw that somebody else had used it, but I took it out. 

I tried creating a tiny app just to find a basic case.  It worked when I have only one Lazserial component in the job.  So it looks like three are too many!

Interestingly (?) it only locks when it speaks to the device.  If I format the command wrongly then it doesn't lock up!  So it should be a2000#13 for example, but if I leave off the #13 then it doesn't set the flow or lock up. 

The machine returns 40 characters or something after a successful command so maybe it is the return that is creating problems.

Thanks

Hil

BeaglePi

  • New Member
  • *
  • Posts: 32
Re: TLazSerial : serial port component for Lazarus (windows and linux).
« Reply #274 on: December 16, 2018, 12:36:59 am »
Oh - OS is Windows 7 Pro.

PaulRowntree

  • Full Member
  • ***
  • Posts: 132
    • Paul Rowntree
Unusual baud rate (28800) required
« Reply #275 on: December 17, 2018, 08:25:02 am »
I have had great success with tLazSerial and connecting to several lab instruments, working with several Windows versions from XP on to Win10.  Thank for this code!One of my systems is a mass spectrometer from Stanford Research Systems.  It comes with a stand alone program that works well, and I have had success with LabView. I need to move to Lazarus/FP, however, the mass spec has a fixed 28,800 baud rate, which is not one of the TLazSerial options.
Am I out of luck on this?Thanks for any help you can provide!Cheers!
Paul Rowntree
- coding for instrument control, data acquisition & analysis, CNC systems

Phemtik

  • New Member
  • *
  • Posts: 19
Re: TLazSerial : serial port component for Lazarus (windows and linux).
« Reply #276 on: December 17, 2018, 09:47:11 am »
@PaulRowntree
Maybe you need to extend the TLazSerial  code with your specific baud rate.
If TLazSerial don't support it at all, you could use VISA. You have already used LabVIEW, so you have the Driver already installed.

If you have already written your program with TLazSerial, i think  it would be faster to modify TLazSerial than rewrite to use VISA instead.
Intel i7-3610QM
Fedora 28

avra

  • Hero Member
  • *****
  • Posts: 2514
    • Additional info
Re: TLazSerial : serial port component for Lazarus (windows and linux).
« Reply #277 on: December 17, 2018, 10:02:23 am »
It worked when I have only one Lazserial component in the job.  So it looks like three are too many!
Do those three components connect to the same machine through the same PC port? Can you go back to a single LazSerial component? How do you connect at all if 28800 is not supported?

There are alternatives for serial communication which you can also try:
http://wiki.freepascal.org/Hardware_Access#Serial_Communication
ct2laz - Conversion between Lazarus and CodeTyphon
bithelpers - Bit manipulation for standard types
pasettimino - Siemens S7 PLC lib

PaulRowntree

  • Full Member
  • ***
  • Posts: 132
    • Paul Rowntree
Re: TLazSerial : serial port component for Lazarus (windows and linux).
« Reply #278 on: December 17, 2018, 02:32:48 pm »
@PaulRowntree
Maybe you need to extend the TLazSerial  code with your specific baud rate.
If TLazSerial don't support it at all, you could use VISA. You have already used LabVIEW, so you have the Driver already installed.

If you have already written your program with TLazSerial, i think  it would be faster to modify TLazSerial than rewrite to use VISA instead.
My LabVIEw code was compiled, and we don't have access to the compiler any more.  It sent the mass spec data back to a Delphi program via DDE, and I really wanted to get away from that system to allow future interfaces. 
It doesn't look like I can extend TLasSerial in an OOP way, it would take recoding a few lines in the unit, and perhaps Synaser as well.  I would like to avoid private forks.  The really odd part is that the Win10 device manager doesn't even list 28800 as an option ...Thanks!
Paul Rowntree
- coding for instrument control, data acquisition & analysis, CNC systems

Phemtik

  • New Member
  • *
  • Posts: 19
Re: TLazSerial : serial port component for Lazarus (windows and linux).
« Reply #279 on: December 17, 2018, 03:38:45 pm »
@PaulRowntree
Maybe you need to extend the TLazSerial  code with your specific baud rate.
If TLazSerial don't support it at all, you could use VISA. You have already used LabVIEW, so you have the Driver already installed.

If you have already written your program with TLazSerial, i think  it would be faster to modify TLazSerial than rewrite to use VISA instead.
My LabVIEw code was compiled, and we don't have access to the compiler any more.  It sent the mass spec data back to a Delphi program via DDE, and I really wanted to get away from that system to allow future interfaces. 
It doesn't look like I can extend TLasSerial in an OOP way, it would take recoding a few lines in the unit, and perhaps Synaser as well.  I would like to avoid private forks.  The really odd part is that the Win10 device manager doesn't even list 28800 as an option ...Thanks!

Well, LabVIEW and VISA are two different things. If you have LabVIEW once installed and used VISA with it, you could use VISA64.dll / VISA.dll direct over Lazarus.
For newer Versions you need to update over National Instruments, because the VISA version from NI is most likely the reference implementation on Windows, but you don't need LabVIEW to use it.
It is an industry standard from the IVI Foundation and NI is only a vendor for it.

I use it for my daily work and wrote a few Programs for measuring and control with it.
Even on Linux over NI-VISA (openSUSE).
Intel i7-3610QM
Fedora 28

Jurassic Pork

  • Hero Member
  • *****
  • Posts: 1228
Re: TLazSerial : serial port component for Lazarus (windows and linux).
« Reply #280 on: December 17, 2018, 05:54:37 pm »
hello,
i have modified 3 files of the TLazSerial package to add the 28800 baud rate choice on Windows.
1 - Replace the 3 files by the files in the attachment file.
2 - Recompile the package
I don't know if it is OK but you can try.

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

PaulRowntree

  • Full Member
  • ***
  • Posts: 132
    • Paul Rowntree
Re: TLazSerial : serial port component for Lazarus (windows and linux).
« Reply #281 on: December 17, 2018, 06:11:44 pm »
hello,
i have modified 3 files of the TLazSerial package to add the 28800 baud rate choice on Windows.
1 - Replace the 3 files by the files in the attachment file.
2 - Recompile the package
I don't know if it is OK but you can try.

Friendly, J.P
Thanks JP, I really appreciate this.  Will try tonight!pr
Paul Rowntree
- coding for instrument control, data acquisition & analysis, CNC systems

PaulRowntree

  • Full Member
  • ***
  • Posts: 132
    • Paul Rowntree
Re: TLazSerial : serial port component for Lazarus (windows and linux).
« Reply #282 on: December 17, 2018, 06:54:21 pm »
@PaulRowntree
Maybe you need to extend the TLazSerial  code with your specific baud rate.
If TLazSerial don't support it at all, you could use VISA. You have already used LabVIEW, so you have the Driver already installed.

If you have already written your program with TLazSerial, i think  it would be faster to modify TLazSerial than rewrite to use VISA instead.
My LabVIEw code was compiled, and we don't have access to the compiler any more.  It sent the mass spec data back to a Delphi program via DDE, and I really wanted to get away from that system to allow future interfaces. 
It doesn't look like I can extend TLasSerial in an OOP way, it would take recoding a few lines in the unit, and perhaps Synaser as well.  I would like to avoid private forks.  The really odd part is that the Win10 device manager doesn't even list 28800 as an option ...Thanks!

Well, LabVIEW and VISA are two different things. If you have LabVIEW once installed and used VISA with it, you could use VISA64.dll / VISA.dll direct over Lazarus.
For newer Versions you need to update over National Instruments, because the VISA version from NI is most likely the reference implementation on Windows, but you don't need LabVIEW to use it.
It is an industry standard from the IVI Foundation and NI is only a vendor for it.

I use it for my daily work and wrote a few Programs for measuring and control with it.
Even on Linux over NI-VISA (openSUSE).
I didn't appreciate that ... thanks for the info!  JP modified his LazSerial codes, so I will try that route first.Cheers!pr
Paul Rowntree
- coding for instrument control, data acquisition & analysis, CNC systems

PaulRowntree

  • Full Member
  • ***
  • Posts: 132
    • Paul Rowntree
Re: TLazSerial : serial port component for Lazarus (windows and linux).
« Reply #283 on: December 21, 2018, 07:27:36 am »
hello,
i have modified 3 files of the TLazSerial package to add the 28800 baud rate choice on Windows.
1 - Replace the 3 files by the files in the attachment file.
2 - Recompile the package
I don't know if it is OK but you can try.

Friendly, J.P
Works like a charm JP, thank you!pr
Paul Rowntree
- coding for instrument control, data acquisition & analysis, CNC systems

BeaglePi

  • New Member
  • *
  • Posts: 32
Still problems with multiple LazSerial components
« Reply #284 on: February 18, 2019, 04:23:52 am »
Hi - I'm back ...

I tried three  LazSerial components in my program and it would not run. 

So then I went to two: one communicates with the laser and the other with the Arduino.   I then speak to the other devices by serial from the Arduino.

All good ... but occasionally the program stops for seconds to minutes.  I tried putting profilers all over the place and the result is that NONE of the calls from my program are freezing.  The problem is happening between my timer clicks and the resulting actions.  BUT the windows task manager shows my program as the culprit for bogging down the processor.

Finally in desperation I deleted a serial component (and all the references) and simply fed a string in with the required data in the timer click event.  And the program runs smooth as butter.  And that includes the dialog box problem that I had as well.

So my experience is definitely that more than one LazSerial component can cause problems.  Or is there something in Windows 7 that might cause a conflict?

Should I try a Synaser for one serial?  Or can anybody suggest another option?  It's funny because I saw a previous post regarding two components and the conclusion was that they should be fine.

 

TinyPortal © 2005-2018