comp.lang.ada
 help / color / mirror / Atom feed
From: Frank Buss <fb@frank-buss.de>
Subject: how to use "in out" for the "self" parameter in a function in a protected object?
Date: Sat, 16 Sep 2017 22:47:38 +0200
Date: 2017-09-16T22:47:38+02:00	[thread overview]
Message-ID: <opk2lc$phj$1@newsreader4.netcologne.de> (raw)

I have a function in a protected object, which needs to change a 
variable, but I get this error:

   actual for "Self" must be a variable

I assume the reason is, that the implicit "self" parameter for my 
function is declared as "in" and not "in out". How can I change it to 
"in out"?

Below is the code. The function "Available" for example works, but the 
function "Read" causes the error when compiling. Both are accessing the 
FIFO variable, "Available" only with a call where the variable is used 
as an "in" parameter, but for "Read" I call a function where it is 
passed as an "in out" parameter.


with Interfaces; use Interfaces;
with Ada.Interrupts; use Ada.Interrupts;
with Ada.Interrupts.Names; use Ada.Interrupts.Names;
with STM32.USARTs; use STM32.USARTs;
with Ringbuffers;

package Serial_IO is

    package FIFO_Package is new Ringbuffers(256, Unsigned_8);
    subtype FIFO is FIFO_Package.Ringbuffer;

    protected type Serial_Port_Controller
    is

       procedure Init (Baud_Rate: Baud_Rates);

       function Available return Boolean;

       function Read return Unsigned_8;

       procedure Write (Data : Unsigned_8);

    private
       procedure Interrupt_Handler;
       pragma Attach_Handler (Interrupt_Handler, USART1_Interrupt);

       Input : FIFO;
       Output: FIFO;
       Initialized : Boolean := False;
    end Serial_Port_Controller;

    Serial : Serial_Port_Controller;

end Serial_IO;





-- 
Frank Buss, http://www.frank-buss.de
electronics and more: http://www.youtube.com/user/frankbuss

             reply	other threads:[~2017-09-16 20:47 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-09-16 20:47 Frank Buss [this message]
2017-09-16 22:02 ` how to use "in out" for the "self" parameter in a function in a protected object? Jeffrey R. Carter
2017-09-16 22:40   ` Frank Buss
2017-09-17  1:35     ` Dennis Lee Bieber
2017-09-17  8:36     ` Jeffrey R. Carter
2017-10-03  0:08       ` Randy Brukardt
replies disabled

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