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=-2.9 required=5.0 tests=BAYES_00,MAILING_LIST_MULTI autolearn=unavailable autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,79db4ff72bff9422 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2001-10-30 11:08:01 PST Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!newsfeeds.belnet.be!news.belnet.be!fr.usenet-edu.net!usenet-edu.net!enst!enst.fr!not-for-mail From: "Beard, Frank" Newsgroups: comp.lang.ada Subject: RE: How to convert record? Date: Tue, 30 Oct 2001 14:05:26 -0500 Organization: ENST, France Sender: comp.lang.ada-admin@ada.eu.org Message-ID: Reply-To: comp.lang.ada@ada.eu.org NNTP-Posting-Host: marvin.enst.fr Mime-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" X-Trace: avanie.enst.fr 1004468880 890 137.194.161.2 (30 Oct 2001 19:08:00 GMT) X-Complaints-To: usenet@enst.fr NNTP-Posting-Date: Tue, 30 Oct 2001 19:08:00 +0000 (UTC) To: "'comp.lang.ada@ada.eu.org'" Return-Path: X-Mailer: Internet Mail Service (5.5.2448.0) Errors-To: comp.lang.ada-admin@ada.eu.org X-BeenThere: comp.lang.ada@ada.eu.org X-Mailman-Version: 2.0.6 Precedence: bulk List-Help: List-Post: List-Subscribe: , List-Id: comp.lang.ada mail<->news gateway List-Unsubscribe: , List-Archive: Errors-To: comp.lang.ada-admin@ada.eu.org X-BeenThere: comp.lang.ada@ada.eu.org Xref: archiver1.google.com comp.lang.ada:15432 Date: 2001-10-30T14:05:26-05:00 But using this method it doesn't matter whether it's packed or not, or whether it's 14 or 11 bytes. the_Command'size will give you the size of the "object" being passed in, which will be translated to the equivalent size IO_Buffer. So long as the receiver is on the same platform (same hardware and same OS), or represents the data the same way, it will work. So, there is no need to "take care of" the_Command'Size. Frank -----Original Message----- From: byhoe@greenlime.com [mailto:byhoe@greenlime.com] Sent: Monday, October 29, 2001 8:18 PM To: comp.lang.ada@ada.eu.org Subject: Re: How to convert record? "Beard, Frank" wrote in message news:... > One other thing you might want to consider: > > > procedure Write_ABCD (the_Command : Command) is > > Length : Posix.IO_Count := > Posix.IO_Count(the_Command'size/Posix.Posix_Character'size); > Buffer : IO_Buffer (1 .. positive(length)); > for Buffer use at the_Command'address; > > begin > > POSIX.IO.write (File_Descriptor, Buffer, Length); > > end Write_ABCD; > > > I've used it on both Windows and a couple of Unix flavors without > any problems, but we were always communicating between homogenous > platforms (same hardware, same OS). If you are in a heterogeneous > environment, you have to use a different method, but you have the > same problem with Unchecked_Conversion. > > I like it because it's fairly straight forward and it doesn't copy > data like Unchecked_Conversion, which is particularly good when > dealing with large buffers. > > Frank Then you would have to take care of the_Command'Size. The 8-byte record will give you no problem at all. See my post thread "Size and Pack". > > -----Original Message----- > From: joseph_kwan@greenlime.com [mailto:joseph_kwan@greenlime.com] > > > Hello, > > I just started to learn Ada and have been playing/working with Ada for > two weeks now. > > I want to send a command buffer to serial port using florist's POSIX > interface but I have encountered problems in converting record to > POSIX.IO.IO_Buffer or Ada.Streams.Stream_Element_Array. How can I > overcome this problem? > > package ABCD is > > type Command is > record > A : Character; > B : Character; > C : Integer; > D : Long_Integer; > end record; -- total 8 bytes; > > ... > end ABCD; > > > POSIX.IO.write (File_Descriptor, Command, Length); > > where > > procedure Write > (File : in File_Descriptor; > Buffer : in IO_Buffer; > Last : out POSIX.IO_Count; > Masked_Signals : in POSIX.Signal_Masking > := POSIX.RTS_Signals); > > I have searched the CLA but do not find any solutions. Can you please > help? > > Thank you. > _______________________________________________ > comp.lang.ada mailing list > comp.lang.ada@ada.eu.org > http://ada.eu.org/mailman/listinfo/comp.lang.ada _______________________________________________ comp.lang.ada mailing list comp.lang.ada@ada.eu.org http://ada.eu.org/mailman/listinfo/comp.lang.ada