Open Yufei-Yan opened 6 years ago
Please send your ASN spec along as well (or by private mail to me if you wish). Your addition of the
@Yufei-Yan , compile your program with -g
flag and use gdb
stepping into function call then you can find where it failed.
Hi, @DavidKelleySCSC Can I have your email please? I cannot post it here. sorry.
I admit that the ASN file could be wrong or some fields may not be defined correctly. But the wired thing is that this BSM
can be successfully encoded and decoded by der_encode_to_buffer()
and ber_decode()
. When this BSM
is encapsulated into MessagaFrame
, ber_decode()
cannot decode the MessageFrame, and it gives an error at value
in MessageFrame
. This makes me confused.
Hi, @brchiu
Thanks for you reply.
The program is running on an embedded platform, and the OS is rather minimal. I doubt it has gdb. And also, the function fails in ber_decode()
, it gives error at value
in MessageFrame
when decoding. The program does not crash.
What else can I do to debug this issue?
Thank you.
@Yufei-Yan , could you have a trial using https://github.com/brchiu/asn1c/tree/velichkov_s1ap_plus_option_group ?
asn1c community members have fixed several problems found in master branch of @vlm's repository.
By the way, under examples/sample.source.J2735
directory, you can compile a sample utility program called j2735-dump
with debug flag -g
on Linux platform. Then feed it with the data you want to encode or decode then step into each function call on Linux platform.
For example, I use it to process the xml you post with ./j2735-dump -dd -ixer message1.xer -oder message1.ber
then I get the following debug message.
https://gist.github.com/brchiu/a56c690e4c159f36ac574fbb8c387632
After AD: Encoded in 113 bytes of DER
, at line 1200 of this log, there are still more data in your <platoon>
tag which does not exist in the default J2735 ASN.1 which I purchased. So it displays
AD: RC_WMORE, continuing read=0, cons=1 with 1..0-0..1
in line 1238.
@brchiu , thank you so much for your help.
<platoon>
tag is our customized tag. It's not in standard J2735 ASN file.
I'll try the tool you mentioned for sure.
The weird thing is when I encode and decode a simple BSM
with <platoon>
tag, it is successful. But when I embed this BSM
in a MessageFrame
, the function ber_decode()
gives an error, failing at value
in MessageFrame
.
Again, I appreciate your effort.
I'm facing the exact same error has this been fixed?
@ronMilne , not yet confirmed if this is a bug or not. Haven't got any time to test it since then. Can I ask if you are working on standard J2735 ASN file or a customized ASN file?
I was working on a customized ASN file, and came across this issue. I might have time to test it again in the next couple of weeks.
Thanks.
To repeat a prior offer...
Please send your ASN spec along as well (or by private mail to me if you wish).
Can take a look at it for issues, it is easily easy to 'break' the frame and I am aware the SAE TC needs to get a suitable example of how to do this out into the world. Regards, David Kelley, SAE J2735 DSRC Msg Set Editor
My ASN is the standard J2735 (latest). I'm successfully encoding/decoding a BSM but not the MessageFrame.
MessageFrame_t* msgFrame = (MessageFrame_t*)calloc(1, sizeof *msgFrame);
msgFrame->messageId = 100;
msgFrame->value.present = (MessageFrame__value_PR)MessageFrame__value_PR_BasicSafetyMessage;
msgFrame->value.choice.BasicSafetyMessage = *bsm;
asn_encode_to_new_buffer_result_t rsltMsg = asn_encode_to_new_buffer(0, ATS_DER, &asn_DEF_MessageFrame, msgFrame);
Okay, but 100 is not the defined ID for the BSM, 0x20 is. You have got to match up the message Id to an anticipated message content for this to work. If you were to define your own content (in the provided ranges) you have to provide that definition to the ASN tool when it is complied as well. In the absence of defining your own message types, use this to select into what ASN packed strut the source C strut will be placed..
DSRCmsgID ::= INTEGER (0..32767)
-- content removed here , dck
--
-- UPER forms
--
mapData DSRCmsgID ::= 18 -- MAP, intersections
signalPhaseAndTimingMessage DSRCmsgID ::= 19 -- SPAT
-- Above two entries were adopted in the 2015-04 edition
-- Message assignments added in 2015 follow below < and that n means for 2016 as well, dck
basicSafetyMessage DSRCmsgID ::= 20 -- BSM, heartbeat msg
commonSafetyRequest DSRCmsgID ::= 21 -- CSR
emergencyVehicleAlert DSRCmsgID ::= 22 -- EVA
intersectionCollision DSRCmsgID ::= 23 -- ICA
nmeaCorrections DSRCmsgID ::= 24 -- NMEA
probeDataManagement DSRCmsgID ::= 25 -- PDM
probeVehicleData DSRCmsgID ::= 26 -- PVD
roadSideAlert DSRCmsgID ::= 27 -- RSA
rtcmCorrections DSRCmsgID ::= 28 -- RTCM
signalRequestMessage DSRCmsgID ::= 29 -- SRM
signalStatusMessage DSRCmsgID ::= 30 -- SSM
travelerInformation DSRCmsgID ::= 31 -- TIM
personalSafetyMessage DSRCmsgID ::= 32 -- PSM
--
-- The Below values are reserved for local message testing use
--
testMessage00 DSRCmsgID ::= 240 -- Hex 0xF0
testMessage01 DSRCmsgID ::= 241
testMessage02 DSRCmsgID ::= 242
testMessage03 DSRCmsgID ::= 243
testMessage04 DSRCmsgID ::= 244
testMessage05 DSRCmsgID ::= 245
testMessage06 DSRCmsgID ::= 246
testMessage07 DSRCmsgID ::= 247
testMessage08 DSRCmsgID ::= 248
testMessage09 DSRCmsgID ::= 249
testMessage10 DSRCmsgID ::= 250
testMessage11 DSRCmsgID ::= 251
testMessage12 DSRCmsgID ::= 252
testMessage13 DSRCmsgID ::= 253
testMessage14 DSRCmsgID ::= 254
testMessage15 DSRCmsgID ::= 255-- Hex 0xFF
--
-- All other values are reserved for std use
--
One other thing I had to do was set coreData.msgCnt = 1; on the BSM. This was picked up asn_check_constraints on the MessageFrame. Thanks greatly, now have a message that transmits.
And please remember to increment it (modulo 0~127) every time the BSM is updated.
I would suggest that as a best practice you write a utility routine that sets ALL the values found in the BSMcoreData to their default invalid values (and in that data frame they are all required, so for ascn1c you will not have to deal with various pointer issues). If you are wrapping this code in C++, this would be a good constructor step. I would estimate that at least half the support queries I get on that standard deal in one way or another with some of the data elements not set to valid values and then being forgotten.
Given the following BasicSafetyMessage_t bsm; bsm = (BasicSafetyMessage_t)calloc(1, sizeof(BasicSafetyMessage_t));
What is the correct way to create the TemporaryID id field? When calling ASN_STRUCT_FREE? Is there a better way of doing the following
TemporaryID_t* tempId = (TemporaryID_t*)calloc(1, sizeof(TemporaryID_t));
tempId->size = 4;
tempId->buf = (uint8_t*)calloc(1, 4);
const uint8_t tempMacId[] = { 0x00, 0x00, 0x00, 0x02 };
memcpy(tempId->buf, tempMacId, 4);
bsm->coreData.id = *tempId;
Thanks.
I have my J2735_201603SA decoder working now. Don't know why folks here are doing BER/DER as UPER is the chosen standardized format. I do find that ASN_STRUCT_FREE crashes for J2735, but not for the P1609.2 decoder I have (OER).
Neal - I am trying to encode a J2735 Map file for use in an RSU. What J2735_201603SA decoder are you using?
Hi, I'm current facing this issue:
MessageFrame
cannot be decoded after encoded.A
BSM
is generated with some customized fields. When testing to encode and decodeBSM
without encapsulating inMessageFrame
, bothder_encode_to_buffer()
andber_decode()
functions work well.But after encapsulating
BSM
inMessageFrame
, encoding function seems to work (I'm not sure if it is working correctly), decoding function does not work. It gives the result code:2
, which is failure.All messages are properly written, since I can verify them by decode the byte sequence into xml format for verification.
The message below is xml format:
What could be wrong?