comp.lang.ada
 help / color / mirror / Atom feed
* Re: Ada95/Mil-Std-1553 Problem (Long Post - Sorry About That)
@ 1997-01-14  0:00 Marin David Condic, 561.796.8997, M/S 731-93
  1997-01-15  0:00 ` Larry Kilgallen
  0 siblings, 1 reply; 8+ messages in thread
From: Marin David Condic, 561.796.8997, M/S 731-93 @ 1997-01-14  0:00 UTC (permalink / raw)



    Several of you have been very kind in sending me suggestions about
    how to handle my Mil-Std-1553 problems. I think the information is
    beginning to gel into a potential solution. I have one question
    which maybe some of the language lawyers can help me out with:

    Is there a way with tagged records to control the position/content
    of any and all tag data? (In a manner that is reasonably close to
    portable so that it's not dependent on, for example,
    implementation X uses a 16 bit integer for a tag vs implementation
    Y uses a 32 bit integer...) In other words, if I can guarantee that
    the tag data will occur at the end (or beginning?) of the record
    and/or that it will occupy exactly N bytes, I think I can figure out
    how to solve my send/receive problems. It would be better if I
    could control the *value* of the tag, but I'll settle for knowing
    where it is so I can strip it off.

    Any info on how that might be done? Thanks.

    MDC

Marin David Condic, Senior Computer Engineer    ATT:        561.796.8997
M/S 731-96                                      Technet:    796.8997
Pratt & Whitney, GESP                           Fax:        561.796.4669
P.O. Box 109600                                 Internet:   CONDICMA@PWFL.COM
West Palm Beach, FL 33410-9600                  Internet:   CONDIC@FLINET.COM
===============================================================================
    "Whatever is not nailed down is mine. Whatever I can pry up is not
    nailed down."

        --  Collis P. Huntington, railroad tycoon
===============================================================================




^ permalink raw reply	[flat|nested] 8+ messages in thread
* Re: Ada95/Mil-Std-1553 Problem (Long Post - Sorry About That)
@ 1997-01-20  0:00 Marin David Condic, 561.796.8997, M/S 731-93
  0 siblings, 0 replies; 8+ messages in thread
From: Marin David Condic, 561.796.8997, M/S 731-93 @ 1997-01-20  0:00 UTC (permalink / raw)



Richard Kenner <kenner@LAB.ULTRA.NYU.EDU> writes:
>This isn't portable.  There's explicit implementation permission to
>reserve a particular space in a record for the tag (but not for any
>other internal field).  So a compiler is permitted to reject such a
>rep clause (GNAT will, for example).
>
    There's an additional problem - what you want to be able to do is
    figure out how many words are in the message, then do an
    UNCHECKED_CONVERSION of the message into your raw-word output
    buffer. If the tag info is in there at all, it a) gets counted in
    the word count and b) gets transferred to the buffer. (If you can
    guarantee it falls at the end, you could at least chop it off!)

    It would seem to me that the tag ought to be treated like array
    bounds - if an implementation keeps the bounds of an array with
    the array itself, all the usual clauses (like 'ADDRESS) are
    supposed to ignore that data.

    Using Streams seems to provide some mechanism for stripping out
    the tag info, but I haven't got the OO thing down far enough just
    yet to see how I could use it to get the contents of a message
    into a raw-word array where I can manipulate it. (Working on it in
    my "spare time". If I get an answer, I'll publish an example to
    whoever would like one.) I'm not sure this isn't going to involve
    moving the data twice or that it won't lead to grossly inefficient
    operation - but it seems like an area to start.

    MDC

Marin David Condic, Senior Computer Engineer    ATT:        561.796.8997
M/S 731-96                                      Technet:    796.8997
Pratt & Whitney, GESP                           Fax:        561.796.4669
P.O. Box 109600                                 Internet:   CONDICMA@PWFL.COM
West Palm Beach, FL 33410-9600                  Internet:   CONDIC@FLINET.COM
===============================================================================
    "Languages don't kill people. *Programmers* do!"

        --  Rich Stewart - Language Lawyer & Language Control Opponent.
===============================================================================




^ permalink raw reply	[flat|nested] 8+ messages in thread
* Ada95/Mil-Std-1553 Problem (Long Post - Sorry About That)
@ 1997-01-12  0:00 Marin David Condic, 561.796.8997, M/S 731-93
  1997-01-13  0:00 ` Amy Hartsough
                   ` (2 more replies)
  0 siblings, 3 replies; 8+ messages in thread
From: Marin David Condic, 561.796.8997, M/S 731-93 @ 1997-01-12  0:00 UTC (permalink / raw)



I have a problem I am trying to solve that involves building a
good  general purpose interface to a Mil-Std-1553 data bus using
Ada95. The 1553  moves data in blocks of 16 bit words, 32 words
at a shot. How exactly is not the problem. Accept for the moment
that we need some array of 32 words as the local buffer to hold
the data being sent or received. Here's what you'd like to have:

-- You would like to create any record type of some arbitrary
number of words (Possibly limited to some maximum, like 1024
words) and you want the first two words to always be the same:
Number of words in the message followed by message ID. Ex:

Type Msg is
    record
        Num_Wds  : Integer := 2;
        Msg_ID   : Integer := 0;
        --  Conforming records would have other stuff here.
    end record;

--  You want to write a package which will send or receive any
arbitrary object of a conforming record type to/from the bus.

--  The message length should not be arbitrarily restricted. (That
is to say, you don't want to insist that each message be exactly
N words in size - although for practical concerns, I'd accept
some maximum upper bound. Dynamically allocating buffers could
be a major problem.) An illegal package spec which would do the
job would look something like this:

package Mil_Std_1553 is
    function Msg_Waiting return BOOLEAN ;
    function Msg_ID return INTEGER ;
    procedure Get (
        Msg : out <any arbitrary conforming record type>);
    procedure Put (
        Msg : in <any arbitrary conforming record type>);
end Mil_Std_1553;

The requirements look something like this:

--  The program wants to work with structured data (record types)

--  The bus wants to work with 32 word chunks of raw words. It
will want machine addresses of where to get/put the data, so you
can probably make a big ring buffer and keep moving pointers
around.

--  The guy at the other end of the wire wants to send or receive
predictable formatted data as spelled out in an interface
control document (some well defined set of messages)

--  The guy at the other end may have been programmed in almost
any other language, so you can't count on the idiosyncrasies of
a particular compiler/hardware combination.

--  Output (from our side) is a little simpler because you can
dynamically determine the size of the record structure that the
data is parked in and use that to convert/block/xmit the data.

--  Input is harder because you have to determine from the
message ID where the data is ultimately to be parked. (You get a
big case statement or lots of little guys being dispatched to
check if the data is for them.)

--  Buffering/Blocking/Deblocking/Hardware is all to be hidden
invisibly in the package body - the client just wants to define
a message and send/receive it while seeing as little as possible
from the Mil_Std_1553 package. (avoid overlaying onto visible
raw-word buffers, etc.)

A traditional solution in languages like Ada83, C, Jovial, etc.
has been to do some version of the following:

--  Declare a fixed size raw-word array.

--  Declare N record types & objects (or maybe 1 discriminated
record type - although this contains its own form of
punishment.)

--  Use address clauses or other mechanisms to overlay the record
objects on the raw word array.

--  For sends, you move the data from some local record to the
overlaid record object and call "Put"

--  For receives, you check the Msg_ID (if data is waiting) and
go into a big case statement to move the data to some local
record.

Discriminated records can be a help, but it generally means
maintaining some mondo-big record declaration that is a pain to
extend. You'd like to declare new messages on the fly and
minimize impact. It seems like Ada95 ought to have a better
answer, but I'm not smart enough to see it.

--  Tagged records suggest a possible solution, but I've been
having problems playing around with that. Output can be coerced
by force (I have a relatively small example if anyone wants to
see it) but you've got to get rid of the record tag. It's
unpredictable and it can make problems for the other end - not
to mention wasting a word of storage in the message) Input is a
lot harder because you won't get the record tag in the message
or it would be unpredictable. That, and you need to write lots of
dispatched "Get" routines.

--  Someone suggested streams, but I can't figure out how this
would work. I'd need to see some small subset example because I
just don't see it from my limited experience.

--  Pointers to a record class may provide some help, but you're
still stuck with the tag and the associated problems on the
input side.

--  If you could control the value and placement of the tag, you
might have an answer because it could substitute for the message
ID. But I'm not sure that's possible.

-- You *really* need to limit data motion and buffering. You
can't get around at least one buffer for the 1553 to read/write
to/from. But you probably don't want to compute out of that
buffer unless you're astronomically fast and you have predictable
message intervals. The goal ought to be 2 moves: from/to local
storage and up/down the wire (1553 hardware move) We'd also
expect to have to implement buffer protection to eliminate risks
of multiple task accesses (and hardware accesses!) to the
buffer, but I think some version of protected types ought to
handle this. You also want to avoid any dynamic allocation or
unpredictable stack sizes and such so declaring lots of buffers
on the fly is probably not a good answer.


Anybody out there ever seen something like this done in Ada95?
Can you suggest an approach? I'll e-mail my feeble attempts to
program an output solution (compiles & runs using Gnat/WinNT) to
anyone who asks. Thanks.

MDC

Marin David Condic, Senior Computer Engineer    ATT:        561.796.8997
M/S 731-96                                      Technet:    796.8997
Pratt & Whitney, GESP                           Fax:        561.796.4669
P.O. Box 109600                                 Internet:   CONDICMA@PWFL.COM
West Palm Beach, FL 33410-9600                  Internet:   CONDIC@FLINET.COM
===============================================================================
    "When the going gets weird, the weird turn pro."

        --  Dr. Hunter S. Thompson
===============================================================================




^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~1997-01-20  0:00 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1997-01-14  0:00 Ada95/Mil-Std-1553 Problem (Long Post - Sorry About That) Marin David Condic, 561.796.8997, M/S 731-93
1997-01-15  0:00 ` Larry Kilgallen
1997-01-16  0:00   ` Richard Kenner
  -- strict thread matches above, loose matches on Subject: below --
1997-01-20  0:00 Marin David Condic, 561.796.8997, M/S 731-93
1997-01-12  0:00 Marin David Condic, 561.796.8997, M/S 731-93
1997-01-13  0:00 ` Amy Hartsough
1997-01-13  0:00 ` Michael F Brenner
1997-01-14  0:00 ` Brad Balfour

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox