Recent

Author Topic: serial.pp on macos  (Read 784 times)

Jon

  • New Member
  • *
  • Posts: 23
serial.pp on macos
« on: May 02, 2022, 06:50:23 pm »
I wrote simple app that sends and receives strings via rs232.
It uses serial.pp included in packages/rtl-extra.
There exists both a windows and *nix version:

fpcsrc/packages/rtl-extra/src/win/serial.pp
fpcsrc/packages/rtl-extra/src/unix/serial.pp

My only computer runs Linux so I cross compile as required.
Does anyone know if serial.pp will compile / run on macos?


MarkMLl

  • Hero Member
  • *****
  • Posts: 6683
Re: serial.pp on macos
« Reply #1 on: May 03, 2022, 08:18:07 am »
See this recent thread (please note that the forum has a search facility):

https://forum.lazarus.freepascal.org/index.php/topic,58709.0.html

I did the last maintenance on that unit, but had no Mac on which to test it. I'd expect the unix variant to work without problems except possibly for the functions that use the select() syscall, where there are two possibilities depending on whether or not select() updates the parameter block on exit.

My understanding- which could be wrong- is that the Mac's operating system is BSD-like, so would expect that using the Solaris/SunOS-style select() would be appropriate.

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

Jon

  • New Member
  • *
  • Posts: 23
Re: serial.pp on macos
« Reply #2 on: May 03, 2022, 05:19:25 pm »
Thank you MarkMLI, yes I had searched and found the other thread but was unsure of what was meant by a select() syscall and also if cross-compiling had any impact on the result.

Can you explain what Solaris/SunOS-style select() means and how I can enable it? I have been away from development for a long time and have no experience with Mac so please forgive my "newbie" questions (as the youngsters would say!).

MarkMLl

  • Hero Member
  • *****
  • Posts: 6683
Re: serial.pp on macos
« Reply #3 on: May 03, 2022, 05:46:51 pm »
Look at the comments near the end of the unit:

Code: Pascal  [Select][+][-]
  1. // Note: this variant of fpSelect() is a thin wrapper around the kernel's syscall.
  2. // In the case of Linux the syscall DOES update the timeout parameter.
  3. ...
  4. // Note: this variant of fpSelect() is a thin wrapper around the kernel's syscall.
  5. // In the case of Solaris the syscall DOES NOT update the timeout parameter.
  6.  

select() (as a unix syscall) and fpSelect() (as a Pascal wrapper) takes a collection of file handles as parameters, plus a timeout. It returns either when there is activity associated with one of the handles, or when the timeout expires.

Linux updates the timeout parameter before exit, while SunOS/Solaris doesn't, so on Linux you can see how long an overall timeout has left on the clock.

Or something like that. It's a good 15 years since I worked on that, and I'm not as young as I used to be either :-)

This shouldn't affect compilation, or code that doesn't use the four-parameter variant of SerReadTimeout(). And since the conditional tests for Linux rather than for SunOS etc., if the Mac's OS- as a Berkeley derivative- works the same then it should be OK without modification.

Note the test programs posted in the other thread, but the stty stuff is untested on anything other than Linux.

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

 

TinyPortal © 2005-2018