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 autolearn=unavailable autolearn_force=no version=3.4.4 Path: eternal-september.org!reader01.eternal-september.org!reader02.eternal-september.org!news.eternal-september.org!feeder.eternal-september.org!feeder.erje.net!1.eu.feeder.erje.net!newsreader4.netcologne.de!news.netcologne.de!.POSTED.xdsl-89-0-113-186.netcologne.de!not-for-mail From: Frank Buss Newsgroups: comp.lang.ada Subject: Re: quiz for Sequential_IO Read Date: Mon, 4 Sep 2017 21:58:27 +0200 Organization: news.netcologne.de Distribution: world Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Injection-Date: Mon, 4 Sep 2017 19:58:27 +0000 (UTC) Injection-Info: newsreader4.netcologne.de; posting-host="xdsl-89-0-113-186.netcologne.de:89.0.113.186"; logging-data="15819"; mail-complaints-to="abuse@netcologne.de" User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.0 In-Reply-To: Xref: feeder.eternal-september.org comp.lang.ada:47929 Date: 2017-09-04T21:58:27+02:00 List-Id: On 09/03/2017 03:11 PM, Dmitry A. Kazakov wrote: > > In practice Stream I/O is a better choice. You also should not use > compiler-generated serialization attributes (see T'Read, T'Write, > T'Input, T'Output attributes). These are not portable either. You should > always replace them with your own. Ok, I wrote my program with Stream_IO. It will be reading from a FIFO file for receiving MIDI signals, and then write to a sound device continuously. I found a convenient package which defines low-level types of fixed size, same as stdint.h in C. See below for the code. Would this be portable on all systems (assuming they provide FIFO files) ? At least it works on my Debian system so far. with Ada.Streams.Stream_IO; use Ada.Streams.Stream_IO; with Ada.Text_IO; use Ada.Text_IO; with Interfaces; use Interfaces; procedure Hello is Data : Unsigned_8; Input_File : Ada.Streams.Stream_IO.File_Type; Input_Stream : Ada.Streams.Stream_IO.Stream_Access; task Main_Task is entry Data_Received(Data : in Unsigned_8); end Main_Task; task body Main_Task is begin loop select accept Data_Received(Data : in Unsigned_8) do Put("test: " & Unsigned_8'Image(Data)); New_Line; end Data_Received; else delay 0.1; -- TODO: create continuous sound output here end select; end loop; end Main_Task; begin Open(Input_File, In_File, "/home/frank/midi"); Input_Stream := Stream(Input_File); loop Unsigned_8'Read(Input_Stream, Data); Main_Task.Data_Received(Data); end loop; end; -- Frank Buss, http://www.frank-buss.de electronics and more: http://www.youtube.com/user/frankbuss