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-29 10:19:09 PST Path: archiver1.google.com!news1.google.com!sn-xit-02!supernews.com!isdnet!enst!enst.fr!not-for-mail From: "Beard, Frank" Newsgroups: comp.lang.ada Subject: RE: How to convert record? Date: Mon, 29 Oct 2001 13:16:58 -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 1004379548 56236 137.194.161.2 (29 Oct 2001 18:19:08 GMT) X-Complaints-To: usenet@enst.fr NNTP-Posting-Date: Mon, 29 Oct 2001 18:19:08 +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:15365 Date: 2001-10-29T13:16:58-05:00 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 -----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