comp.lang.ada
 help / color / mirror / Atom feed
* file descriptor of a serial port
@ 2018-08-20 13:56 jan.de.kruyf
  2018-08-20 14:21 ` J-P. Rosen
                   ` (2 more replies)
  0 siblings, 3 replies; 14+ messages in thread
From: jan.de.kruyf @ 2018-08-20 13:56 UTC (permalink / raw)


Hallo,

I try to set up a custom baudrate on a serial port, which I believe is done with the C ioctl procedure.

However, for that I need the fd of the serial port which is hidden in the private part of GNAT.Serial_Communications.

I tried to construct a child package of GNAT.Serial_Communications but the compiler does not like that, since it does not actually compile that package.

Has anybody any idea?

Thanks,

Jan de Kruijf.


^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: file descriptor of a serial port
  2018-08-20 13:56 file descriptor of a serial port jan.de.kruyf
@ 2018-08-20 14:21 ` J-P. Rosen
  2018-08-20 14:33   ` jan.de.kruyf
  2018-08-20 15:17 ` Björn Lundin
  2018-08-20 19:52 ` Per Sandberg
  2 siblings, 1 reply; 14+ messages in thread
From: J-P. Rosen @ 2018-08-20 14:21 UTC (permalink / raw)


Le 20/08/2018 à 15:56, jan.de.kruyf@gmail.com a écrit :
> Hallo,
> 
> I try to set up a custom baudrate on a serial port, which I believe
> is done with the C ioctl procedure.
> 
GNAT.Serial_Communications has a Set procedure to set various
parameters, including baud rate. No need to play with the low level.

-- 
J-P. Rosen
Adalog
2 rue du Docteur Lombard, 92441 Issy-les-Moulineaux CEDEX
Tel: +33 1 45 29 21 52, Fax: +33 1 45 29 25 00
http://www.adalog.fr

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: file descriptor of a serial port
  2018-08-20 14:21 ` J-P. Rosen
@ 2018-08-20 14:33   ` jan.de.kruyf
  2018-08-20 14:58     ` joakimds
  2018-08-20 16:36     ` Dmitry A. Kazakov
  0 siblings, 2 replies; 14+ messages in thread
From: jan.de.kruyf @ 2018-08-20 14:33 UTC (permalink / raw)


On Monday, August 20, 2018 at 4:21:20 PM UTC+2, J-P. Rosen wrote:
> Le 20/08/2018 à 15:56, jan.....com a écrit :
> > Hallo,
> > 
> > I try to set up a custom baudrate on a serial port, which I believe
> > is done with the C ioctl procedure.
> > 
> GNAT.Serial_Communications has a Set procedure to set various
> parameters, including baud rate. No need to play with the low level.
> 
> -- 
> J-P. Rosen
> Adalog
> 2 rue du Docteur Lombard, 92441 Issy-les-Moulineaux CEDEX
> Tel: +33 1 45 29 21 52, Fax: +33 1 45 29 25 00
> http://www.adalog.fr


Thanks J-P but:

Pity, does not work.

type Data_Rate is
     (B75, B110, B150, B300, B600, B1200, B2400, B4800, B9600,
      B19200, B38400, B57600, B115200);

procedure Set
     (Port      : Serial_Port;
      Rate      : Data_Rate        := B9600;
      Bits      : Data_Bits        := CS8;
      Stop_Bits : Stop_Bits_Number := One;
      Parity    : Parity_Check     := None;
      Block     : Boolean          := True;
      Local     : Boolean          := True;
      Flow      : Flow_Control     := None;
      Timeout   : Duration         := 10.0);


I quit desperately need B100_000 to cure someone else's mess.

j.

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: file descriptor of a serial port
  2018-08-20 14:33   ` jan.de.kruyf
@ 2018-08-20 14:58     ` joakimds
  2018-08-20 15:12       ` jan.de.kruyf
  2018-08-20 16:36     ` Dmitry A. Kazakov
  1 sibling, 1 reply; 14+ messages in thread
From: joakimds @ 2018-08-20 14:58 UTC (permalink / raw)


Den måndag 20 augusti 2018 kl. 16:33:15 UTC+2 skrev jan.de...@gmail.com:
> On Monday, August 20, 2018 at 4:21:20 PM UTC+2, J-P. Rosen wrote:
> > Le 20/08/2018 à 15:56, jan.....com a écrit :
> > > Hallo,
> > > 
> > > I try to set up a custom baudrate on a serial port, which I believe
> > > is done with the C ioctl procedure.
> > > 
> > GNAT.Serial_Communications has a Set procedure to set various
> > parameters, including baud rate. No need to play with the low level.
> > 
> > -- 
> > J-P. Rosen
> > Adalog
> > 2 rue du Docteur Lombard, 92441 Issy-les-Moulineaux CEDEX
> > Tel: +33 1 45 29 21 52, Fax: +33 1 45 29 25 00
> > http://www.adalog.fr
> 
> 
> Thanks J-P but:
> 
> Pity, does not work.
> 
> type Data_Rate is
>      (B75, B110, B150, B300, B600, B1200, B2400, B4800, B9600,
>       B19200, B38400, B57600, B115200);
> 
> procedure Set
>      (Port      : Serial_Port;
>       Rate      : Data_Rate        := B9600;
>       Bits      : Data_Bits        := CS8;
>       Stop_Bits : Stop_Bits_Number := One;
>       Parity    : Parity_Check     := None;
>       Block     : Boolean          := True;
>       Local     : Boolean          := True;
>       Flow      : Flow_Control     := None;
>       Timeout   : Duration         := 10.0);
> 
> 
> I quit desperately need B100_000 to cure someone else's mess.
> 
> j.

Hallo Jan,

You could try to copy-paste the contents of GNAT.Serial_Communications into a package of your own choice and then make changes to the code as you wish, for example adding a function that gives access to the file descriptor or adding your own enumeration value B100_000 to the Data_Rate type.

Best regards,
Joakim


^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: file descriptor of a serial port
  2018-08-20 14:58     ` joakimds
@ 2018-08-20 15:12       ` jan.de.kruyf
  0 siblings, 0 replies; 14+ messages in thread
From: jan.de.kruyf @ 2018-08-20 15:12 UTC (permalink / raw)


On Monday, August 20, 2018 at 4:58:27 PM UTC+2, joak...@kth.se wrote:
> Den måndag 20 augusti 2018 kl. 16:33:15 UTC+2 skrev jan.de...@gmail.com:
> > On Monday, August 20, 2018 at 4:21:20 PM UTC+2, J-P. Rosen wrote:
> > > Le 20/08/2018 à 15:56, jan.....com a écrit :
> > > > Hallo,
> > > > 
> > > > I try to set up a custom baudrate on a serial port, which I believe
> > > > is done with the C ioctl procedure.
> > > > 
> > > GNAT.Serial_Communications has a Set procedure to set various
> > > parameters, including baud rate. No need to play with the low level.
> > > 
> > > -- 
> > > J-P. Rosen
> > > Adalog
> > > 2 rue du Docteur Lombard, 92441 Issy-les-Moulineaux CEDEX
> > > Tel: +33 1 45 29 21 52, Fax: +33 1 45 29 25 00
> > > http://www.adalog.fr
> > 
> > 
> > Thanks J-P but:
> > 
> > Pity, does not work.
> > 
> > type Data_Rate is
> >      (B75, B110, B150, B300, B600, B1200, B2400, B4800, B9600,
> >       B19200, B38400, B57600, B115200);
> > 
> > procedure Set
> >      (Port      : Serial_Port;
> >       Rate      : Data_Rate        := B9600;
> >       Bits      : Data_Bits        := CS8;
> >       Stop_Bits : Stop_Bits_Number := One;
> >       Parity    : Parity_Check     := None;
> >       Block     : Boolean          := True;
> >       Local     : Boolean          := True;
> >       Flow      : Flow_Control     := None;
> >       Timeout   : Duration         := 10.0);
> > 
> > 
> > I quit desperately need B100_000 to cure someone else's mess.
> > 
> > j.
> 
> Hallo Jan,
> 
> You could try to copy-paste the contents of GNAT.Serial_Communications into a package of your own choice and then make changes to the code as you wish, for example adding a function that gives access to the file descriptor or adding your own enumeration value B100_000 to the Data_Rate type.
> 
> Best regards,
> Joakim

Yes Joakim,
I have done that for the test harness, but I tried to keep away from it as it does not make very nice code.

Thanks,

j.

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: file descriptor of a serial port
  2018-08-20 13:56 file descriptor of a serial port jan.de.kruyf
  2018-08-20 14:21 ` J-P. Rosen
@ 2018-08-20 15:17 ` Björn Lundin
  2018-08-20 15:41   ` jan.de.kruyf
  2018-08-20 19:52 ` Per Sandberg
  2 siblings, 1 reply; 14+ messages in thread
From: Björn Lundin @ 2018-08-20 15:17 UTC (permalink / raw)


On 2018-08-20 15:56, jan.de.kruyf@gmail.com wrote:

> I tried to construct a child package of GNAT.Serial_Communications but the compiler does not like that, since it does not 
>actually compile that package.

Do you actually 'with' that new child package?
Otherwise it is strange that it is not compiled.



-- 
--
Björn

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: file descriptor of a serial port
  2018-08-20 15:17 ` Björn Lundin
@ 2018-08-20 15:41   ` jan.de.kruyf
  0 siblings, 0 replies; 14+ messages in thread
From: jan.de.kruyf @ 2018-08-20 15:41 UTC (permalink / raw)


On Monday, August 20, 2018 at 5:17:15 PM UTC+2, björn lundin wrote:
> On 2018-08-20 15:56, jan.....com wrote:
> 
> > I tried to construct a child package of GNAT.Serial_Communications but the compiler does not like that, since it does not 
> >actually compile that package.
> 
> Do you actually 'with' that new child package?
> Otherwise it is strange that it is not compiled.
> 
> 
> 
> -- 
> --
> Björn

Björn,
this is what I get on building of

package body Gnat.Serial_Communications.Baud is
.
.
procedure Get_Divisor (Port : Serial_Port)
is
   function Toint is new Ada.Unchecked_Conversion  -- line 53
     (Source => Port_Data, Target => Integer);
begin
.
.

gprbuild -Paupdi.gpr
Compile
   [Ada]          g-secoba.adb
g-secoba.adb:53:17: premature use of incomplete type
g-secoba.adb:53:17: instantiation abandoned
g-secoba.adb:57:33: "toint" is undefined
gprbuild: *** compilation phase failed

---------------------

And now I do get the compilers problem. the Port_Data type is only spelled out in the body of Gnat.Serial_Communications as an integer. So I cannot see it in the child.

Pity. So I will have to construct a hand crafted Serial_Communications package.

Thanks for your help.

j.

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: file descriptor of a serial port
  2018-08-20 14:33   ` jan.de.kruyf
  2018-08-20 14:58     ` joakimds
@ 2018-08-20 16:36     ` Dmitry A. Kazakov
  2018-08-20 19:10       ` jan.de.kruyf
  1 sibling, 1 reply; 14+ messages in thread
From: Dmitry A. Kazakov @ 2018-08-20 16:36 UTC (permalink / raw)


On 2018-08-20 16:33, jan.de.kruyf@gmail.com wrote:
> On Monday, August 20, 2018 at 4:21:20 PM UTC+2, J-P. Rosen wrote:
>> Le 20/08/2018 à 15:56, jan.....com a écrit :
>>> Hallo,
>>>
>>> I try to set up a custom baudrate on a serial port, which I believe
>>> is done with the C ioctl procedure.
>>>
>> GNAT.Serial_Communications has a Set procedure to set various
>> parameters, including baud rate. No need to play with the low level.
>>
>> -- 
>> J-P. Rosen
>> Adalog
>> 2 rue du Docteur Lombard, 92441 Issy-les-Moulineaux CEDEX
>> Tel: +33 1 45 29 21 52, Fax: +33 1 45 29 25 00
>> http://www.adalog.fr
> 
> Pity, does not work.

How do you know it does not? The call goes right to the OS, at least 
under Windows. There is little one could do wrong or differently to the 
GNAT implementation.

Maybe the settings you are using are incorrect or the way you are 
reading from the port.

-- 
Regards,
Dmitry A. Kazakov
http://www.dmitry-kazakov.de


^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: file descriptor of a serial port
  2018-08-20 16:36     ` Dmitry A. Kazakov
@ 2018-08-20 19:10       ` jan.de.kruyf
  2018-08-20 19:26         ` Dmitry A. Kazakov
  0 siblings, 1 reply; 14+ messages in thread
From: jan.de.kruyf @ 2018-08-20 19:10 UTC (permalink / raw)


On Monday, August 20, 2018 at 6:36:31 PM UTC+2, Dmitry A. Kazakov wrote:
> On 2018-08-20 16:33, jan......com wrote:
> > On Monday, August 20, 2018 at 4:21:20 PM UTC+2, J-P. Rosen wrote:
> >> Le 20/08/2018 à 15:56, jan.....com a écrit :
> >>> Hallo,
> >>>
> >>> I try to set up a custom baudrate on a serial port, which I believe
> >>> is done with the C ioctl procedure.
> >>>
> >> GNAT.Serial_Communications has a Set procedure to set various
> >> parameters, including baud rate. No need to play with the low level.
> >>
> >> -- 
> >> J-P. Rosen
> >> Adalog
> >> 2 rue du Docteur Lombard, 92441 Issy-les-Moulineaux CEDEX
> >> Tel: +33 1 45 29 21 52, Fax: +33 1 45 29 25 00
> >> http://www.adalog.fr
> > 
> > Pity, does not work.
> 
> How do you know it does not? The call goes right to the OS, at least 
> under Windows. There is little one could do wrong or differently to the 
> GNAT implementation.
> 
> Maybe the settings you are using are incorrect or the way you are 
> reading from the port.
> 
> -- 
> Regards,
> Dmitry A. Kazakov
> http://www.dmitry-kazakov.de

You did not comprehend the bottom line of that post Dmitry!

j.

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: file descriptor of a serial port
  2018-08-20 19:10       ` jan.de.kruyf
@ 2018-08-20 19:26         ` Dmitry A. Kazakov
  2018-08-21  7:09           ` jan.de.kruyf
  0 siblings, 1 reply; 14+ messages in thread
From: Dmitry A. Kazakov @ 2018-08-20 19:26 UTC (permalink / raw)


On 2018-08-20 21:10, jan.de.kruyf@gmail.com wrote:
> On Monday, August 20, 2018 at 6:36:31 PM UTC+2, Dmitry A. Kazakov wrote:
>> On 2018-08-20 16:33, jan......com wrote:
>>> On Monday, August 20, 2018 at 4:21:20 PM UTC+2, J-P. Rosen wrote:
>>>> Le 20/08/2018 à 15:56, jan.....com a écrit :
>>>>> Hallo,
>>>>>
>>>>> I try to set up a custom baudrate on a serial port, which I believe
>>>>> is done with the C ioctl procedure.
>>>>>
>>>> GNAT.Serial_Communications has a Set procedure to set various
>>>> parameters, including baud rate. No need to play with the low level.
>>>>
>>>> -- 
>>>> J-P. Rosen
>>>> Adalog
>>>> 2 rue du Docteur Lombard, 92441 Issy-les-Moulineaux CEDEX
>>>> Tel: +33 1 45 29 21 52, Fax: +33 1 45 29 25 00
>>>> http://www.adalog.fr
>>>
>>> Pity, does not work.
>>
>> How do you know it does not? The call goes right to the OS, at least
>> under Windows. There is little one could do wrong or differently to the
>> GNAT implementation.
>>
>> Maybe the settings you are using are incorrect or the way you are
>> reading from the port.

E.g. depending on the settings and how poorly the other party was 
designed, which quite frequently quite poorly, you must be always 
reading the next byte from the COM port in order to prevent deadlock. 
Sometimes you have to read out all garbage before sending anything to 
the other side etc.

-- 
Regards,
Dmitry A. Kazakov
http://www.dmitry-kazakov.de

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: file descriptor of a serial port
  2018-08-20 13:56 file descriptor of a serial port jan.de.kruyf
  2018-08-20 14:21 ` J-P. Rosen
  2018-08-20 15:17 ` Björn Lundin
@ 2018-08-20 19:52 ` Per Sandberg
  2018-08-21  7:19   ` jan.de.kruyf
  2 siblings, 1 reply; 14+ messages in thread
From: Per Sandberg @ 2018-08-20 19:52 UTC (permalink / raw)


Why don't patch your own "GNAT.Serial_Communications" and put in your 
own projects sources.
--------------------------------------------------------------------
package GNAT.Serial_Communications is
...
    type Data_Rate is
      (B75, B110, B150, B300, B600, B1200, B2400, B4800, B9600,
       B19200, B38400, B57600, B100000, B115200);
...
private
...
    Data_Rate_Value : constant array (Data_Rate) of 
Interfaces.C.unsigned ...
                         B57600  =>  57_600,
                         B100000 => 100_000,
                         B115200 => 115_200);

end GNAT.Serial_Communications;
--------------------------------------------------------------------
package body GNAT.Serial_Communications is
...
    C_Data_Rate : constant array (Data_Rate) of unsigned :=
...
                     B57600  => OSC.B57600,
                     B100000 => 0010010, --<<bits/termios.h:162
                     B115200 => OSC.B115200);
...
end GNAT.Serial_Communications;
--------------------------------------------------------------------
project Serial_Mess is
    for Source_Dirs use ("src");
    for Object_Dir use ".obj";
    for Main use ("main.adb");

    package Compiler is
       for Switches ("g-sercom.adb") use ("-gnatg");
    end Compiler;
end Serial_Mess;
--------------------------------------------------------------------
And you are done.

Did the same thing some years ago for B75 before it was implemented in 
the distributed Run-times.
/P



On 08/20/18 15:56, jan.de.kruyf@gmail.com wrote:
> Hallo,
> 
> I try to set up a custom baudrate on a serial port, which I believe is done with the C ioctl procedure.
> 
> However, for that I need the fd of the serial port which is hidden in the private part of GNAT.Serial_Communications.
> 
> I tried to construct a child package of GNAT.Serial_Communications but the compiler does not like that, since it does not actually compile that package.
> 
> Has anybody any idea?
> 
> Thanks,
> 
> Jan de Kruijf.
> 

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: file descriptor of a serial port
  2018-08-20 19:26         ` Dmitry A. Kazakov
@ 2018-08-21  7:09           ` jan.de.kruyf
  0 siblings, 0 replies; 14+ messages in thread
From: jan.de.kruyf @ 2018-08-21  7:09 UTC (permalink / raw)


On Monday, August 20, 2018 at 9:26:57 PM UTC+2, Dmitry A. Kazakov wrote:
> On 2018-08-20 21:10, jan.....com wrote:
> > On Monday, August 20, 2018 at 6:36:31 PM UTC+2, Dmitry A. Kazakov wrote:
> >> On 2018-08-20 16:33, jan......com wrote:
> >>> On Monday, August 20, 2018 at 4:21:20 PM UTC+2, J-P. Rosen wrote:
> >>>> Le 20/08/2018 à 15:56, jan.....com a écrit :
> >>>>> Hallo,
> >>>>>
> >>>>> I try to set up a custom baudrate on a serial port, which I believe
> >>>>> is done with the C ioctl procedure.
> >>>>>
> >>>> GNAT.Serial_Communications has a Set procedure to set various
> >>>> parameters, including baud rate. No need to play with the low level.
> >>>>
> >>>> -- 
> >>>> J-P. Rosen
> >>>> Adalog
> >>>> 2 rue du Docteur Lombard, 92441 Issy-les-Moulineaux CEDEX
> >>>> Tel: +33 1 45 29 21 52, Fax: +33 1 45 29 25 00
> >>>> http://www.adalog.fr
> >>>
> >>> Pity, does not work.
> >>
> >> How do you know it does not? The call goes right to the OS, at least
> >> under Windows. There is little one could do wrong or differently to the
> >> GNAT implementation.
> >>
> >> Maybe the settings you are using are incorrect or the way you are
> >> reading from the port.
> 
> E.g. depending on the settings and how poorly the other party was 
> designed, which quite frequently quite poorly, you must be always 
> reading the next byte from the COM port in order to prevent deadlock. 
> Sometimes you have to read out all garbage before sending anything to 
> the other side etc.
> 
> -- 
> Regards,
> Dmitry A. Kazakov
> http://www.dmitry-kazakov.de

Dmitry good morning to you,

I think you still misunderstand the requirement. I need a very non-standard baud-rate which Gnat does not cater for, most likely because Linux can only be persuaded by a big roundabout to have a non-standard baud rate on a port.

So I was hoping to test the big roundabout to see if it will work with the FTDI driver in Linux. If not I will have to write a complete new serial port driver based on the proprietary FDTI driver from the chip manufacturers.

Cheers,
j.

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: file descriptor of a serial port
  2018-08-20 19:52 ` Per Sandberg
@ 2018-08-21  7:19   ` jan.de.kruyf
  2018-08-22  7:03     ` jan.de.kruyf
  0 siblings, 1 reply; 14+ messages in thread
From: jan.de.kruyf @ 2018-08-21  7:19 UTC (permalink / raw)


On Monday, August 20, 2018 at 9:52:28 PM UTC+2, Per Sandberg wrote:
> Why don't patch your own "GNAT.Serial_Communications" and put in your 
> own projects sources.
> --------------------------------------------------------------------
> package GNAT.Serial_Communications is
> ...
>     type Data_Rate is
>       (B75, B110, B150, B300, B600, B1200, B2400, B4800, B9600,
>        B19200, B38400, B57600, B100000, B115200);
> ...
> private
> ...
>     Data_Rate_Value : constant array (Data_Rate) of 
> Interfaces.C.unsigned ...
>                          B57600  =>  57_600,
>                          B100000 => 100_000,
>                          B115200 => 115_200);
> 
> end GNAT.Serial_Communications;
> --------------------------------------------------------------------
> package body GNAT.Serial_Communications is
> ...
>     C_Data_Rate : constant array (Data_Rate) of unsigned :=
> ...
>                      B57600  => OSC.B57600,
>                      B100000 => 0010010, --<<bits/termios.h:162
>                      B115200 => OSC.B115200);
> ...
> end GNAT.Serial_Communications;
> --------------------------------------------------------------------
> project Serial_Mess is
>     for Source_Dirs use ("src");
>     for Object_Dir use ".obj";
>     for Main use ("main.adb");
> 
>     package Compiler is
>        for Switches ("g-sercom.adb") use ("-gnatg");
>     end Compiler;
> end Serial_Mess;
> --------------------------------------------------------------------
> And you are done.
> 
> Did the same thing some years ago for B75 before it was implemented in 
> the distributed Run-times.
> /P
> 
> 
> 
> On 08/20/18 15:56, jan.....com wrote:
> > Hallo,
> > 
> > I try to set up a custom baudrate on a serial port, which I believe is done with the C ioctl procedure.
> > 
> > However, for that I need the fd of the serial port which is hidden in the private part of GNAT.Serial_Communications.
> > 
> > I tried to construct a child package of GNAT.Serial_Communications but the compiler does not like that, since it does not actually compile that package.
> > 
> > Has anybody any idea?
> > 
> > Thanks,
> > 
> > Jan de Kruijf.
> >

Per,
Yes, it is not as simple as you make it, but that I will do. The whole issue comes about because I need to read a serial port at 100kBaud which Linux does not handle by normal means. You need to give a custom divider (i.e. not preset in the serial driver) with ioctl

See here:
stackoverflow.com/questions/3192478/specifying-non-standard-baud-rate-for-ftdi-virtual-serial-port-under-linux#

Enjoy your day.

j.


^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: file descriptor of a serial port
  2018-08-21  7:19   ` jan.de.kruyf
@ 2018-08-22  7:03     ` jan.de.kruyf
  0 siblings, 0 replies; 14+ messages in thread
From: jan.de.kruyf @ 2018-08-22  7:03 UTC (permalink / raw)


On Tuesday, August 21, 2018 at 9:19:36 AM UTC+2, jan.de...@gmail.com wrote:
> On Monday, August 20, 2018 at 9:52:28 PM UTC+2, Per Sandberg wrote:
> > Why don't patch your own "GNAT.Serial_Communications" and put in your 
> > own projects sources.
> > --------------------------------------------------------------------
> > package GNAT.Serial_Communications is
> > ...
> >     type Data_Rate is
> >       (B75, B110, B150, B300, B600, B1200, B2400, B4800, B9600,
> >        B19200, B38400, B57600, B100000, B115200);
> > ...
> > private
> > ...
> >     Data_Rate_Value : constant array (Data_Rate) of 
> > Interfaces.C.unsigned ...
> >                          B57600  =>  57_600,
> >                          B100000 => 100_000,
> >                          B115200 => 115_200);
> > 
> > end GNAT.Serial_Communications;
> > --------------------------------------------------------------------
> > package body GNAT.Serial_Communications is
> > ...
> >     C_Data_Rate : constant array (Data_Rate) of unsigned :=
> > ...
> >                      B57600  => OSC.B57600,
> >                      B100000 => 0010010, --<<bits/termios.h:162
> >                      B115200 => OSC.B115200);
> > ...
> > end GNAT.Serial_Communications;
> > --------------------------------------------------------------------
> > project Serial_Mess is
> >     for Source_Dirs use ("src");
> >     for Object_Dir use ".obj";
> >     for Main use ("main.adb");
> > 
> >     package Compiler is
> >        for Switches ("g-sercom.adb") use ("-gnatg");
> >     end Compiler;
> > end Serial_Mess;
> > --------------------------------------------------------------------
> > And you are done.
> > 
> > Did the same thing some years ago for B75 before it was implemented in 
> > the distributed Run-times.
> > /P
> > 
> > 
> > 
> > On 08/20/18 15:56, jan.....com wrote:
> > > Hallo,
> > > 
> > > I try to set up a custom baudrate on a serial port, which I believe is done with the C ioctl procedure.
> > > 
> > > However, for that I need the fd of the serial port which is hidden in the private part of GNAT.Serial_Communications.
> > > 
> > > I tried to construct a child package of GNAT.Serial_Communications but the compiler does not like that, since it does not actually compile that package.
> > > 
> > > Has anybody any idea?
> > > 
> > > Thanks,
> > > 
> > > Jan de Kruijf.
> > >
> 
> Per,
> Yes, it is not as simple as you make it, but that I will do. The whole issue comes about because I need to read a serial port at 100kBaud which Linux does not handle by normal means. You need to give a custom divider (i.e. not preset in the serial driver) with ioctl
> 
> See here:
> stackoverflow.com/questions/3192478/specifying-non-standard-baud-rate-for-ftdi-virtual-serial-port-under-linux#
> 
> Enjoy your day.
> 
> j.

Rejoice with me, the stackoverflow.com recipe works.
I get 100kBaud now. 
The code is here for anybody who might ever need it.

Thanks for all the help.

j.

^ permalink raw reply	[flat|nested] 14+ messages in thread

end of thread, other threads:[~2018-08-22  7:03 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-08-20 13:56 file descriptor of a serial port jan.de.kruyf
2018-08-20 14:21 ` J-P. Rosen
2018-08-20 14:33   ` jan.de.kruyf
2018-08-20 14:58     ` joakimds
2018-08-20 15:12       ` jan.de.kruyf
2018-08-20 16:36     ` Dmitry A. Kazakov
2018-08-20 19:10       ` jan.de.kruyf
2018-08-20 19:26         ` Dmitry A. Kazakov
2018-08-21  7:09           ` jan.de.kruyf
2018-08-20 15:17 ` Björn Lundin
2018-08-20 15:41   ` jan.de.kruyf
2018-08-20 19:52 ` Per Sandberg
2018-08-21  7:19   ` jan.de.kruyf
2018-08-22  7:03     ` jan.de.kruyf

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox