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=-0.9 required=5.0 tests=BAYES_00,FORGED_GMAIL_RCVD, FREEMAIL_FROM autolearn=no autolearn_force=no version=3.4.4 X-Google-Thread: a07f3367d7,7e490a18b9688bd9 X-Google-Attributes: gida07f3367d7,public,usenet X-Google-NewGroupId: yes X-Google-Language: ENGLISH,ASCII Path: g2news1.google.com!postnews.google.com!s30g2000pri.googlegroups.com!not-for-mail From: Alexander Korolev Newsgroups: comp.lang.ada Subject: Re: Stream_Element_Array Date: Wed, 14 Sep 2011 10:16:09 -0700 (PDT) Organization: http://groups.google.com Message-ID: <276b8d0a-5b3c-4559-a275-98620657cc2f@s30g2000pri.googlegroups.com> References: <1e6rw4vto3ldb.i8d7fxixapx4.dlg@40tude.net> <28u4e86fk8gn$.ialexttobgr0$.dlg@40tude.net> NNTP-Posting-Host: 96.49.119.210 Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-Trace: posting.google.com 1316021975 18008 127.0.0.1 (14 Sep 2011 17:39:35 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Wed, 14 Sep 2011 17:39:35 +0000 (UTC) Complaints-To: groups-abuse@google.com Injection-Info: s30g2000pri.googlegroups.com; posting-host=96.49.119.210; posting-account=9aAl4woAAACPkuvNJOQxyBXxG_5lfu_0 User-Agent: G2/1.0 X-Google-Web-Client: true X-Google-Header-Order: HUARLECNK X-HTTP-UserAgent: Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_6_5; ru-ru) AppleWebKit/533.18.1 (KHTML, like Gecko) Version/5.0.2 Safari/533.18.5,gzip(gfe) Xref: g2news1.google.com comp.lang.ada:20940 Date: 2011-09-14T10:16:09-07:00 List-Id: On Sep 14, 7:08=A0pm, "Dmitry A. Kazakov" wrote: > On Wed, 14 Sep 2011 07:48:47 -0700 (PDT), Alexander Korolev wrote: > > I am talking to serial port via GNAT.Serial_Communication. The > > Buffer it offers is Stream_Element_Array. > > In that case it is OK to use Stream_Element. > > > And I need to do > > computations (implemented assuming that the buffer is ok :) ) over the > > buffer > > before do the call.One of the formats receiving part expects is: > >|Start(8bit|Length - 16 bit|Element1-8bit|Element-16bit|Checksum| > > Write (S_Port,Buffer) > > I usually allocate an output buffer in the "device object". The output > index as I described earlier is also stored there. The application level > fills the buffer and in the end call something like Device.Flush. Flush > calculates the checksum over 1..Index - 1, stores the result and finally > calls Write. > > BTW, it is highly recommended to use asynchronous read, or a synchronous > one from an independent task. You should always be ready to read next byt= e > from the device. Otherwise you risk to run into a deadlock upon protocol > errors. > > You might also wish to write asynchronously (to improve performance), but > beware that most serial devices, at least those I saw, are broken and jus= t > crash when full duplex I/O attempted. > > -- > Regards, > Dmitry A. Kazakovhttp://www.dmitry-kazakov.de "I usually allocate an output buffer in the "device object" I've been advised and that worked out for many in few cases to use Volatile_Streams.Memory_Resident_Stream. You may like to take a look (in GNAT Examples) if you have not already did before. I was getting a compilation error like I posted before (see my second post) but now it's gone and I hope I got what I wanted but further autopsy will show ... I will post the result if it will work this way. " or a synchronous one from an independent task" Sure. This is were I call the serial port