Forum > Packages and Libraries
Synaser and Mac Lion
(1/1)
JimKueneman:
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: ---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;
--- End code ---
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: ---{$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}
--- End code ---
What am I doing wrong?
Thanks,
Jim
JimKueneman:
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:
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:
i have the same problem ... can you tell us more ?
Thanks !
Navigation
[0] Message Index