Recent

Author Topic: TLazSerial Component  (Read 541 times)

jcdammeyer

  • Full Member
  • ***
  • Posts: 119
  • Embedded System Developer
    • Automation Artisans Inc.
TLazSerial Component
« on: December 23, 2020, 07:02:05 pm »
Since I thought that the Mac used Linux under the covers I wondered why this component wouldn't work. 
https://github.com/JurassicPork/TLazSerial
But since it's Unix I can see the $IFDEF for LINUX failing and therefore trying to build for Windows. 

Just moving Classes out side of the ifdef and commenting out windows doesn't work. There are other files in the package that have issues.  I can try and make this work but before I head down that rabbit hole will macOS allow access to a USB Serial device or is this against Mac rules?

Code: Pascal  [Select][+][-]
  1. {$IFDEF LINUX}
  2.   Classes,
  3. {$IFDEF UseCThreads}
  4.   cthreads,
  5. {$ENDIF}
  6. {$ELSE}
  7.   Windows, Classes, //registry,
  8. {$ENDIF}
  9.   SysUtils, lazsynaser,  LResources, Forms, Controls, Graphics, Dialogs,
  10.   PropEdits;
  11.  

trev

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 1282
  • Former Delphi 1-7, 10.2 User
Re: TLazSerial Component
« Reply #1 on: December 23, 2020, 09:56:56 pm »
I have no firsthand experience with doing this on macOS, but you may find the Wiki article Hardware Access helpful.

Also, see https://forum.lazarus.freepascal.org/index.php/topic,20481.45.html
« Last Edit: December 23, 2020, 10:09:18 pm by trev »
Lazarus 2.1 r64368 FPC 3.3.1 r48100 macOS 10.14.6 Xcode 11.3.1
Lazarus 2.1 r64455 3.3.1 r48840   macOS 11.2.2 aarch64 Xcode 12.4
Lazarus 2.1 r61574 3.3.1 r42318 FreeBSD 12.1 amd64 VMware VM
Lazarus 2.1 r61574 3.0.4 Ubuntu 20.04 Parallels VM
Lazarus 2.0.10 3.2.0 Win10 Parallels VM

wp

  • Hero Member
  • *****
  • Posts: 8120
Re: TLazSerial Component
« Reply #2 on: December 23, 2020, 10:25:36 pm »
When you simply open a new project and look at the lpr file you'll see
Code: Pascal  [Select][+][-]
  1. uses
  2.   {$IFDEF UNIX}
  3.   cthreads,
  4.   {$ENDIF}
  5.   {$IFDEF HASAMIGA}
  6.   athreads,
  7.   {$ENDIF}  
  8.   ...
Therefore, I'd guess that you only have to replace the {$IFDEF LINUX} by {$IFDEF UNIX}.
Mainly Lazarus trunk / fpc 3.2.0 / all 32-bit on Win-10, but many more...

jcdammeyer

  • Full Member
  • ***
  • Posts: 119
  • Embedded System Developer
    • Automation Artisans Inc.
Re: TLazSerial Component
« Reply #3 on: December 23, 2020, 11:12:26 pm »
I did try that but there are several other .pas files and they did have IFDEF UNIX but there were missing constants.  I didn't want to spend a lot of time on it if was going to be a rabbit hole that would eat up a week or more.

@WP Interesting.  I hadn't thought of that.  the cthreads is a requirement of LazSerial with Linux but not Windows. 

I'll report back when I've done a bit more research.  If I can get it working then we can update the github to include macOS as one of the targets.  At the moment, it does say only for Windows and Linux.

jcdammeyer

  • Full Member
  • ***
  • Posts: 119
  • Embedded System Developer
    • Automation Artisans Inc.
Re: TLazSerial Component
« Reply #4 on: December 23, 2020, 11:30:43 pm »
@trev.  Interesting that all that work for LazSerial in the link you posted was from 2014.  In computer terms that's eons ago.

Something i don't understand though.  Serial ports go back to the first PCs.  Linux can't really function without it.  Lazarus isn't alone in this.  The same issue is there with Delphi where for at least the last 15 years I've been using the CPort component.  Each year I think my RAD Studio upgrade will have serial and each year not.

jcdammeyer

  • Full Member
  • ***
  • Posts: 119
  • Embedded System Developer
    • Automation Artisans Inc.
Re: TLazSerial Component
« Reply #5 on: December 24, 2020, 12:20:37 am »
The Poster, Jurassic Pork (JP) has made changes to LazSerial based on comments in LazSynaSer.pas.  And there are {$IFDEF DARWIN} conditionals.
However, compiling the component fails on identifier not found TIOCGSERIAL.  That doesn't happen in the windows version because that piece of code is not defined so not accessed.
Code: Pascal  [Select][+][-]
  1.     {$IFNDEF MSWINDOWS}
  2.     // Modif J.P   03/2013 - O1/2017
  3.     function GetSerialPortNames: string;
  4.     ...


However drop into the Pi Linux version and it's defined in the termios.inc.   It's not defined in the termios.inc on the Mac.

So termio.pp which is in ../rtl/darwin/ is different from termio.pp in ../rtl/linux/

Changing the Linux Run Time Library files is really above my pay grade so to speak.

For the same reason on another Linux Lazarus project I'm having trouble incorporating socketCAN support in sockets.pp while the sockets.c used by C and Python already have it.

Where do we put in a request to upgrade /rtl/termio.pp and the corresponding termios.inc to match what is available in Lazarus for Linux?

Thanks
John

[edit: argh - edited original post instead of my reply :-]
« Last Edit: December 24, 2020, 02:54:45 am by trev »

trev

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 1282
  • Former Delphi 1-7, 10.2 User
Re: TLazSerial Component
« Reply #6 on: December 24, 2020, 02:54:59 am »

Quote
The Poster, Jurassic Pork (JP) has made changes to LazSerial based on comments in LazSynaSer.pas.  And there are {$IFDEF DARWIN} conditionals. 
However, compiling the component fails on identifier not found TIOCGSERIAL. 

Although I didn't read that whole thread I pointed you to, I did notice that there was a post about defining the missing constants/identifiers.

Quote
However drop into the Pi Linux version and it's defined in the termios.inc.   It's not defined in the termios.inc on the Mac.

So termio.pp which is in ../rtl/darwin/ is different from termio.pp in ../rtl/linux/

Changing the Linux Run Time Library files is really above my pay grade so to speak. 

For the same reason on another Linux Lazarus project I'm having trouble incorporating socketCAN support in sockets.pp while the sockets.c used by C and Python already have it.

Where do we put in a request to upgrade /rtl/termio.pp and the corresponding termios.inc to match what is available in Lazarus for Linux?

The BugTracker would be the place.
Lazarus 2.1 r64368 FPC 3.3.1 r48100 macOS 10.14.6 Xcode 11.3.1
Lazarus 2.1 r64455 3.3.1 r48840   macOS 11.2.2 aarch64 Xcode 12.4
Lazarus 2.1 r61574 3.3.1 r42318 FreeBSD 12.1 amd64 VMware VM
Lazarus 2.1 r61574 3.0.4 Ubuntu 20.04 Parallels VM
Lazarus 2.0.10 3.2.0 Win10 Parallels VM

jcdammeyer

  • Full Member
  • ***
  • Posts: 119
  • Embedded System Developer
    • Automation Artisans Inc.
Re: TLazSerial Component
« Reply #7 on: December 24, 2020, 03:26:16 am »
Submitted to Bug Tracker.   

 

TinyPortal © 2005-2018