From: hreba <hreba@terra.com.br>
Subject: Serial port configuration
Date: Sun, 06 Apr 2014 13:22:20 -0300
Date: 2014-04-06T13:22:20-03:00 [thread overview]
Message-ID: <bqdd9uFo9g8U1@mid.individual.net> (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
next reply other threads:[~2014-04-06 16:22 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-04-06 16:22 hreba [this message]
2014-04-06 18:57 ` Serial port configuration 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
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox