Recent

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

Jurassic Pork

  • Hero Member
  • *****
  • Posts: 1228
Re: TLazSerial : serial port component for Lazarus (windows and linux).
« Reply #255 on: September 17, 2018, 06:38:24 am »
hello,
with a timer ?  see here
Friendly, J.P
Jurassic computer : Sinclair ZX81 - Zilog Z80A à 3,25 MHz - RAM 1 Ko - ROM 8 Ko

att2

  • Jr. Member
  • **
  • Posts: 52
Re: TLazSerial : serial port component for Lazarus (windows and linux).
« Reply #256 on: October 09, 2018, 03:05:04 pm »
Hello,
We have a large program that compiles perfectly with Lazarus 1.8.4 "stable" and FPC3.2.0 "fixes". Perfectly, that is, IF you select as Target OS=Linux and Target CPU=Intel (x64). If you select Target CPU=ARM, you get errors in the serial component :

Quote
Hint: (11030) Start of reading config file /home/arm1/fpc2/fpc/bin/x86_64-linux/fpc.cfg
Hint: (11031) End of reading config file /home/arm1/fpc2/fpc/bin/x86_64-linux/fpc.cfg
Free Pascal Compiler version 3.2.0-beta-r20:39835 [2018/10/08] for arm
Copyright (c) 1993-2018 by Florian Klaempfl and others
(1002) Target OS: Linux for ARMHF
(3104) Compiling LazSerialPort.pas
(3104) Compiling lazserial.pas
(3104) Compiling lazsynaser.pas
/home/arm1/fpc2/config_lazarus/onlinepackagemanager/packages/LazSerial/lazsynaser.pas(255,15) Error: (5000) Identifier not found "B1000000"
/home/arm1/fpc2/config_lazarus/onlinepackagemanager/packages/LazSerial/lazsynaser.pas(255,23) Error: (3203) Illegal expression
/home/arm1/fpc2/config_lazarus/onlinepackagemanager/packages/LazSerial/lazsynaser.pas(256,15) Error: (5000) Identifier not found "B1152000"
/home/arm1/fpc2/config_lazarus/onlinepackagemanager/packages/LazSerial/lazsynaser.pas(256,23) Error: (3203) Illegal expression
/home/arm1/fpc2/config_lazarus/onlinepackagemanager/packages/LazSerial/lazsynaser.pas(257,15) Error: (5000) Identifier not found "B1500000"
/home/arm1/fpc2/config_lazarus/onlinepackagemanager/packages/LazSerial/lazsynaser.pas(257,23) Error: (3203) Illegal expression
/home/arm1/fpc2/config_lazarus/onlinepackagemanager/packages/LazSerial/lazsynaser.pas(258,15) Error: (5000) Identifier not found "B2000000"
/home/arm1/fpc2/config_lazarus/onlinepackagemanager/packages/LazSerial/lazsynaser.pas(258,23) Error: (3203) Illegal expression
/home/arm1/fpc2/config_lazarus/onlinepackagemanager/packages/LazSerial/lazsynaser.pas(259,15) Error: (5000) Identifier not found "B2500000"
/home/arm1/fpc2/config_lazarus/onlinepackagemanager/packages/LazSerial/lazsynaser.pas(259,23) Error: (3203) Illegal expression
/home/arm1/fpc2/config_lazarus/onlinepackagemanager/packages/LazSerial/lazsynaser.pas(260,15) Error: (5000) Identifier not found "B3000000"
/home/arm1/fpc2/config_lazarus/onlinepackagemanager/packages/LazSerial/lazsynaser.pas(260,23) Error: (3203) Illegal expression
/home/arm1/fpc2/config_lazarus/onlinepackagemanager/packages/LazSerial/lazsynaser.pas(261,15) Error: (5000) Identifier not found "B3500000"
/home/arm1/fpc2/config_lazarus/onlinepackagemanager/packages/LazSerial/lazsynaser.pas(261,23) Error: (3203) Illegal expression
/home/arm1/fpc2/config_lazarus/onlinepackagemanager/packages/LazSerial/lazsynaser.pas(262,15) Error: (5000) Identifier not found "B4000000"
/home/arm1/fpc2/config_lazarus/onlinepackagemanager/packages/LazSerial/lazsynaser.pas(262,23) Error: (3203) Illegal expression
/home/arm1/fpc2/config_lazarus/onlinepackagemanager/packages/LazSerial/lazsynaser.pas(765,1) Fatal: (10026) There were 16 errors compiling module, stopping
Fatal: (1018) Compilation aborted
Error: /home/arm1/fpc2/fpc/bin/x86_64-linux/ppcrossarm returned an error exitcode


Can you help me to fix these errors ? It must be the component's fault.......     %)   %)

af0815

  • Hero Member
  • *****
  • Posts: 1289
Re: TLazSerial : serial port component for Lazarus (windows and linux).
« Reply #257 on: October 09, 2018, 03:17:59 pm »
This speeds are not defined in linux for arm by fpc. You can fix this in synaser or in fpc. I dont know WHO is responsible for this. FPC Team or Maintainer of synapse.
regards
Andreas

kasko

  • Newbie
  • Posts: 4
Re: TLazSerial : serial port component for Lazarus (windows and linux).
« Reply #258 on: October 09, 2018, 05:00:08 pm »
First of all, thank you for the LazSerial component!

I'm trying to make a program on the Rasperry Pi 3 and I'm using LazSerial version 0.2, but I get some problems. I woul be very grateful if anyone could give me som hints to get on... here is my problem:

I'm trying to use LazSerial, version 0.2, on a Raspberry Pi 3 with Raspian (Debian adaption for RPi). Just a simple test program with one button. When clicking the button, I want the Serial setup dialog to show up. Just using "LazSerial.ShowSetupDialog". The call results in an error "File not open". If clicking "OK" to ignore, and clicking once more on the button, the Setup Dialog appears. I have compiled the source code on the Raspberry Pi 3. The Helpscreen shows this configuration:

Raspberry Pi - #1
Lazarus version # 1.6.2 + dfsg-2
Date: 2018-10-05
FPC version 3.0.0
SVN revision Debian package 1.6.2 dfsg-2 arm-linux.gtk 2

I have another Raspberry Pi 3 with the following configuration:

Raspberry Pi - #2
Lazarus version # 1.6 + dfsg-4
Date: 2016-08-08
FPC version 3.0.0
SVN revision Debian package 1.6.4 dfsg-2 arm-linux.gtk 2

The LazSerial is version 0.1 and the message "File not open" does not show up, and everything workes nice!

When running in debugging mode, a debugger exception notification occur with the message "Project "Test" raised exception class 'RunError(103)'. In file "lazlogger.pas' at line 548. Pressing "Continue" result in the same message again. A new click on "Continue" results in the "normal" error message "File not open".

Does anyone have this problem too?

By the way, this does not occur in Windows....

Best regards
Karl

Jurassic Pork

  • Hero Member
  • *****
  • Posts: 1228
Re: TLazSerial : serial port component for Lazarus (windows and linux).
« Reply #259 on: October 09, 2018, 05:22:25 pm »
hello,
We have a large program that compiles perfectly with Lazarus 1.8.4 "stable" and FPC3.2.0 "fixes". Perfectly, that is, IF you select as Target OS=Linux and Target CPU=Intel (x64). If you select Target CPU=ARM, you get errors in the serial component :
you can try to put the code of engkin (see here)  :
Code: Pascal  [Select][+][-]
  1. {$ifdef cpuarm}
  2.    B1000000= $0001008;
  3.    B1152000= $0001009;
  4.    B1500000= $000100A;
  5.    B2000000= $000100B;
  6.    B2500000= $000100C;
  7.    B3000000= $000100D;
  8.    B3500000= $000100E;
  9.    B4000000= $000100F;
  10. {$endif cpuarm}
just before this :
Code: Pascal  [Select][+][-]
  1.   {$IFDEF UNIX}
  2.     ,(500000, B500000),
  3.     (576000, B576000),
  4.     (921600, B921600),
  5.     (1000000, B1000000),
  6.     (1152000, B1152000),
  7.     (1500000, B1500000),
  8.     (2000000, B2000000),
  9.     (2500000, B2500000),
  10.     (3000000, B3000000),
  11.     (3500000, B3500000),
  12.     (4000000, B4000000)
  13.   {$ENDIF}
at the beginning of the file lazsynaser.pas
Friendly, J.P
« Last Edit: October 09, 2018, 05:35:40 pm by Jurassic Pork »
Jurassic computer : Sinclair ZX81 - Zilog Z80A à 3,25 MHz - RAM 1 Ko - ROM 8 Ko

Thaddy

  • Hero Member
  • *****
  • Posts: 14204
  • Probably until I exterminate Putin.
Re: TLazSerial : serial port component for Lazarus (windows and linux).
« Reply #260 on: October 09, 2018, 05:25:41 pm »
Which is about the answer I gave very much earlier?
Specialize a type, not a var.

Jurassic Pork

  • Hero Member
  • *****
  • Posts: 1228
Re: TLazSerial : serial port component for Lazarus (windows and linux).
« Reply #261 on: October 09, 2018, 05:39:27 pm »
kasko what is your code , have you tried to run your program as superuser ?
Jurassic computer : Sinclair ZX81 - Zilog Z80A à 3,25 MHz - RAM 1 Ko - ROM 8 Ko

kasko

  • Newbie
  • Posts: 4
Re: TLazSerial : serial port component for Lazarus (windows and linux).
« Reply #262 on: October 09, 2018, 06:39:48 pm »
I will try with superuser...
the code is very simple. Just a form with a button, and when clicking the button the "LazSerial.ShowSetupDialog" is executed, that's all

Karl

kasko

  • Newbie
  • Posts: 4
Re: TLazSerial : serial port component for Lazarus (windows and linux).
« Reply #263 on: October 09, 2018, 07:03:25 pm »
Hi again!
Just tried with sudo, same error.
But.....
My original program is rather big, so I just compiled a very simple from as I described in my previous mail. This is working ok!!! So, there must be something with my big program. I think it has to do with a configuration file or something around this. I have to have a closer look. I'm not familiar with Linux, but I get help for this. I want to use the same source code to mak an executable for both Windows and Raspberry Pi...

Thanks for using your time on my problem!

Karl

att2

  • Jr. Member
  • **
  • Posts: 52
Re: TLazSerial : serial port component for Lazarus (windows and linux).
« Reply #264 on: October 18, 2018, 08:55:08 pm »
Hello "Jurassic Pork",
Thanks for your kind advice, but it did not work as described.
My boss, an extremely pro Delphi coder, finally fixed it with changing the "termios.inc" file, like so:

At Line numbers 1398 ff. :

Quote
{c_cflag bits}
   CBAUD   = $000100F;
   B0      = $0000000;
   B50     = $0000001;
   B75     = $0000002;
   B110    = $0000003;
   B134    = $0000004;
   B150    = $0000005;
   B200    = $0000006;
   B300    = $0000007;
   B600    = $0000008;
   B1200   = $0000009;
   B1800   = $000000A;
   B2400   = $000000B;
   B4800   = $000000C;
   B9600   = $000000D;
   B19200  = $000000E;
   B38400  = $000000F;
   EXTA    = B19200;
   EXTB    = B38400;
   CSIZE   = $0000030;
     CS5   = $0000000;
     CS6   = $0000010;
     CS7   = $0000020;
     CS8   = $0000030;
   CSTOPB  = $0000040;
   CREAD   = $0000080;
   PARENB  = $0000100;
   PARODD  = $0000200;
   HUPCL   = $0000400;
   CLOCAL  = $0000800;
   CBAUDEX = $0001000;
   B57600  = $0001001;
   B115200 = $0001002;
   B230400 = $0001003;
   B460800 = $0001004;
   B500000 = $0001005;
   B576000 = $0001006;
   B921600 = $0001007;
   B1000000 = $0001008;   // this line was added!
   B1152000 = $0001009;  // this line was added!
   B1500000 = $000100A;  // this line was added!
   B2000000 = $000100B;  // this line was added!
   B2500000 = $000100C;  // this line was added!
   B3000000 = $000100D;  // this line was added!
   B3500000 = $000100E;  // this line was added!
   B4000000 = $000100F;  // this line was added!

   CIBAUD  = $100F0000;
   CMSPAR  = $40000000;
   CRTSCTS = $80000000; 



The lazsynaser looks like this at line 220 ff.  :

Quote
const
{$IFDEF UNIX}
  {$IFDEF DARWIN}
  MaxRates = 18;  //MAC
  {$ELSE}
   MaxRates = 30; //UNIX
  {$ENDIF}
{$ELSE}
  MaxRates = 19;  //WIN
{$ENDIF}
  Rates: array[0..MaxRates, 0..1] of cardinal =
  (
    (0, B0),
    (50, B50),
    (75, B75),
    (110, B110),
    (134, B134),
    (150, B150),
    (200, B200),
    (300, B300),
    (600, B600),
    (1200, B1200),
    (1800, B1800),
    (2400, B2400),
    (4800, B4800),
    (9600, B9600),
    (19200, B19200),
    (38400, B38400),
    (57600, B57600),
    (115200, B115200),
    (230400, B230400)
{$IFNDEF DARWIN}
    ,(460800, B460800)
  {$IFDEF UNIX}
    ,(500000, B500000),
    (576000, B576000),
    (921600, B921600),
    (1000000, $0001008),
    (1152000, $0001009),
    (1500000, $000100A),
    (2000000, $000100B),
    (2500000, $000100C),
    (3000000, $000100D),
    (3500000, $000100E),
    (4000000, $000100F)
  {$ENDIF}
{$ENDIF}
    );
{$ENDIF}

{$IFDEF DARWIN}
const // From fcntl.h
  O_SYNC = $0080;  { synchronous writes }
{$ENDIF}         

BOLD are the additions to the LazSynaser file.

THEN, and only then, the large project compiled. I'm happy to see it working under Linux/Intel-32bit, Linux/Intel-64bit, Linux/ARM-32bit, Linux/ARM-64bit (aarch), and even Windows if we wanted to.   ;D


keyman

  • Newbie
  • Posts: 2
TLazSerial: onStatus dealing with rising and falling CTS
« Reply #265 on: December 01, 2018, 11:01:51 am »
Hey all,
first of all: thank you for LazSerial! it made my live easier so ofter and i really like how easy and good it works. really loving it!
the last days i fall over a problem i was not able to find a solution for myself.
i have a device which sends data and in parallel it notifies via CTS that a chip is in front of a reader.
what i wanted to achive is, to have a marker in the software when a chip is present. so far so good - i just used onStatus and it is signaling a rise of CTS. (read ready)
here comes my problem: as far is i got it onStatus is not called when CTS is falling. but i need that signal too.... how could i achive that?
as a fix a am reading the CTS-pin in a timer event now - but its not that clean i wanted it to be. is there any chance to get this to work? all i found was "on a change of the communication status" the function called.
can you help me with that?  ::)

thanks!
jan


mas steindorff

  • Hero Member
  • *****
  • Posts: 532
Re: TLazSerial : serial port component for Lazarus (windows and linux).
« Reply #266 on: December 03, 2018, 07:53:07 pm »
hi Keyman,
i do not have a fix for you but it would be useful to know what your target baud rate is.
windows 10 &11, Ubuntu 21+ - fpc 3.0.4, IDE 2.0 general releases

darthvader

  • Newbie
  • Posts: 2
Re: TLazSerial : serial port component for Lazarus (windows and linux).
« Reply #267 on: December 08, 2018, 12:44:12 pm »
Hi  :D
At First , thanks for this component !!
I just have a question about TX.
How can i know when the TX buffer is empty ?
I have to check this before i send new data or i get something like communication collision and the serial port freeze for some second , it's a little annoying because the sent data's are piloting Servo's and when it unfreeze some movement step for the servos are gone and the movement can be very rubbish  ;D
For info i use Latest Lazarus on win10
« Last Edit: December 08, 2018, 12:56:31 pm by darthvader »
Theory is when we know everything but nothing work ...
Practice is when everything work but no one know why ;) ...

keyman

  • Newbie
  • Posts: 2
Re: TLazSerial : serial port component for Lazarus (windows and linux).
« Reply #268 on: December 09, 2018, 07:11:28 pm »
i do not have a fix for you but it would be useful to know what your target baud rate is.
Hey,
its running with "9600,8,n,1" (baud,data,parity,stop)
thanks for wrapping your head around my problem; it's still unsolved.
jan

BeaglePi

  • New Member
  • *
  • Posts: 32
Re: TLazSerial : serial port component for Lazarus (windows and linux).
« Reply #269 on: December 15, 2018, 05:23:42 pm »
Hi

I'm going crazy trying to speak to an Alicat mass flow controller.  I write to it and the whole program (which is a big one, with three LazSerial components) locks up.  It does not return from the write statement.  The machine responds, for example when I set a flow rate, so it IS getting the message.   Then it locks.   I send it a string which is the instruction followed by a CR.  There's not a lot more to say!  The baud rates etc are matched but I have no information on data bits etc.  Current Baud is 19200, on LazSerial and device, over a USB.  I tried a serial cable and it behaves the same.  I tried the three flow control options.

Here is the chunk of code:

procedure TForm1.TestAlicatClick(Sender: TObject);
var tStr : string ;
 begin
  tStr :=  Edit1.text ; //Edit1.text contains 'A2222'  (Alicat expects integer 0..64000) A is the device ID
  Lazali.SynSer.Flush ;
  Lazali.WriteData(tStr + chr(13) ); //Add CR - and I've tried 2 of them
  exit ;  //Never gets to here
  try
   sleep (10) ;
   if Lazali.DataAvailable then
    tStr := Lazali.ReadData else exit ;
  except
   on  e: Exception do
    begin
     ShowMessage ('Sorry - an exception was generated and the program must close!') ;
     Application.Terminate;
    end ;
  end; 

Is there a parameter to timeout during a write?  I'm really desperate to get this to work as I am in Michigan and have to go back to Australia in two days!

Incidentally I know that the Alicat RS232 protocol is strange - it uses 0-5 volts instead of -5 to +5, but I'm using their serial interface box which presumably provides a compatible face to the outside world.

Thanks

Frustrated Hil
« Last Edit: December 15, 2018, 05:32:40 pm by BeaglePi »

 

TinyPortal © 2005-2018