--------------------------------------------------------------------------- -- -- Filename: -- -- command_interpreter.ads -- -- Description: -- -- XGC Ada demo -- -- Credits: -- -- Copyright (C) 1997, ESTEC - ESA -- Copyright (c) 1999, Chris Nettleton Software -- -- License: -- -- Permission to use copy, modify, and distribute this software for any -- purpose without fee is hereby granted. This software is provided -- "as is", without any express or implied warranty. -- -- Revision: -- -- $Id: $ -- --------------------------------------------------------------------------- with Ada.Interrupts.Names; with Interfaces; with Text_IO; with Controllers; package body Command_Interpreter is use Ada.Interrupts.Names; use Interfaces; use Text_IO; use Controllers; --------------- -- Serial_IO -- --------------- protected Serial_IO is procedure Handler; pragma Attach_Handler (Handler, UART_A_RX_TX); entry Get (C : out Character); private Rx_Ready : Boolean := False; end Serial_IO; protected body Serial_IO is procedure Handler is Status_Word : Unsigned_32; for Status_Word'Address use 16#01F800E8#; begin Rx_Ready := (Status_Word and 16#00000001#) /= 0; end Handler; entry Get (C : out Character) when Rx_Ready is Data_Word : Unsigned_32; for Data_Word'Address use 16#01F800E0#; begin C := Character'Val (Data_Word and 16#0000007f#); Rx_Ready := False; end Get; end Serial_IO; ----------- -- Task1 -- ----------- task body Task1 is Line : String (1 .. 20) := (others => ' '); Next : Natural := 1; -- Input buffer Ch : Character; Pos : Natural; Case_Offset : constant Integer := Character'Pos ('A') - Character'Pos ('a'); begin loop Serial_IO.Get (Ch); exit when Ch = '~'; if Ch = ASCII.LF or else Ch = ASCII.CR then Pos := 1; if Line (Pos) = 'T' then Pos := Pos + 1; if Line (Pos) in '1' .. '5' then declare i : Integer := Character'Pos (Line (Pos)) - Character'Pos ('0'); begin Pos := Pos + 1; if Line (Pos) = '_' then Pos := Pos + 1; end if; if Line (Pos .. Pos + 3) = "AUTO" then Modes (i) := Auto; elsif Line (Pos .. Pos + 1) = "ON" then Modes (i) := On; elsif Line (Pos .. Pos + 2) = "OFF" then Modes (i) := Off; end if; end; end if; end if; Line := (others => ' '); Next :=1; elsif Next < Line'Last then if Ch in 'a' .. 'z' then Line (Next) := Character'Val (Character'Pos (Ch) + Case_Offset); else Line (Next) := Ch; end if; Next := Next + 1; end if; end loop; end Task1; end Command_Interpreter;