[fpc-pascal] serial ports under Unix using Freepascal

2007-10-04 Thread [EMAIL PROTECTED]
Hi!

I'm creating a component that handles serial port in windows/unix. Under
Windows I include in uses the unit windows, that open, close, read, write,
test if the configuration of serial port is valid (some set of
configurations of baudrate, stop bits and parity is invalid in windows)  and
if serial port exists.

Under Unix I found the unit Serial, that open, close, read and write. How to
test if serial port exist? Unix accept any set of configurations of  the
serial port? I see fpopen that return the handle of serial port but I not
found anything that describes error codes returned by this function in fpc
rtl documentation.

Somebody have tried to do this?

info: I newbie in FPC Unix (FreeBSD).
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] serial ports under Unix using Freepascal

2007-10-04 Thread Luca Olivetti

En/na [EMAIL PROTECTED] ha escrit:

Hi!

I'm creating a component that handles serial port in windows/unix. Under 
Windows I include in uses the unit windows, that open, close, read, 
write, test if the configuration of serial port is valid (some set of 
configurations of baudrate, stop bits and parity is invalid in windows)  
and if serial port exists.


Under Unix I found the unit Serial, that open, close, read and write. 
How to test if serial port exist? Unix accept any set of configurations 
of  the serial port? I see fpopen that return the handle of serial port 
but I not found anything that describes error codes returned by this 
function in fpc rtl documentation.


Somebody have tried to do this?


I'd suggest to take a look at synaser:

http://synapse.ararat.cz (it's included in synasnap.zip)

Bye
--
Luca

___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] serial ports under Unix using Freepascal

2007-10-04 Thread Marc Santhoff
Am Mittwoch, den 03.10.2007, 16:53 -0300 schrieb
[EMAIL PROTECTED]:
> Hi!
> 
> I'm creating a component that handles serial port in windows/unix.
> Under Windows I include in uses the unit windows, that open, close,
> read, write, test if the configuration of serial port is valid (some
> set of configurations of baudrate, stop bits and parity is invalid in
> windows)  and if serial port exists. 
> 
> Under Unix I found the unit Serial, that open, close, read and write.
> How to test if serial port exist? Unix accept any set of
> configurations of  the serial port? I see fpopen that return the
> handle of serial port but I not found anything that describes error
> codes returned by this function in fpc rtl documentation. 

Normally the libc function "tcsetattr()" is used to set the ports
parameters, as you can see in the source of serial.pp at the end of
"SetSerParams()". That is the place where a check should evaluate the
return code of tcsetattr and return the OS error code if it is -1. This
is a spot where serial.pp should be improved.

FPC exhibits the systems error code by using GetOSError() and
RaiseOSError(), both in sysutils.

If you want to set up the port directly you can use something like this
with the parameters you need:

  var
tios: termios;

BEGIN
...

(*
SerSetParams(fCom, 1200, 7, NoneParity, 2, []);
*)

r := 0;
fillchar(tios, sizeof(tios), #0);

tios.c_ispeed := B1200;
tios.c_ospeed := B1200;

tios.c_cflag := CREAD or CLOCAL or CS7 or CSTOPB;

tios.c_oflag := 0;
tios.c_iflag := IGNBRK OR IGNPAR;
tios.c_lflag := 0;

r := tcsetattr(fCom, TCSANOW, tios);
if (r = -1) then begin
writeln(stderr, 'tcsetattr failed!');
writeln(stderr, 'errno is ', errno);
fpClose(fCom);
halt(1);
end;

That code is from a program I made and is actually running on FreeBSD
4.11.

One other hint: FreeBSD has very good manpages, try "man sio" and "man
tcsetattr" and so on.

Have fun,
Marc


___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


[fpc-pascal] function alias

2007-10-04 Thread Mattias Gaertner
How can I create an alias for a function?
For example:

procedure DoSomething(...params...); cdecl; external 'useful';

const
  DoAliasSomething = DoSomething;

fpc does not allow this. So how can it be done?


Mattias
 
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] function alias

2007-10-04 Thread Michael Van Canneyt


On Thu, 4 Oct 2007, Mattias Gaertner wrote:

> How can I create an alias for a function?
> For example:
> 
> procedure DoSomething(...params...); cdecl; external 'useful';
> 
> const
>   DoAliasSomething = DoSomething;
> 
> fpc does not allow this. So how can it be done?

program test;

procedure something; external name 'something';

Type
  TProcedure = Procedure;

const
  DoSomething : TProcedure = @something;

begin
end.

Works fine.

Michael.
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] function alias

2007-10-04 Thread Mattias Gaertner
On Thu, 4 Oct 2007 19:58:08 +0200 (CEST)
Michael Van Canneyt <[EMAIL PROTECTED]> wrote:

> 
> 
> On Thu, 4 Oct 2007, Mattias Gaertner wrote:
> 
> > How can I create an alias for a function?
> > For example:
> > 
> > procedure DoSomething(...params...); cdecl; external 'useful';
> > 
> > const
> >   DoAliasSomething = DoSomething;
> > 
> > fpc does not allow this. So how can it be done?
> 
> program test;
> 
> procedure something; external name 'something';
> 
> Type
>   TProcedure = Procedure;
> 
> const
>   DoSomething : TProcedure = @something;
> 
> begin
> end.
> 
> Works fine.

Yes, but I hoped to declare it in situ - without adding another type. ;)
The reason is that I'm auto translating some C headers that contains
aliases for functions.


Mattias
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] function alias

2007-10-04 Thread Daniël Mantione


Op Thu, 4 Oct 2007, schreef Mattias Gaertner:

> Yes, but I hoped to declare it in situ - without adding another type. ;)
> The reason is that I'm auto translating some C headers that contains
> aliases for functions.

procedure DoAliasSomething(...params...); cdecl; external 'useful';

... is another approach.

Daniël___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal

[fpc-pascal] Has anyone ported fpc-pascal to Solaris ?

2007-10-04 Thread Dennis Clarke

I wanted to create a package for Solaris users and wondered if anyone had
made the attempt.

-
Dennis Clarke

___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal