I've the following message. This is a basic ASN.1 Uper message created on https://asn1.io/asn1playground/. I want to operate with a single field. For example I want to print the protocol versione. How can I do? Can I write DENM.header.protocol versione? I really don't know:
value1 DENM ::= {
header {
protocolVersion 1,
messageID denm,
stationID 1234567
},
denm {
management {
actionID {
originatingStationID 20,
sequenceNumber 30
},
detectionTime 45000000000,
referenceTime oneMillisecAfterUTCStartOf2004,
eventPosition {
latitude 40487111,
longitude -79494789,
positionConfidenceEllipse {
semiMajorConfidence 500,
semiMinorConfidence 400,
semiMajorOrientation 10
},
altitude {
altitudeValue 2000,
altitudeConfidence alt-000-02
}
},
validityDuration 600,
transmissionInterval oneMilliSecond,
stationType unknown
},
situation {
informationQuality lowest,
eventType {
causeCode roadworks,
subCauseCode 0
}
},
location {
eventSpeed {
speedValue standstill,
speedConfidence equalOrWithinOneCentimeterPerSec
},
eventPositionHeading {
headingValue wgs84North,
headingConfidence equalOrWithinOneDegree
},
traces {
{
{
pathPosition {
deltaLatitude 20,
deltaLongitude 20,
deltaAltitude unavailable
},
pathDeltaTime tenMilliSecondsInPast
},
{
pathPosition {
deltaLatitude 22,
deltaLongitude 22,
deltaAltitude unavailable
}
}
}
},
roadType urban-NoStructuralSeparationToOppositeLanes
},
alacarte {
impactReduction {
heightLonCarrLeft oneCentimeter,
heightLonCarrRight oneCentimeter,
posLonCarrLeft oneCentimeter,
posLonCarrRight oneCentimeter,
positionOfPillars {
tenCentimeters
},
posCentMass unavailable,
wheelBaseVehicle tenCentimeters,
turningRadius point4Meters,
posFrontAx tenCentimeters,
positionOfOccupants '11111110000000100001'B,
vehicleMass 20,
requestResponseIndication response
},
externalTemperature oneDegreeCelsius,
roadWorks {
lightBarSirenInUse '11'B,
closedLanes {
innerhardShoulderStatus availableForStopping,
drivingLaneStatus '011'B
},
restriction {
unknown
},
speedLimit 20,
incidentIndication {
causeCode reserved,
subCauseCode 0
},
recommendedPath {
{
latitude 20,
longitude 20,
positionConfidenceEllipse {
semiMajorConfidence oneCentimeter,
semiMinorConfidence oneCentimeter,
semiMajorOrientation wgs84North
},
altitude {
altitudeValue 200,
altitudeConfidence alt-000-02
}
}
}
},
positioningSolution noPositioningSolution,
stationaryVehicle {
stationarySince equalOrGreater15Minutes,
stationaryCause {
causeCode roadworks,
subCauseCode 0
},
numberOfOccupants 30,
vehicleIdentification {
wMInumber "WVW",
vDS "ZZZ1JZ"
},
energyStorageType '0000010'B
}
}
}
}
How can I print in C the field "PROTOCOL VERSION"? Thank you for your help!
That website has three basic areas. The left hand side is where your schema goes. The middle area is where you put your ASN.1 value that you've included in your question. The right hand side is where the website outputs the various different wire formats (or encodings) that ASN.1 can create for that ASN.1 value. The hex is simply the binary output rendered as hex digit pairs.
The thing you'll need to do is compile the schema with your own ASN.1 compile, such as this one. That will give you a lot of C source code, some of which is the compiler's library code, and some that it has generated to represent your schema as a hierarchy of C structures. There will be a routine in there for decoding a DENM from a binary file containing the uPER encoding of that ASN.1 value.
Once you have the hang of that, it's trivial to write a program to call that DENM uPER decoder, and then printf("%i\n",denm.header.protocolVersion);