Recent

Author Topic: Synaser and Mac Lion  (Read 5232 times)

JimKueneman

  • Full Member
  • ***
  • Posts: 246
Synaser and Mac Lion
« on: August 01, 2012, 06:44:13 am »
I am just learning about Mac and Unix so this may be just me but I am trying to open a USB comport with Lazarus 9.30.4 and FCP 2.6.0 using Synaser.

This is what I did

Code: [Select]
procedure TFormMain.ButtonConnectClick(Sender: TObject);
begin
  if Connected then
  begin
    ser.CloseSocket;
    ButtonConnect.Caption:='Connect';
    Connected:=False
  end else
  begin
    ser.Connect('/dev/cu.usbserial-A4003I59');
    Sleep(1000);
    ser.Config(StrToInt(FormSettings.EditBaudRate.Text), 8, 'N', 0, False, False);      // FTDI Driver uses no stop bits for non-standard baud rates.
    ButtonConnect.Caption:='Disconnect';
    Connected:=True
  end;
end;   

This was after learning that the tty driver will block on "open" if the Data Carrier Detect line is not high  :-X

Now it will return a valid file handle but when flush is called I get a "Communication error 25: Not a typewriter" error.  I have traced through the code looking for when the error is returned and it is in the ioctl( ) call in this Synaser function that is called in the Connect() method:

Code: [Select]
{$IFNDEF MSWINDOWS}
procedure TBlockSerial.Purge;
begin
  {$IFNDEF FPC}
  SerialCheck(ioctl(FHandle, TCFLSH, TCIOFLUSH));
  {$ELSE}
    {$IFDEF DARWIN}
    SerialCheck(fpioctl(FHandle, TCIOFLUSH, Pointer(PtrInt(TCIOFLUSH))));  << Fixed per another thread here.
    {$ELSE}
    SerialCheck(fpioctl(FHandle, TCFLSH, Pointer(PtrInt(TCIOFLUSH))));
    {$ENDIF}
  {$ENDIF}
  FBuffer := '';
  ExceptCheck;
end;
{$ELSE} 

What am I doing wrong?

Thanks,
Jim
« Last Edit: August 01, 2012, 03:03:07 pm by JimKueneman »

JimKueneman

  • Full Member
  • ***
  • Posts: 246
Re: Synaser and Mac Lion
« Reply #1 on: August 02, 2012, 02:53:41 pm »
Let me ask another question.  Does any one have a simple example of connecting to a Mac USB serial port on Lazarus/Free Pascal?

I have even tried using the Apple example and it does not connect correctly:

https://developer.apple.com/library/mac/#samplecode/SerialPortSample/Listings/SerialPortSample_c.html

Jim

JimKueneman

  • Full Member
  • ***
  • Posts: 246
Re: Synaser and Mac Lion
« Reply #2 on: August 16, 2012, 03:09:47 pm »
FYI was was contacted off list with the fixes to Synaser to get it to work correctly with the Mac at non standard baud rates (USB Serial).  If anyone needs to know how to do this drop me a line.

Jim

kitsaros

  • New Member
  • *
  • Posts: 27
Re: Synaser and Mac Lion
« Reply #3 on: September 29, 2012, 09:57:39 am »
i have the same problem ... can you tell us more ?
Thanks !

 

TinyPortal © 2005-2018