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=ham 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-29 17:17:36 PST Path: archiver1.google.com!postnews1.google.com!not-for-mail From: byhoe@greenlime.com (Adrian Hoe) Newsgroups: comp.lang.ada Subject: Re: How to convert record? Date: 29 Oct 2001 17:17:35 -0800 Organization: http://groups.google.com/ Message-ID: <9ff447f2.0110291717.39b4eb15@posting.google.com> References: NNTP-Posting-Host: 210.186.172.60 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit X-Trace: posting.google.com 1004404656 17594 127.0.0.1 (30 Oct 2001 01:17:36 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: 30 Oct 2001 01:17:36 GMT Xref: archiver1.google.com comp.lang.ada:15386 Date: 2001-10-30T01:17:36+00:00 List-Id: "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