comp.lang.ada
 help / color / mirror / Atom feed
From: tonyg <tonythegair@gmail.com>
Subject: Re: GNAT.Serial_Communications
Date: Fri, 15 Apr 2011 09:32:32 -0700 (PDT)
Date: 2011-04-15T09:32:32-07:00	[thread overview]
Message-ID: <d4dc0334-8b72-4c16-84df-a02d99f18cd9@e26g2000vbz.googlegroups.com> (raw)
In-Reply-To: 9af0087d-9637-40d9-8c30-2e06c2d1e4f4@o26g2000vby.googlegroups.com

On Apr 15, 2:58 pm, tonyg <tonytheg...@gmail.com> wrote:
> On Apr 14, 6:52 pm, Chris Moore <zmo...@ntlworld.com> wrote:
>
>
>
> > On 13/04/2011 22:12, tonyg wrote:
>
> > > Its actually blocking on top of the write. Also I've discovered after
> > > much experimentation that the writes are not doing the job when it
> > > does not block up. Usually it blocks up after 3-4 write attempts. I
> > > expect I need to discover what is happening at the other end of the
> > > wire, but its my first experience of using a serial port for anything.
>
> > > I suspect there is an option I am not engaging in the setting up of
> > > the port. I am using the gpl version so I was thinking there could be
> > > a bug that is not in the gnat pro version, but I don't want to be a
> > > bad craftsman :) and gnat are usually pretty much on top of stuff like
> > > that from previous experience, but then again its a relatively new
> > > addition to the gnat compiler and no ones perfect. But.... its usually
> > > me.....
>
> > I suspect it's the speed setting.  Serial ports default to 9600 baud
> > which is slow so you're filling the buffers up with the first few writes
> > as they're unable to get the data out quick enough and then they start
> > to block cos there's nowhere to put the data.
>
> > > Saying that though I am successfully reading from the port the
> > > incoming messages although they do appear in sections and I have to
> > > keep re reading the port to get the full message...
>
> > This is how serial interfaces usually work.  The lowest level read
> > function returns the number of bytes actually read.
>
> I found the problem. Its very embarassing and completely my own fault!
> Basically I did not have the write access to the usb port! I am using
> ubuntu for this. Just to let those who are interested know.

Actually this is not the problem I spoke too soon. Minicom will talk
and read the correct values.
However gnat will read correctly but not write to the port properly,
but its not hanging anymore so thats a plus. I just cannot see why
minicom would write the string correctly to the port but when I write
the string to the port through gnat.serial_communication it does not
work!!

      GNAT.Serial_Communications.Write(Port   => The_Port,
                        Buffer =>
String_To_Stream(Broadcast_Message));

  function String_To_Stream ( The_String : in String) return
Ada.Streams.Stream_Element_Array is

      Return_Value :
Ada.Streams.Stream_Element_Array(1..The_String'length);

   begin
      Put (" Start of Data out  :- ");
      for count in
1..Ada.Streams.Stream_Element_Offset(The_String'Length) loop
         Return_Value(count) :=
character'pos(The_String(Integer(count)));
         int_io.Put(Integer(Return_Value(count)));
      end loop;
      Put (" End of Data out ");
	Put_Line (The_String);

      Return Return_Value(1..The_String'Length);
   end String_To_Stream;

Is there anything you can see thats wrong there ?



  reply	other threads:[~2011-04-15 16:32 UTC|newest]

Thread overview: 46+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-04-11 10:26 GNAT.Serial_Communications tonyg
2011-04-11 11:11 ` GNAT.Serial_Communications Brian Drummond
2011-04-13  7:49   ` GNAT.Serial_Communications tonyg
2011-04-13 14:12     ` GNAT.Serial_Communications Alex Mentis
2011-04-13 21:12       ` GNAT.Serial_Communications tonyg
2011-04-14 13:15         ` GNAT.Serial_Communications Alex Mentis
2011-04-14 17:52         ` GNAT.Serial_Communications Chris Moore
2011-04-15 13:58           ` GNAT.Serial_Communications tonyg
2011-04-15 16:32             ` tonyg [this message]
2011-04-15 17:12               ` GNAT.Serial_Communications Simon Clubley
2011-04-15 17:32                 ` GNAT.Serial_Communications tonyg
2011-04-15 18:49                   ` GNAT.Serial_Communications Simon Clubley
2011-04-16  0:07                     ` GNAT.Serial_Communications tonyg
2011-04-16  8:29                       ` GNAT.Serial_Communications Simon Clubley
2011-04-16 10:19                         ` GNAT.Serial_Communications tonyg
2011-04-16 10:33                           ` GNAT.Serial_Communications tonyg
2011-04-16 11:15                             ` GNAT.Serial_Communications Brian Drummond
2011-04-16 12:03                               ` GNAT.Serial_Communications tonyg
2011-04-16 15:12                                 ` GNAT.Serial_Communications Simon Clubley
2011-04-18 20:31                                   ` GNAT.Serial_Communications tonyg
2011-04-18 20:43                                   ` GNAT.Serial_Communications tonyg
2011-04-19 11:46                                     ` GNAT.Serial_Communications tonyg
2011-04-19 12:09                                       ` GNAT.Serial_Communications Ludovic Brenta
2011-04-19 13:53                                         ` GNAT.Serial_Communications tonyg
2011-04-19 19:06                                           ` GNAT.Serial_Communications Ludovic Brenta
2011-04-19 19:57                                         ` GNAT.Serial_Communications Alex Mentis
2011-04-20 11:37                                           ` GNAT.Serial_Communications tonyg
2011-04-20 14:22                                             ` GNAT.Serial_Communications Alex Mentis
2011-04-21  9:00                                               ` GNAT.Serial_Communications tonyg
2011-04-21 13:28                                                 ` GNAT.Serial_Communications Alex Mentis
2011-04-22 13:55                                                 ` GNAT.Serial_Communications Alex Mentis
2011-04-22 15:52                                                   ` GNAT.Serial_Communications Brian Drummond
2011-04-19 13:32                                       ` GNAT.Serial_Communications Simon Clubley
2011-04-19 16:59                                         ` GNAT.Serial_Communications Simon Clubley
2011-04-20 10:17                                         ` GNAT.Serial_Communications Brian Drummond
2011-04-20 20:46                                         ` GNAT.Serial_Communications Brian Drummond
2011-04-21  4:28                                           ` GNAT.Serial_Communications Simon Wright
2011-04-21  9:12                                             ` GNAT.Serial_Communications tonyg
2011-04-21 10:14                                               ` GNAT.Serial_Communications tonyg
2011-04-22 15:54                                             ` GNAT.Serial_Communications Brian Drummond
2011-04-22 16:14                                               ` GNAT.Serial_Communications Simon Wright
2011-04-21 11:56                                           ` GNAT.Serial_Communications Simon Clubley
2011-04-15 18:01               ` GNAT.Serial_Communications Jeffrey Carter
2011-04-16 10:21                 ` GNAT.Serial_Communications tonyg
2016-12-01 19:58 ` GNAT.Serial_Communications mario.blunk.gplus
2017-03-20 15:20   ` GNAT.Serial_Communications Jacob Sparre Andersen
replies disabled

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