Whoops - it is too long since I gave an ASN.1 course - Conrad is, of course,
right. The value notation for a CHOICE type is just "identifier:Value", where
"Value" is value notatio for the selected alternative. NO BRACKETS.
Sorry!
John L
Conrad Sigona wrote:
You are right, it is a '}' and not a ')'. Just a typo.
However, everything else is exactly the same as the DATEX-ASN.1
standard is
describing the Time type. I thought that the "DEFAULT{0}" at the end
means
in fact
time-SecondFractions CHOICE {
deci-seconds INTEGER (0..9) DEFAULT{0},
centi-seconds INTEGER (0..99) DEFAULT{0},
milliseconds INTEGER (0..999) DEFAULT{0} }
And this is the case that confuses me - if on the encoding side I have
the
chosen sub-field being the millisecond with a value of 0, I will not
encode
anything. On the decoding side I can figure out that the CHOICE was
skipped
because the chosen field had the default value (I also know the value -
zero - but I don't know which one was the chosen field).
Things are even worse in this case:
time-SecondFractions CHOICE {
deci-seconds INTEGER (0..9) DEFAULT{1},
centi-seconds INTEGER (0..99) DEFAULT{2},
milliseconds INTEGER (0..999) DEFAULT{3} }
There is something that I am missing.
Yes, you're missing that the default is not just an INTEGER value.
The correct ASN.1 would be something like this
time-SecondFractions CHOICE {
deci-seconds INTEGER (0..9),
centi-seconds INTEGER (0..99),
milliseconds INTEGER (0..999) } DEFAULT deci-seconds: 0
There are no brackets, whether () or {} around the default value and
there must be a choice made (the name before the colon) and then that
choice takes a value (the thing after the colon). Look at it this way:
The element time-SecondFractions is a CHOICE. The first step is
assigning a value to a CHOICE is to choose one of the elements. The
second step is to provide a value for that element. Thus, if our
SEQUENCE were to look like this (automatic tags assumed)
Time ::= SEQUENCE {
hours INTEGER,
minutes INTEGER,
seconds INTEGER,
time-SecondFractions CHOICE {
deci-seconds INTEGER (0..9),
centi-seconds INTEGER (0..99),
milliseconds INTEGER (0..999)
} DEFAULT deci-seconds: 0
}
we could have a value described in value notation like this
t Time ::= { hours 12,
minutes 0,
seconds 0,
time-SecondFractions centi-seconds: 150
}
Note that the value of time-SecondFractions is not just 150, it's
centi-seconds:150; that is, we first choose centi-seconds from among the
three choices, then assign a value to centi-seconds. Likewise we might have
u Time ::= { hours 12,
minutes 0,
seconds 0,
time-SecondFractions deci-seconds: 12
}
where we have chosen deci-seconds and assigned it a value of 12.
A value of 12 for time-SecondsFractions has no meaning (or, at best, an
ambiguous meaning) since we can't tell whether it's 12 deci-seconds, 12
centi-seconds, or 12 milli-seconds.
When we bring DEFAULT into the picture, all we're saying is (excuse the
lack of precision) that time-SecondFractions is an optional field, which
when present, takes the value given, but when absent, takes the value
specified as the default. So the question is: what kind of default value
should time-SecondFractions take? As we already established above, it
can't take a value of 0 since it's ambiguous; it must take a value which
specifies (a) which element is chosen and (b) the value that the chosen
element should take.
If I explained this well enough, you'll see that in the definition of
Time above, even when time-SecondFractions is absent, it takes the
default value of deci-seconds:0. Your decoder would therefore have to
make it clear to the application that deci-seconds is the chosen and 0
is the value of deci-seconds.
You mentioned that you took the ASN.1 straight from the DATEX standard.
If that's correct, the standard is faulty.
If you'd like further help, consider sending the entire ASN.1 file to me.
=====================================================================
Conrad Sigona Voice Mail : 1-732-302-9669 x400
OSS Nokalva Fax : 1-614-388-4156
[EMAIL PROTECTED] My direct line : 1-315-845-1773
_______________________________________________
ASN1 mailing list
[email protected]
http://lists.asn1.org/mailman/listinfo/asn1
--
Prof John Larmouth
Larmouth T&PDS Ltd
(Training and Protocol Development Services Ltd)
1 Blueberry Road
Bowdon [EMAIL PROTECTED]
Cheshire WA14 3LS
England
Tel: +44 161 928 1605 Fax: +44 161 928 8069
_______________________________________________
ASN1 mailing list
[email protected]
http://lists.asn1.org/mailman/listinfo/asn1