根据ASN1C编译生成的协议,以CSAE 53-2020的BSM.asn为例
BSM DEFINITIONS AUTOMATIC TAGS ::= BEGIN
-- imports and exports
EXPORTS BasicSafetyMessage;
IMPORTS AccelerationSet4Way FROM DefAcceleration
BrakeSystemStatus FROM VehBrake
VehicleSize FROM VehSize
Position3D, PositionConfidenceSet, PositionalAccuracy FROM DefPosition
DSecond, TimeConfidence FROM DefTime
TransmissionState FROM VehStatus
Speed, Heading, SteeringWheelAngle, MotionConfidenceSet FROM DefMotion
MsgCount FROM MsgFrame
VehicleClassification FROM VehClass
VehicleSafetyExtensions FROM VehSafetyExt
VehicleEmergencyExtensions FROM VehEmgExt;
BasicSafetyMessage ::= SEQUENCE {
msgCnt MsgCount,
id OCTET STRING (SIZE(8)),
-- temperary vehicle ID
secMark DSecond,
timeConfidence TimeConfidence OPTIONAL,
pos Position3D,
posAccuracy PositionalAccuracy OPTIONAL,
-- Accuracy for GNSS system
posConfidence PositionConfidenceSet OPTIONAL,
-- Realtime position confidence
transmission TransmissionState,
speed Speed,
heading Heading,
angle SteeringWheelAngle OPTIONAL,
motionCfd MotionConfidenceSet OPTIONAL,
accelSet AccelerationSet4Way,
brakes BrakeSystemStatus,
size VehicleSize,
vehicleClass VehicleClassification,
-- VehicleClassification includes BasicVehicleClass and other extendible type
safetyExt VehicleSafetyExtensions OPTIONAL,
emergencyExt VehicleEmergencyExtensions OPTIONAL,
...
}
END
(1)截取以下部分:
BasicSafetyMessage ::= SEQUENCE {
msgCnt MsgCount,
id OCTET STRING (SIZE(8)),
-- temperary vehicle ID
secMark DSecond,
timeConfidence TimeConfidence OPTIONAL,
pos Position3D,
posAccuracy PositionalAccuracy OPTIONAL,
-- Accuracy for GNSS system
posConfidence PositionConfidenceSet OPTIONAL,
-- Realtime position confidence
transmission TransmissionState,
speed Speed,
heading Heading,
angle SteeringWheelAngle OPTIONAL,
motionCfd MotionConfidenceSet OPTIONAL,
accelSet AccelerationSet4Way,
brakes BrakeSystemStatus,
size VehicleSize,
vehicleClass VehicleClassification,
-- VehicleClassification includes BasicVehicleClass and other extendible type
safetyExt VehicleSafetyExtensions OPTIONAL,
emergencyExt VehicleEmergencyExtensions OPTIONAL,
...
}
(2)按照该部分的内容,依次粘贴其他ASN文件,将其放在同一个文件下,并取名为***.asn
(3)进入该网站https://asn1.io/asn1playground/
点击如下图所示部分:
(4)选择你需要刚刚制作的asn文件,并点击右下角的编译
(5)编译成功后你可以看到如下画面:
(6)输入你收到的被编码后的字符串,这里选用的是UPER编码
(7)单击解码(decode),便会成功打印解码信息
(8)通过点击download,可以下载txt或者json格式的文件
rec1value MessageFrame ::= bsmFrame : {
msgCnt 10,
id '1020300000000000'H,
secMark 1234,
pos {
lat 1000,
long 230000
},
transmission forwardGears,
speed 1234,
heading 456,
accelSet {
long 12,
lat 34,
vert 56,
yaw 78
},
brakes {
},
size {
width 90,
length 0
},
vehicleClass {
classification 20
}
}
结束!