Recent

Author Topic: LazSerial for OS-X  (Read 5696 times)

rphoover

  • Newbie
  • Posts: 4
LazSerial for OS-X
« on: May 15, 2016, 04:09:38 pm »
Patch for LazSerial to work with OS-X.
Serial Port Component for Lazarus (windows, linux, and OS-X)

Attached is a patch on the latest check-in for LazSerial located on GitHub.  The latest check-in on git-hub was dated Aug 28, 2016 as of this post.  For those interested in using LazSerial with OS-X, the attached patch should get you going on OS-X.

As a part of the patch, a new property was added to the TBlockSerial class in synaser.pas, added as NonBlock.  The NonBlock property is for Unix users (Linux and OS-X included).  When NonBlock is True, the call to the FpOpen method in TBlockSerial.Connect will not block when an of CTS, DSR, or Carrier are not active.

Jurassic Pork, if the patch looks good to you, would you consider checking the changes into your GitHub repository?

Jurassic Pork

  • Hero Member
  • *****
  • Posts: 1228
Re: LazSerial for OS-X
« Reply #1 on: May 15, 2016, 08:13:11 pm »
hello,
sorry it is not me who have created the lazserial github repository  :o .
i don't know who is the creator :  it is my readme but there is no other name in the readme. 
i have no power on this repository. 
If the creator read this, say us who he is   Petr Medek ?  ;D

Friendly, J.P

« Last Edit: May 15, 2016, 08:15:38 pm by Jurassic Pork »
Jurassic computer : Sinclair ZX81 - Zilog Z80A à 3,25 MHz - RAM 1 Ko - ROM 8 Ko

srw7

  • Newbie
  • Posts: 1
Re: LazSerial for OS-X
« Reply #2 on: June 18, 2016, 12:57:16 am »
Thanks for your patch.  Before I spend too much time figuring it out I thought I would ask you.  I am porting an application that I developed on Linux to OSX.  It uses LazSerial, so I downloaded the same version you found on GitHub and patched it with your patch.  On OSX (El Capitan) I can compile the application, but as soon as I attempt to open the serial port, the application simply hangs.
The GPS Simulator in LazSerialTest does the same thing.
I'm very green at using a Mac, so I could be doing something wrong.  I was just wondering if you could point me in the right direction trying to figure this out.
Is this maybe related to the nonblock property you mentioned?
Thanks.

xinyiman

  • Hero Member
  • *****
  • Posts: 2256
    • Lazarus and Free Pascal italian community
Re: LazSerial for OS-X
« Reply #3 on: July 20, 2016, 09:33:19 am »
Hello I see now that your post. That I have to give command to apply the patch. I the patch file I saved in the folder ~/Downloads/LazSerial/

Thank you
Win10, Ubuntu and Mac
Lazarus: 2.1.0
FPC: 3.3.1

esvignolo

  • Full Member
  • ***
  • Posts: 159
  • Using FPC in Windows, Linux, Macos
Re: LazSerial for OS-X
« Reply #4 on: August 08, 2016, 07:44:37 am »
Hi @rphoover and JP, i use the component (with patch) in windows and linux work fine, but in osx (elcapitan) i can't receive buffers. the same code work in another plataforms.

Bytes:= FComPort.RecvBufferEx(@buf[0], 128, 500);  //in OSX always comeback in timeout and empty; bytes=0

Code: Pascal  [Select][+][-]
  1. var
  2.     Timeouts : integer;
  3.     buf : array [0..128] of Byte;
  4.  
  5.     SynaSerComPort: TBlockSerial;
  6.  
  7. begin
  8.   if SynaSerComPort = nil then
  9.  
  10.     SynaSerComPort:= TBlockSerial.Create;
  11.  
  12.   SynaSerComPort.LinuxLock:= False;
  13.   // ignore port locking in Linux
  14.   if not SynaSerComPort.InstanceActive then
  15.  
  16.     SynaSerComPort.Connect('/dev/ttyS1');  // or whatever com port (might be /dev/ttyUSB0 for Linux)
  17.   // add some delays to allow for serial port setup times
  18.  
  19.   sleep(500);
  20.  
  21.   SynaSerComPort.Config(19200, 8, 'N', SB1, False, False);
  22.  
  23.   sleep(300);
  24.  
  25.  
  26.     count:= SynaSerComPort.RecvBufferEx(@buf[0], 128, 500);  //Wait for 500ms per 128 byte packet //HERE is the problem in OSX
  27.     if SynaSerComPort.LastError = ErrTimeout then
  28.  
  29.     begin
  30.  
  31.       Inc(Timeouts);
  32.   // Do some sort of recovery here maybe
  33.     end;
  34. end;      
  35.  
  36.  



If u have some simple code probed and working in OSx, i will thank you.

PD: sorry for my english.



Patch for LazSerial to work with OS-X.
Serial Port Component for Lazarus (windows, linux, and OS-X)

Attached is a patch on the latest check-in for LazSerial located on GitHub.  The latest check-in on git-hub was dated Aug 28, 2016 as of this post.  For those interested in using LazSerial with OS-X, the attached patch should get you going on OS-X.

As a part of the patch, a new property was added to the TBlockSerial class in synaser.pas, added as NonBlock.  The NonBlock property is for Unix users (Linux and OS-X included).  When NonBlock is True, the call to the FpOpen method in TBlockSerial.Connect will not block when an of CTS, DSR, or Carrier are not active.

Jurassic Pork, if the patch looks good to you, would you consider checking the changes into your GitHub repository?

 

TinyPortal © 2005-2018