text
stringlengths
0
234
procedure Fill_Queue is
begin
Log.Log_Line ("Prio 1 - 1", 1);
Log.Log_Line ("Prio 2 - 1", 2);
Log.Log_Line ("Prio 5 - 1", 5);
Log.Log_Line ("Prio 1 - 2", 1);
Log.Log_Line ("Prio 5 - 2", 5);
Log.Log_Line ("Prio 8 - 1", 8);
if not Log.Full then
raise Program_Error with "The queue should be full";
end if;
end Fill_Queue;
-----------------
-- Empty_Queue --
-----------------
procedure Empty_Queue is
begin
-- Empty the queue
for Cnt in 1 .. 6 loop
Pop_And_Print;
end loop;
if not Log.Empty then
raise Program_Error with "The queue should be empty";
end if;
end Empty_Queue;
begin
Ada.Text_IO.Put_Line ("--- Log test begin ---");
declare
begin
Ada.Text_IO.Put_Line ("--- Test priorities ---");
-- Try to print but there should be nothing in the queue
Pop_And_Print;
-- Insert a few messages with various priorities to check that the messages
-- will be properly sorted.
Fill_Queue;
Empty_Queue;
-- Try to print but there should be nothing in the queue
Pop_And_Print;
Function Definition: function To_Char is new Ada.Unchecked_Conversion (Source => UInt8,
Function Body: Target => Character);
function To_UInt8 is new Ada.Unchecked_Conversion (Source => Character,
Target => UInt8);
procedure Write (This : in out TP_Device; Cmd : String);
procedure Read (This : in out TP_Device; Str : out String);
-----------
-- Write --
-----------
procedure Write (This : in out TP_Device; Cmd : String) is
Status : UART_Status;
Data : UART_Data_8b (Cmd'Range);
begin
for Index in Cmd'Range loop
Data (Index) := To_UInt8 (Cmd (Index));
end loop;
This.Port.Transmit (Data, Status);
if Status /= Ok then
-- No error handling...
raise Program_Error;
end if;
-- This.Time.Delay_Microseconds ((11 * 1000000 / 19_2000) + Cmd'Length);
end Write;
----------
-- Read --
----------
procedure Read (This : in out TP_Device; Str : out String) is
Status : UART_Status;
Data : UART_Data_8b (Str'Range);
begin
This.Port.Receive (Data, Status);
if Status /= Ok then
-- No error handling...
raise Program_Error;
end if;
for Index in Str'Range loop
Str (Index) := To_Char (Data (Index));
end loop;
end Read;