From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,WEIRD_PORT autolearn=unavailable autolearn_force=no version=3.4.4 Path: border2.nntp.dca.giganews.com!nntp.giganews.com!usenet.blueworldhosting.com!feeder01.blueworldhosting.com!feeder.erje.net!eu.feeder.erje.net!news.swapon.de!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail From: hreba Newsgroups: comp.lang.ada Subject: Serial port configuration Date: Sun, 06 Apr 2014 13:22:20 -0300 Message-ID: Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Trace: individual.net WLqkH1hsNGoHs0ouut8ZTw+gNqj3sETuRH6x6r7Ukr8GBn8nBW Cancel-Lock: sha1:jBF1q7DUR5MUxhygrNBHmNSRsVg= User-Agent: Mozilla/5.0 (X11; Linux i686; rv:24.0) Gecko/20100101 Thunderbird/24.4.0 Xref: number.nntp.dca.giganews.com comp.lang.ada:185563 Date: 2014-04-06T13:22:20-03:00 List-Id: 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