From: byhoe@greenlime.com (Adrian Hoe)
Subject: Re: How to convert record?
Date: 29 Oct 2001 17:17:35 -0800
Date: 2001-10-30T01:17:36+00:00 [thread overview]
Message-ID: <9ff447f2.0110291717.39b4eb15@posting.google.com> (raw)
In-Reply-To: mailman.1004379548.31870.comp.lang.ada@ada.eu.org
"Beard, Frank" <beardf@spawar.navy.mil> wrote in message news:<mailman.1004379548.31870.comp.lang.ada@ada.eu.org>...
> 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
next prev parent reply other threads:[~2001-10-30 1:17 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2001-10-29 18:16 How to convert record? Beard, Frank
2001-10-30 1:17 ` Adrian Hoe [this message]
-- strict thread matches above, loose matches on Subject: below --
2001-10-31 19:40 Beard, Frank
2001-11-01 2:13 ` Adrian Hoe
2001-10-30 19:05 Beard, Frank
2001-10-31 4:10 ` Adrian Hoe
2001-10-21 9:56 Joseph Kwan
2001-10-22 11:30 ` John McCabe
2001-10-25 11:40 ` Joseph Kwan
2001-10-25 12:38 ` sk
2001-10-25 17:12 ` Jeffrey L. Susanj
2001-10-25 12:48 ` David C. Hoos
2001-10-29 1:42 ` Joseph Kwan
2001-10-29 13:35 ` Marc A. Criley
2001-10-25 12:48 ` Marc A. Criley
2001-10-25 12:54 ` sk
2001-10-25 15:41 ` Ted Dennison
2001-10-26 3:21 ` Smark
2001-10-26 5:45 ` James Rogers
2001-10-26 17:46 ` Smark
2001-10-26 14:30 ` Ted Dennison
2001-10-26 17:42 ` Smark
2001-10-26 20:02 ` Ted Dennison
2001-10-26 23:10 ` Jeffrey Carter
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox