esnacc / esnacc-ng

A continuation of the Enhanced SNACC ASN.1 compiler - See http://mail.esnacc.org/mailman/listinfo/dev
http://esnacc.org
GNU General Public License v2.0
32 stars 30 forks source link

Syntax Error on ,.. #47

Closed momor10 closed 6 years ago

momor10 commented 6 years ago

im trying to compile an asn1 file (CAM and DENM) that contains structures like the following: ProtectedZoneRadius::= INTEGER (1..255,...) I wasnt able to find out what's the meaning of those points behind the range actually is.. removing those ",.." didn't work either, it would still output errors (im not on the development machine to look it up) Is there anyway to make it work with esnacc? Im trying to generate c++ files.

apconole commented 6 years ago

I'm not sure what that accomplishes. The ',...' as I understand it will extend the range (I think it means that any value would be accepted? need to double check the standard). It should be the same.

What version of esnacc are you using? If I use the latest from 'master' I don't see any such issue with INTEGER(1..255), but I can duplicate your INTEGER(1..255,...) issue.

momor10 commented 6 years ago

Im using the latest from master. When changing those lines i get the following error without any line hint: SortTypeDefs: internal compiler error - non recursive type defs failed sort.

btw: i managed to compile the file without any changes using asn1c from lionet (however it can only generate c files)

apconole commented 6 years ago

can you share the asn1 file causing this error? Or a minimal subset that reproduces it?

mouse07410 commented 6 years ago

INTEGER(1..255,...)

I don't get it. What's the meaning of the above statement? "The range is between 1 and 255, or whatever"???

momor10 commented 6 years ago

Thats the file:

CoopIts DEFINITIONS ::= BEGIN

ProtocolVersion::= INTEGER (0..255)
MessageID::= INTEGER (0..255)
StationID::= INTEGER (0..4294967295)
GenerationDeltaTime::= INTEGER (0..65535)
StationType::= INTEGER (0..255)
SpeedValue::= INTEGER (0..16383)
SpeedConfidence::= INTEGER (1..127)
DriveDirection::= ENUMERATED 
{
    forward      (0),
    backward     (1),
    unavailable  (2)
}
VehicleLengthValue::= INTEGER (1..1023)
VehicleLengthConfidenceIndication::= ENUMERATED 
{
    noTrailerPresent                (0),
    trailerPresentWithKnownLength   (1),
    trailerPresentWithUnknownLength (2),
    trailerPresenceIsUnknown        (3),
    unavailable                     (4)
}
VehicleWidth::= INTEGER (1..62)
LongitudinalAccelerationValue::= INTEGER (-160..161)
AccelerationConfidence::= INTEGER (0..102)
CurvatureValue::= INTEGER (-30000..30001)
CurvatureConfidence::= ENUMERATED 
{
    onePerMeter-0-00002 (0),
    onePerMeter-0-0001  (1),
    onePerMeter-0-0005  (2),
    onePerMeter-0-002   (3),
    onePerMeter-0-01    (4),
    onePerMeter-0-1     (5),
    outOfRange          (6),
    unavailable         (7)    
}
CurvatureCalculationMode::= ENUMERATED 
{
    yawRateUsed     (0),
    yawRateNotUsed  (1),
    unavailable     (2),
    ...
}
YawRateValue::= INTEGER (-32766..32767)
YawRateConfidence::= ENUMERATED 
{
    degSec-000-01   (0),
    degSec-000-05   (1),
    degSec-000-10   (2),
    degSec-001-00   (3),
    degSec-005-00   (4),
    degSec-010-00   (5),
    degSec-100-00   (6),
    outOfRange      (7),
    unavailable     (8)
}
SemiAxisLength::= INTEGER (0..4095)
AltitudeValue::= INTEGER (-100000..800001)
AltitudeConfidence::= ENUMERATED 
{
    alt-000-01  (0),
    alt-000-02  (1),
    alt-000-05  (2),
    alt-000-10  (3),
    alt-000-20  (4),
    alt-000-50  (5),
    alt-001-00  (6),
    alt-002-00  (7),
    alt-005-00  (8),
    alt-010-00  (9),
    alt-020-00  (10),
    alt-050-00  (11),
    alt-100-00  (12),
    alt-200-00  (13),
    outOfRange  (14),
    unavailable  (15)
}
HeadingValue::= INTEGER (0..3601)
HeadingConfidence::= INTEGER (1..127)
Latitude::= INTEGER (-900000000..900000001)
Longitude::= INTEGER (-1800000000..1800000001)
AccelerationControl::= BIT STRING (SIZE (7))
LanePosition::= INTEGER (-1..14)
SteeringWheelAngleValue::= INTEGER (-511..512)
SteeringWheelAngleConfidence::= INTEGER (1..127)
LateralAccelerationValue::= INTEGER (-160..161)
VerticalAccelerationValue::= INTEGER (-160..161)
PerformanceClass::= INTEGER (0..7)
ProtectedZoneID::= INTEGER (0..134217727)
VehicleRole::= ENUMERATED 
{
    default            (0),
    publicTransport     (1),
    specialTransport    (2),
    dangerousGoods      (3),
    roadWork            (4),
    rescue              (5),
    emergency           (6),
    safetyCar           (7),
    agriculture         (8),
    commercial          (9),
    military            (10),
    roadOperator        (11),
    taxi                (12),
    reserved1           (13),
    reserved2           (14),
    reserved3           (15)
}
ExteriorLights::= BIT STRING (SIZE(8))
PathHistory::= SEQUENCE (SIZE (0..40)) OF PathPoint
ProtectedCommunicationZonesRSU::= SEQUENCE (SIZE (1..16)) OF ProtectedCommunicationZone
ProtectedZoneType::= ENUMERATED 
{
    cenDsrcTolling  (0),
    ...
}
TimeStampIts::= INTEGER (0..4398046511103)
ProtectedZoneRadius::= INTEGER (1..255,...)
DeltaLatitude::= INTEGER (-131071..131072)
DeltaLongitude::= INTEGER (-131071..131072)
DeltaAltitude::= INTEGER (-12700..12800)
PathDeltaTime::= INTEGER (1..65535, ...)
PtActivationType::= INTEGER (0..255)
PtActivationData::= OCTET STRING (SIZE (1..20))
EmbarkationStatus::= BOOLEAN 
ElevatedTemperature::= BOOLEAN
TunnelsRestricted::= BOOLEAN
LimitedQuantity::= BOOLEAN
SpecialTransportType::= BIT STRING (SIZE (4))
DangerousGoodsBasic::= ENUMERATED 
{
    explosives1                                             (0),
    explosives2                                             (1),
    explosives3                                             (2),
    explosives4                                             (3),
    explosives5                                             (4),
    explosives6                                             (5),
    flammableGases                                          (6),
    nonFlammableGases                                       (7),
    toxicGases                                              (8),
    flammableLiquids                                        (9),
    flammableSolids                                         (10),
    substancesLiableToSpontaneousCombustion                 (11),
    substancesEmittingFlammableGasesUponContactWithWater    (12),
    oxidizingSubstances                                     (13),
    organicPeroxides                                        (14),
    toxicSubstances                                         (15),
    infectiousSubstances                                    (16),
    radioactiveMaterial                                     (17),
    corrosiveSubstances                                     (18),
    miscellaneousDangerousSubstances                        (19)   
}
RoadworksSubCauseCode::= INTEGER (0..255)
LightBarSirenInUse::= BIT STRING (SIZE (2))
HardShoulderStatus::= ENUMERATED 
{
    vailableForStopping (0),
    closed              (1),
    availableForDriving (2)
}
DrivingLaneStatus::= BIT STRING (SIZE (1..14))
CauseCodeType::= INTEGER (0..255) 
SubCauseCodeType::= INTEGER (0..255)
EmergencyPriority::= BIT STRING (SIZE (2))
TrafficRule::= ENUMERATED 
{
    noPassing           (0),
    noPassingForTrucks  (1),
    passToRight         (2),
    passToLeft          (3),
    ...
}
SpeedLimit::= INTEGER (1..255)
RelevanceDistance::= ENUMERATED 
{
    lessThan50m     (0),
    lessThan100m    (1),
    lessThan200m    (2),
    lessThan500m    (3),
    lessThan1000m   (4),
    lessThan5km     (5),
    lessThan10km    (6),
    over10km        (7)
}
RelevanceTrafficDirection::= ENUMERATED
{
    allTrafficDirections    (0),
    upstreamTraffic         (1),
    downstreamTraffic       (2),
    oppositeTraffic         (3)    
}
SequenceNumber::= INTEGER (0..65535)
ValidityDuration::= INTEGER (0..86400)
TransmissionInterval::= INTEGER (1..10000)
Termination::= ENUMERATED 
{
    isCancellation  (0),
    isNegation      (1)
}
InformationQuality::= INTEGER (0..7)
EventHistory::= SEQUENCE (SIZE (1..23)) OF EventPoint
Traces::= SEQUENCE (SIZE (1..7)) OF PathHistory
RoadType::= ENUMERATED 
{
    urban-NoStructuralSeparationToOppositeLanes         (0),
    urban-WithStructuralSeparationToOppositeLanes       (1),
    nonUrban-NoStructuralSeparationToOppositeLanes      (2),
    nonUrban-WithStructuralSeparationToOppositeLanes    (3)   
}
HeightLonCarr::= INTEGER (1..100)
PosLonCarr::= INTEGER (1..127)
Temperature::= INTEGER (-60..67)
ItineraryPath::= SEQUENCE (SIZE (1..40)) OF ReferencePosition
RestrictedTypes::= SEQUENCE (SIZE (1..3)) OF StationType  
PosPillar::= INTEGER (1..30)
PosCentMass::= INTEGER (1..63)
WheelBaseVehicle::= INTEGER (1..127)
TurningRadius::= INTEGER (1..255)
PosFrontAx::= INTEGER (1..20)
VehicleMass::= INTEGER (1..1024)
PositionOfOccupants::= BIT STRING (SIZE (20))
RequestResponseIndication::= ENUMERATED 
{
    request     (0),
    response    (1)
}
PositionOfPillars::= SEQUENCE (SIZE (1..3)) OF PosPillar 
ReferenceDenms::= SEQUENCE (SIZE (1..8)) OF ActionID
PositioningSolutionType::= ENUMERATED 
{
    noPositionSolution  (0),
    sGNSS               (1),
    dGNSS               (2),
    sGNSSplusDR         (3),
    dGNSSplusDR         (4),
    dR                  (5),
    ...
}
StationarySince::= ENUMERATED 
{
    lessThan1Minute         (0),
    lessThan2Minutes        (1),
    lessThan15Minutes       (2),
    equalOrGreater15Minutes (3)
}
NumberOfOccupants::= INTEGER (0..127)
WMInumber::= IA5String (SIZE (1..3))
VDS::= IA5String (SIZE (6))
EnergyStorageType::= BIT STRING (SIZE (7))
UnNumber::= INTEGER (0..9999)
EmergencyActionCode::= IA5String (SIZE (1..24))
PhoneNumber::= IA5String (SIZE (1..24))
CompanyName::= UTF8String (SIZE (1..24))

Cam::= SEQUENCE {
    header ItsPduHeader,
    cam CoopAwareness
}

ItsPduHeader::= SEQUENCE {
    protocolVersion ProtocolVersion,
    messageID MessageID, 
    stationID StationID
}

CoopAwareness::= SEQUENCE {
    generationDeltaTime GenerationDeltaTime,
    camParameters CamParameters
}

CamParameters::= SEQUENCE {
    basicContainer BasicContainer,
    highFrequencyContainer HighFrequencyContainer,
    lowFrequencyContainer LowFrequencyContainer OPTIONAL,
    specialVehicleContainer SpecialVehicleContainer OPTIONAL,
    ...
}

BasicContainer::= SEQUENCE {
    stationType StationType,
    referencePosition ReferencePosition,
    ...
}

HighFrequencyContainer::= CHOICE {
    basicVehicleContainerHighFrequency BasicVehicleContainerHighFrequency,
    rsuContainerHighFrequency RSUContainerHighFrequency,
    ...
}

BasicVehicleContainerHighFrequency::= SEQUENCE {
    heading Heading,
    speed Speed,
    driveDirection DriveDirection,
    vehicleLength VehicleLength, 
    vehicleWidth VehicleWidth,
    longitudinalAcceleration LongitudinalAcceleration,
    curvature Curvature, 
    curvatureCalculationMode CurvatureCalculationMode,
    yawRate YawRate,
    accelerationControl AccelerationControl OPTIONAL,
    lanePosition LanePosition OPTIONAL,
    steeringWheelAngle SteeringWheelAngle OPTIONAL,
    lateralAcceleration LateralAcceleration OPTIONAL,
    verticalAcceleration VerticalAcceleration OPTIONAL,
    performanceClass PerformanceClass OPTIONAL,
    cenDsrcTollingZone CenDsrcTollingZone OPTIONAL
}

ReferencePosition::= SEQUENCE {
    latitude Latitude,
    longitude Longitude,
    positionConfidenceEllipse PosConfidenceEllipse,
    altitude Altitude
}

Heading::= SEQUENCE {
    headingValue HeadingValue,
    headingConfidence HeadingConfidence
}

Speed::= SEQUENCE {
    speedValue SpeedValue,
    speedConfidence SpeedConfidence
}

VehicleLength::= SEQUENCE {
    vehicleLengthValue VehicleLengthValue,
    vehicleLengthConfidenceIndication VehicleLengthConfidenceIndication
}

LongitudinalAcceleration::= SEQUENCE {
    longitudinalAccelerationValue LongitudinalAccelerationValue,
    longitudinalAccelerationConfidence AccelerationConfidence
}

Curvature::= SEQUENCE {
    curvatureValue CurvatureValue,
    curvatureConfidence CurvatureConfidence
}

YawRate::= SEQUENCE {
    yawRateValue YawRateValue,
    yawRateConfidence YawRateConfidence
}

PosConfidenceEllipse::= SEQUENCE {
    semiMajorConfidence SemiAxisLength,
    semiMinorConfidence SemiAxisLength,
    semiMajorOrientation HeadingValue
}

Altitude::= SEQUENCE {
    altitudeValue AltitudeValue,
    altitudeConfidence AltitudeConfidence
}

SteeringWheelAngle::= SEQUENCE {
    steeringWheelAngleValue SteeringWheelAngleValue,
    steeringWheelAngleConfidence SteeringWheelAngleConfidence 
}

LateralAcceleration::= SEQUENCE {
    lateralAccelerationValue LateralAccelerationValue,
    lateralAccelerationConfidence AccelerationConfidence
}

VerticalAcceleration::= SEQUENCE {
    verticalAccelerationValue VerticalAccelerationValue,
    verticalAccelerationConfidence AccelerationConfidence
}

CenDsrcTollingZone::= SEQUENCE {
    protectedZoneLatitude Latitude,
    protectedZoneLongitude Longitude,
    cenDsrcTollingZoneID ProtectedZoneID OPTIONAL
}

LowFrequencyContainer::= CHOICE {
    basicVehicleContainerLowFrequency BasicVehicleContainerLowFrequency,
    ...
}

BasicVehicleContainerLowFrequency::= SEQUENCE {
    vehicleRole VehicleRole,
    exteriorLights ExteriorLights,
    pathHistory PathHistory
}

RSUContainerHighFrequency::= SEQUENCE {
    protectedCommunicationZonesRSU ProtectedCommunicationZonesRSU OPTIONAL,
    ...
}

ProtectedCommunicationZone::= SEQUENCE {
    protectedZoneType ProtectedZoneType,
    expiryTime TimeStampIts OPTIONAL,
    protectedZoneLatitude Latitude,
    protectedZoneLongitude Longitude,
    protectedZoneRadius ProtectedZoneRadius OPTIONAL, 
    protectedZoneID ProtectedZoneID OPTIONAL
}

PathPoint::= SEQUENCE {
    pathPosition DeltaReferencePosition,
    pathDeltaTime PathDeltaTime OPTIONAL
}

DeltaReferencePosition::= SEQUENCE {
    deltaLatitude DeltaLatitude,
    deltaLongitude DeltaLongitude,
    deltaAltitude DeltaAltitude
}

SpecialVehicleContainer::= CHOICE {
    publicTransportContainer PublicTransportContainer,
    specialTransportContainer SpecialTransportContainer,
    dangerousGoodsContainer DangerousGoodsContainer,
    roadWorksContainerBasic RoadWorksContainerBasic,
    rescueContainer RescueContainer,
    emergencyContainer EmergencyContainer,
    safetyCarContainer SafetyCarContainer,
    ...
}

PublicTransportContainer::= SEQUENCE {
    embarkationStatus EmbarkationStatus,
    ptActivation PtActivation OPTIONAL
}

PtActivation::= SEQUENCE {
    ptActivationType PtActivationType,
    ptActivationData  PtActivationData
}

SpecialTransportContainer::= SEQUENCE {
    specialTransportType SpecialTransportType,
    lightBarSirenInUse LightBarSirenInUse
}

DangerousGoodsContainer::= SEQUENCE {
    dangerousGoodsBasic DangerousGoodsBasic
}

RoadWorksContainerBasic::= SEQUENCE {
    roadworksSubCauseCode RoadworksSubCauseCode OPTIONAL,
    lightBarSirenInUse LightBarSirenInUse,
    closedLanes ClosedLanes OPTIONAL
}

ClosedLanes::= SEQUENCE {
    hardShoulderStatus HardShoulderStatus OPTIONAL,
    drivingLaneStatus DrivingLaneStatus,
    ...
}

RescueContainer::= SEQUENCE {
    lightBarSirenInUse LightBarSirenInUse
}

EmergencyContainer::=SEQUENCE {
    lightBarSirenInUse LightBarSirenInUse,
    incidentIndication CauseCode OPTIONAL,
    emergencyPriority EmergencyPriority OPTIONAL
}

CauseCode::= SEQUENCE {
    causeCode CauseCodeType,
    subCauseCode SubCauseCodeType
}

SafetyCarContainer::= SEQUENCE {
    lightBarSirenInUse LightBarSirenInUse,
    incidentIndication CauseCode OPTIONAL,
    trafficRule TrafficRule OPTIONAL,
    speedLimit SpeedLimit OPTIONAL
}

Denm::= SEQUENCE {
    header ItsPduHeader,
    denm DecentralizedEnvironmentalNotificationMessage
}

DecentralizedEnvironmentalNotificationMessage::= SEQUENCE {
    management ManagementContainer,
    situation SituationContainer OPTIONAL,
    location LocationContainer OPTIONAL,
    alacarte AlacarteContainer OPTIONAL
}

ManagementContainer::= SEQUENCE {
    actionID ActionID,
    detectionTime TimeStampIts,
    referenceTime TimeStampIts,
    termination Termination OPTIONAL,
    eventPosition ReferencePosition,
    relevanceDistance RelevanceDistance OPTIONAL,
    relevanceTrafficDirection RelevanceTrafficDirection OPTIONAL,
    validityDuration ValidityDuration OPTIONAL,
    transmissionInterval TransmissionInterval OPTIONAL,
    stationType StationType,
    ...
}

ActionID::= SEQUENCE {
    originatingStationID StationID,
    sequenceNumber SequenceNumber
}

SituationContainer::= SEQUENCE {
    informationQuality InformationQuality, 
    eventType CauseCode,
    linkedCause CauseCode OPTIONAL,
    eventHistory EventHistory OPTIONAL,
    ...
}

EventPoint::= SEQUENCE {
    eventPosition DeltaReferencePosition,
    eventDeltaTime PathDeltaTime OPTIONAL,
    informationQuality InformationQuality
}

LocationContainer::= SEQUENCE {
    eventSpeed Speed OPTIONAL,
    eventPositionHeading Heading OPTIONAL,
    traces Traces,
    roadType RoadType OPTIONAL,
    ...
}

AlacarteContainer::= SEQUENCE {
    lanePosition LanePosition OPTIONAL,
    impactReduction ImpactReductionContainer OPTIONAL,
    externalTemperature Temperature OPTIONAL,
    roadWorks RoadWorksContainerExtended OPTIONAL,
    positioningSolution PositioningSolutionType OPTIONAL,
    stationaryVehicle StationaryVehicleContainer OPTIONAL,
    ...
}

ImpactReductionContainer::= SEQUENCE {
    heightLonCarrLeft HeightLonCarr,
    heightLonCarrRight HeightLonCarr,
    posLonCarrLeft PosLonCarr,
    posLonCarRight PosLonCarr,
    positionOfPillars PositionOfPillars,
    posCentMass PosCentMass,
    wheelBaseVehicle WheelBaseVehicle,
    turningRadius TurningRadius,
    posFrontAx PosFrontAx,
    positionOfOccupants PositionOfOccupants,
    vehicleMass VehicleMass,
    requestResponseIndication RequestResponseIndication
}

RoadWorksContainerExtended::= SEQUENCE {
    lightBarSirenInUse LightBarSirenInUse OPTIONAL,
    closedLanes ClosedLanes OPTIONAL,
    restriction RestrictedTypes OPTIONAL,
    speedLimit SpeedLimit OPTIONAL,
    incidentIndication CauseCode OPTIONAL,
    recommendedPath ItineraryPath OPTIONAL,
    startingPointSpeedLimit DeltaReferencePosition OPTIONAL,
    trafficFlowRule TrafficRule OPTIONAL,
    referenceDenms ReferenceDenms OPTIONAL
}

StationaryVehicleContainer::= SEQUENCE {
    stationarySince StationarySince OPTIONAL,
    stationaryCause CauseCode OPTIONAL,
    carryingDangerousGoods DangerousGoodsExtended OPTIONAL,
    numberOfOccupants NumberOfOccupants OPTIONAL,
    vehicleIdentification VehicleIdentification OPTIONAL,
    energyStorageType EnergyStorageType OPTIONAL
}

VehicleIdentification::= SEQUENCE {
    wMInumber WMInumber OPTIONAL,
    vDS VDS OPTIONAL,
    ...
}

DangerousGoodsExtended::= SEQUENCE {
    dangerousGoodsType DangerousGoodsBasic,
    unNumber UnNumber,
    elevatedTemperature ElevatedTemperature,
    tunnelsRestricted TunnelsRestricted,
    limitedQuantity LimitedQuantity,
    emergencyActionCode EmergencyActionCode OPTIONAL,
    phoneNumber PhoneNumber OPTIONAL,
    companyName CompanyName OPTIONAL
}

END
apconole commented 6 years ago

I see some kinds of strangeness in that file. I guess automatic tagging is implicit for asn1c - maybe that's the default in a newer standard. If I remove the ',...' from the two integers (PathDeltaTime and ProtectedZoneRadius), and change the definitions to AUTOMATIC TAGS, I don't see any issues.

can you run 'esnacc --version' and give the output?

momor10 commented 6 years ago

i had added AUTOMATIC TAGS to compile it with asn1c because it would fail because of duplicate tags. as for the esnacc version: i had "git clone https://github.com/esnacc/esnacc-ng" today. however ill get the --version output tomorrow morning. Im not sure if i tried both, adding automatic tags and removing the ",.." with esnacc. Ill try that too (Im sure i tried each).

momor10 commented 6 years ago

Version output: Version 1.8.99 Release Date: UNRELEASED

I removed ',..' and added AUTOMATIC TAGS and still get the SortTypeDefs error. I use the following command: esnacc -C file.asn

edit: i managed to compile the latest source on windows. After editing the asn file i was able to compile it there resulting in a .cpp and .h file Is there any.

Is there any example on how to use it in a qt project? I guess i need to add the cxx-lib. what's the minimal configuration? Is there any Uper encoding example?

edit2: im using msvc2017 for qt. I build the compiler using mingw.

apconole commented 6 years ago

Check the cxx-examples for how to use the resulting .h/.cpp files. The short of it is:

  1. Include the relevant h file and cpp file in your project (preferably by building them from the asn1 spec)
  2. Link against the libraries (see the .pc file for which packages you'll need to include)
  3. Ensure that you use the correct buffers to decode / encode. cxx-examples does have info, as well as the developer's guide https://github.com/esnacc/esnacc-ng/blob/master/doc/developer-guide.md

Is it okay to close this issue now?

momor10 commented 6 years ago

yes this issue can be closed, thank you