comp.lang.ada
 help / color / mirror / Atom feed
From: jan.de.kruyf@gmail.com
Subject: Re: file descriptor of a serial port
Date: Tue, 21 Aug 2018 00:19:35 -0700 (PDT)
Date: 2018-08-21T00:19:35-07:00	[thread overview]
Message-ID: <f8db92cc-707a-46b4-8aea-7fb0e3b7d823@googlegroups.com> (raw)
In-Reply-To: <_ZEeD.60176$4w.12143@fx44.am4>

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.


  reply	other threads:[~2018-08-21  7:19 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 [this message]
2018-08-22  7:03     ` jan.de.kruyf
replies disabled

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