asn1c生成v2x day2 二阶段 消息解码程序
wget下载:
wget http://lionet.info/soft/asn1c-0.9.28.tar.gz
下载其他版本,可以直接进入http://lionet.info/soft/ 查看
解压:tar xvf asn1c-0.9.28.tar.gz
进入源码目录:cd asn1c-0.9.28
配置:./configure
编译:make
安装:make install
asn1c工具安装好了,可以通过运行 asn1c -h 查看用法
生成c代码
ls *.asn
BSM.asn DefPosition.asn Map.asn PAM.asn RSC.asn RTCM.asn TestMsg.asn VehEmgExt.asn VehStatus.asn
DefAcceleration.asn DefPositionOffset.asn MsgDayII.asn Platooning.asn RSI.asn SensorSharing.asn VehBrake.asn VehSafetyExt.asn VIR.asn
DefMotion.asn DefTime.asn MsgFrame.asn PSM.asn RSM.asn SignalPhaseAndTiming.asn VehClass.asn VehSize.asn VPM.asn
asn1c -S /usr/local/share/asn1c -fcompound-names -fskeletons-copy -gen-PER -gen-OER -pdu=auto *.asn
asn1c -h
-fcompound-names Disambiguate C's struct NAME's inside top-level types
-S <dir> Directory with support (skeleton?) files
(Default is "/usr/local/share/asn1c")
-pdu={all|auto|Type} Generate PDU table (discover PDUs automatically)
注意: 如果不加-f compound-names,后续c代码编译时,会报很多枚举重定义错误。-fskeleton-copy是会从
-S指定的目录中,拷贝asn基础类型解码文件,为了不存在依赖必须加上。 不加-pdu=auto的话,不会产生pdu_colletion.c文件,这个文件中定义了所有的消息PDU。make -f converter-example.mk
cc -DASN_PDU_COLLECTION -I. -o converter-example.o -c converter-example.c
cc -DASN_PDU_COLLECTION -I. -o pdu_collection.o -c pdu_collection.c
cc -DASN_PDU_COLLECTION -I. -o converter-example converter-example.o pdu_collection.o libasncodec.a -lm
./converter-example -p list
Available PDU types:
MessageFrame
命令行编解码
./converter-example -p MessageFrame -ixer MessageFrame.xml
<MessageFrame>
<msgFrameExt>
<messageId>13</messageId>
<value>
<VehIntentionAndRequest>
<msgCnt>0</msgCnt>
<id>00 00 00 00 00 06 D6 13</id>
<secMark>110</secMark>
<refPos>
<lat>416955100</lat>
<long>1234521700</long>
<elevation>5454</elevation>
</refPos>
<intAndReq>
</intAndReq>
</VehIntentionAndRequest>
</value>
</msgFrameExt>
</MessageFrame>
本文链接地址:https://const.net.cn/382.html