comp.lang.ada
 help / color / mirror / Atom feed
* Serial port configuration
@ 2014-04-06 16:22 hreba
  2014-04-06 18:57 ` Simon Wright
  0 siblings, 1 reply; 6+ messages in thread
From: hreba @ 2014-04-06 16:22 UTC (permalink / raw)


The problem
-----------
I am trying to communicate with an Arduino using 
GNAT.Serial_Communications, which I will abbreviate as "Serial". The 
"Set" procedure isn't detailed enough, I need "fcntl", "tcgetattr" and 
"tcsetattr" which are private in Serial. To call them, I need the file 
descriptor which is a private component of the type "Port".

The Idea
--------
1. Create a new package "SerAux"
2. declare "fcntl", "tcgetattr" and "tcsetattr" the same way as in
    "Serial", but public
3. define a new type "Port" the same way as in "Serial", but public,
    and do the conversion somehow.

The obstacles
-------------
Creating the new Port requires to override its methods "Read" and 
"Write", but even doing that the same way as in "Serial" gets me a lot 
of error messages. The SerAux.adb begins like this (reproduced from 
original line # 4 on):

--------------------------------------------------------------
...
package body SerAux is

    type Port_Data is new int;
    type Port_Data_Access is access Port_Data;
    type Port is new Ada.Streams.Root_Stream_Type with record
       H : Port_Data_Access;
    end record;


    overriding procedure Read
      (--Port   : in out Serial_Port;
       Port   : in out Port;
       Buffer : out Ada.Streams.Stream_Element_Array;
       Last   : out Ada.Streams.Stream_Element_Offset)
    is
    begin
       Read (Serial.Serial_Port(Port), Buffer, Last);
    end Read;

    ...
----------------------------------------------------------------

The error messages for this fragment are:

seraux.adb:8:09: type must be declared abstract or "Read" overridden
seraux.adb:8:09: "Read" has been inherited at line 8
seraux.adb:8:09: "Read" has been inherited from subprogram at 
a-stream.ads:54
seraux.adb:13:15: subprogram "Read" is not overriding
seraux.adb:15:23: formal parameter "Port" cannot be used before end of 
specification
seraux.adb:20:07: warning: possible infinite recursion
seraux.adb:20:07: warning: Storage_Error may be raised at run time
...
-----------------------------------------------------------------

The questions
-------------
1. Why is all that an error here and not in "Serial"?
2. Am I on the right way or would you solve the problem completely 
different?

Please consider that I am a beginner.

--
hreba


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

end of thread, other threads:[~2023-11-04 14:23 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-04-06 16:22 Serial port configuration hreba
2014-04-06 18:57 ` Simon Wright
2014-04-06 19:06   ` Shark8
2014-04-07 11:47     ` hreba
2023-11-04 14:23     ` GNAT.SHA256 differs from Linux' sha256sum wvxvw
2014-04-07 11:44   ` Serial port configuration hreba

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