comp.lang.ada
 help / color / mirror / Atom feed
* how to use "in out" for the "self" parameter in a function in a protected object?
@ 2017-09-16 20:47 Frank Buss
  2017-09-16 22:02 ` Jeffrey R. Carter
  0 siblings, 1 reply; 6+ messages in thread
From: Frank Buss @ 2017-09-16 20:47 UTC (permalink / 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

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

end of thread, other threads:[~2017-10-03  0:08 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-09-16 20:47 how to use "in out" for the "self" parameter in a function in a protected object? Frank Buss
2017-09-16 22:02 ` 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

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