Recent

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

engkin

  • Hero Member
  • *****
  • Posts: 2513
Re: TLazSerial : serial port component for Lazarus (windows and linux).
« Reply #60 on: February 21, 2014, 10:59:02 pm »
If I edit termios.inc the IDE can see the constant, but the compiler stills complains
The compiler does not know about these changes, yet.

Those constants aren't defined in the ARM section of termios.inc, maybe they're just not supported on ARM (and sparc)
If someone finds a working method, please let me know!
Hardware wise they are supported. Software wise, it might need some changes, and since you replaced the constants with their values and TLazSerial did not complain about it that means it does not support these speeds as well. If you do not need these speeds then you might as well delete the constants as you had done.

VTwin

  • Hero Member
  • *****
  • Posts: 787
  • Former Turbo Pascal 3 user
Re: TLazSerial : serial port component for Lazarus (windows and linux).
« Reply #61 on: March 08, 2014, 06:33:10 pm »
Paul,

Thanks!

I see the version of synazer.pas in CtrlTerm is 007.005.005 (2013), so I should have used this instead of 007.005.002 (2011) supplied by Jurasssic. I will see if I can get the CtrlTerm project to compile. Maybe that is a better starting point.

It does not compile as is, but I can see if the patch works for Darwin. If anyone has a patch file for 007.005.005 that would be very helpful. :)

All I need to do is read a stream of bytes from a COM port, which is connected from a counter with a RS-232 to USB converter.

Any suggestions are greatly appreciated.

Cheers,
Frederick

Just an update on my progress. I had no luck compiling CtrlTerm on OS X, and was having some trouble installing LazSerial. I run Lazarus on Windows, OS X, and Linux, and I'm not very familiar with using packages. So I just used synaser 007.005.005 and made this fix:

Code: [Select]
{$IFNDEF FPC}
  FHandle := THandle(Libc.open(pchar(FDevice), O_RDWR or O_SYNC));
{$ELSE}
  FHandle := THandle(fpOpen(FDevice, O_RDWR or O_SYNC or O_NONBLOCK)); //// FWV
{$ENDIF}

I made a wrapper class to open and close the port, and read incoming data. I call it from a timer and have it working on Windows and OS X. Nothing fancy, but it does what I need.

Thanks for the input!

Cheers,
Frederick

 
“Talk is cheap. Show me the code.” -Linus Torvalds

macOS 10.13.6: Lazarus 2.0 (2.0.7) fixes svn 62148 (64 bit Cocoa)
Ubuntu 18.04.3: Lazarus 2.0.6 (64 bit on VBox)
Windows 7 Pro SP1: Lazarus 2.0.6 (64 bit on VBox)
fpc 3.0.4

BigChimp

  • Hero Member
  • *****
  • Posts: 5740
  • Add to the wiki - it's free ;)
    • FPCUp, PaperTiger scanning and other open source projects
Re: TLazSerial : serial port component for Lazarus (windows and linux).
« Reply #62 on: March 18, 2014, 01:23:21 pm »
Please post any (OSX) patches for synaser to the Synapse mailing list [1] so the fixes can be incorporated in the next official Synapse version.

Thanks!
[1] See
http://www.ararat.cz/synapse/doku.php/support
Want quicker answers to your questions? Read http://wiki.lazarus.freepascal.org/Lazarus_Faq#What_is_the_correct_way_to_ask_questions_in_the_forum.3F

Open source including papertiger OCR/PDF scanning:
https://bitbucket.org/reiniero

Lazarus trunk+FPC trunk x86, Windows x64 unless otherwise specified

vonskie

  • Full Member
  • ***
  • Posts: 137
Re: TLazSerial : serial port component for Lazarus (windows and linux).
« Reply #63 on: March 18, 2014, 01:24:37 pm »
Paul,

Thanks!

I see the version of synazer.pas in CtrlTerm is 007.005.005 (2013), so I should have used this instead of 007.005.002 (2011) supplied by Jurasssic. I will see if I can get the CtrlTerm project to compile. Maybe that is a better starting point.

It does not compile as is, but I can see if the patch works for Darwin. If anyone has a patch file for 007.005.005 that would be very helpful. :)

All I need to do is read a stream of bytes from a COM port, which is connected from a counter with a RS-232 to USB converter.

Any suggestions are greatly appreciated.

Cheers,
Frederick

Just an update on my progress. I had no luck compiling CtrlTerm on OS X, and was having some trouble installing LazSerial. I run Lazarus on Windows, OS X, and Linux, and I'm not very familiar with using packages. So I just used synaser 007.005.005 and made this fix:

Code: [Select]
{$IFNDEF FPC}
  FHandle := THandle(Libc.open(pchar(FDevice), O_RDWR or O_SYNC));
{$ELSE}
  FHandle := THandle(fpOpen(FDevice, O_RDWR or O_SYNC or O_NONBLOCK)); //// FWV
{$ENDIF}

I made a wrapper class to open and close the port, and read incoming data. I call it from a timer and have it working on Windows and OS X. Nothing fancy, but it does what I need.

Thanks for the input!

Cheers,
Frederick

Your my hero that patch fixed the problem!


Paul Breneman

  • Sr. Member
  • ****
  • Posts: 290
    • Control Pascal
Re: TLazSerial : serial port component for Lazarus (windows and linux).
« Reply #64 on: March 18, 2014, 02:31:28 pm »
I'm glad to know that Synaser is now working on the Mac for  you.  I will try to follow up on the Synapse mailing list to get the change made in Synapse for everyone.

Does the CtrlTerm port for Lazarus compile OK?  If it compiles and runs, does it show the ports that are available?  I'm thinking there are other Synaser changes needed for the Mac to get the ports listed OK.  If you could email me the source code vonskie I'd sure appreciate it.
Regards,
Paul Breneman
www.ControlPascal.com

avra

  • Hero Member
  • *****
  • Posts: 1717
    • Additional info
Re: TLazSerial : serial port component for Lazarus (windows and linux).
« Reply #65 on: March 31, 2014, 03:00:37 pm »
@Jurrasic:

Tried to install LazSerial but it has a conflict with Synapse in CT/WinXP. Ignore button did not help. I had to delete units synafpc, synaser and synautil from LazSerial dir and to add synapse to the list of LazSerial required packages. After that compilation has passed and demo seams to work well at first sight (GPS data received at the other end).

Shouldn't borrowed Synapse units have some prefix in filenames and classes to avoid situations like this, if you had to include them? You should take a look at IFDEF changes made by CT to synapse units to support more platforms.

Thanks for your work!
ct2laz - Conversion between Lazarus and CodeTyphon
bithelpers - Bit manipulation for standard types
pasettimino - Siemens S7 PLC lib

Jurassic Pork

  • Hero Member
  • *****
  • Posts: 753
Re: TLazSerial : serial port component for Lazarus (windows and linux).
« Reply #66 on: March 31, 2014, 05:32:52 pm »
hello Avra,
i had the same problem with CT. To avoid this, i have renamed all the synaser pascal source code. For example synaser.pas becomes  mysynaser.pas. I have a version with this, but not sure that it works because not use since a long time. You can try it.   

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

Geoff_S

  • Newbie
  • Posts: 1
Re: TLazSerial : serial port component for Lazarus (windows and linux).
« Reply #67 on: April 11, 2014, 09:27:46 am »
Is there a way to get the current baud rate, as a string ?  There is a property called "BaudRate" but it has a value like "br__110".

Jurassic Pork

  • Hero Member
  • *****
  • Posts: 753
Re: TLazSerial : serial port component for Lazarus (windows and linux).
« Reply #68 on: April 11, 2014, 11:38:55 am »
hello
Baudrate of TLazSerial component is an enum :
Code: [Select]
type
  TBaudRate=(br___110,br___300, br___600, br__1200, br__2400, br__4800,
             br__9600,br_14400, br_19200, br_38400,br_56000, br_57600,
             br115200,br128000, br230400,br256000, br460800, br921600);   

to use it in your project  , for example create  const array of something in your project :
Code: [Select]
const
  BaudInt: array[TBaudRate] of integer=(110,
    300, 600, 1200, 2400, 4800, 9600,14400, 19200, 38400,56000, 57600,
    115200,128000,230400,256000, 460800, 921600);
  BaudString: array[TBaudRate] of string=('110',
      '300', '600', '1200', '2400', '4800', '9600','14400','19200','38400','56000',
      '57600','115200','128000','230400','256000', '460800', '921600');   

For example to read baudrate as string of your Serial1 TLaserial component :
Code: [Select]
ShowMessage(BaudString[Serial1.BaudRate]);
Friendly, J.P
Jurassic computer : Sinclair ZX81 - Zilog Z80A à 3,25 MHz - RAM 1 Ko - ROM 8 Ko

arifhannasy3

  • Newbie
  • Posts: 1
Re: TLazSerial : serial port component for Lazarus (windows and linux).
« Reply #69 on: April 11, 2014, 01:49:03 pm »
Jurrasic Pork,

hey Jurrasic Pork,
why you not submit your serialport component to sorceforge,
so people can download and develop your serialport component,
and bugs can be quickly resolved.

sorry my english is bad. :D

Momboz

  • New member
  • *
  • Posts: 7
Re: TLazSerial : serial port component for Lazarus (windows and linux).
« Reply #70 on: June 05, 2014, 11:23:33 pm »
Hi J.P.

I would like also to express my sincere thanks for the good job you have done. I am a fan of the Delphi environment (Embarcadero) and I am starting to use you LazSerial package. I like it very much.

I have tested it under Ubuntu 12.04 LTS and its perfect.

Your English is good and I can understand :-)

Please go ahead improving this wonderful package.

 

CM630

  • Hero Member
  • *****
  • Posts: 858
  • Не съм сигурен, че те разбирам.
    • http://sourceforge.net/u/cm630/profile/
Re: TLazSerial : serial port component for Lazarus (windows and linux).
« Reply #71 on: July 28, 2014, 08:25:26 am »
*JurrasicPork, I would ask you to put a link to the current version of TLazSerial in you first post.
Also, here is a function, I find essential for such purposes. Surely writing it would take less time than googling it.


Code: [Select]
//BSD 3-Clause License, СМ630, 2014
function  StringToASCIIStrHexColumned (aString: String): string;
const
  CrLf=#13#10;
var
  i:integer;
begin
  Result:='        │ 00 01 02 03 04 05 06 07 │ 08 09 0A 0B 0C 0D 0E 0F'
  +CrLf+  '────────┼─────────────────────────┼────────────────────────';
  for i:= 0 to Length(aString)-1 do
  if ((i mod 16) = 0)
     then Result:= Result +CrLf + IntToHex(trunc(i/16),8) + '│ ' + IntToHex( (i),2)+' '
        else if ((i mod = 0) then Result:= Result + '│ ' + IntToHex ((i),2)+' '
          else Result:= Result + IntToHex ((i),2)+' ';
end;
Example: Memo.Clear; Memo.Append(StringToASCIIStrHexColumned ('abcdefghijklmnoprstuvwxyz')); or
 Memo.Append (#13#10 +  StringToASCIIStrHexColumned ('abcdefghijklmnoprstuvwxyz'));
Obviously, it can be used with a monospaced font only.
« Last Edit: July 28, 2014, 09:17:28 am by paskal »
Лазар 1,8,2;W7 64bit or XP 32bit;FPC3,0,4;rev 57369

Dr. Console

  • New member
  • *
  • Posts: 5
Re: TLazSerial : serial port component for Lazarus (windows and linux).
« Reply #72 on: July 29, 2014, 10:28:08 pm »
Hey Jurassic,
could you may provide a little how to or so...i'm not working that often with lazarus, but I need serial com. for my actual project...
So would be cool if you could provide a short example of how to send and receive serial data... i didn't got I it yet from the example.

Thanks and nice greetings from Germany.
Dr. Console

CM630

  • Hero Member
  • *****
  • Posts: 858
  • Не съм сигурен, че те разбирам.
    • http://sourceforge.net/u/cm630/profile/
Re: TLazSerial : serial port component for Lazarus (windows and linux).
« Reply #73 on: July 30, 2014, 08:03:08 am »
Give us some more info what is you project about, we might give you some hints.

Лазар 1,8,2;W7 64bit or XP 32bit;FPC3,0,4;rev 57369

Dr. Console

  • New member
  • *
  • Posts: 5
Re: TLazSerial : serial port component for Lazarus (windows and linux).
« Reply #74 on: July 31, 2014, 03:40:04 pm »
Well my project are small, easy and cheap pagers for a medical service incl. a software for alarming them.
So the Pagers are based on an arduino at the moment and I need to supply the Keyword, a ID of the Pager and the message to send via Serial port and receive infos about a received ACK or a confirmation send by the pager.
So would be cool if you could it as basic as possible :D

NG
Dr. Console