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.3 required=5.0 tests=BAYES_00, REPLYTO_WITHOUT_TO_CC autolearn=no autolearn_force=no version=3.4.4 X-Google-Thread: 103376,7e490a18b9688bd9 X-Google-NewGroupId: yes X-Google-Attributes: gida07f3367d7,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit Received: by 10.68.59.38 with SMTP id w6mr55098pbq.23.1316012928461; Wed, 14 Sep 2011 08:08:48 -0700 (PDT) Path: m9ni6171pbd.0!nntp.google.com!news1.google.com!news3.google.com!feeder.news-service.com!aioe.org!.POSTED!not-for-mail From: "Dmitry A. Kazakov" Newsgroups: comp.lang.ada Subject: Re: Stream_Element_Array Date: Wed, 14 Sep 2011 17:08:59 +0200 Organization: cbb software GmbH Message-ID: <28u4e86fk8gn$.ialexttobgr0$.dlg@40tude.net> References: <1e6rw4vto3ldb.i8d7fxixapx4.dlg@40tude.net> Reply-To: mailbox@dmitry-kazakov.de NNTP-Posting-Host: FbOMkhMtVLVmu7IwBnt1tw.user.speranza.aioe.org Mime-Version: 1.0 X-Complaints-To: abuse@aioe.org User-Agent: 40tude_Dialog/2.0.15.1 X-Notice: Filtered by postfilter v. 0.8.2 Xref: news1.google.com comp.lang.ada:17966 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Date: 2011-09-14T17:08:59+02:00 List-Id: 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 byte 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 just crash when full duplex I/O attempted. -- Regards, Dmitry A. Kazakov http://www.dmitry-kazakov.de