I am running the latest version of asn1c v0.9.24 on Windows 64bit and gcc in cygwin64.
I have a question about the INTEGER_t type and specifically the function asn_long2INTEGER.
Here is a extract of a complex multi-file asn1-specification:
I wrote an example program for encoding and decoding the pdu based in the pdf on the homepage.
A other example from this specification works, but I don’t have to use the INTEGER_t-type in it.
Here is the code, that potentially causes the problems:
int retvalue = 0;
retvalue = asn_ulong2INTEGER(&denm->denm.management.detectionTime, 1);
printf("Return value detectionTime: %d.\n", retvalue);
detectionTime is from type Timestamplts and the printed value of retvalue is 0, as excepted.
Here now the code to encode my object. It is basically the example from the pdf with my types:
Hi Adrian,
a DENM packet must have a field called ReferenceTime that has to be set
to the time of event detection.
I think that the uper_encoder is failing for that missing field.
I'm developing ETSI standards for embedded devices and I have not
problems with CAMS neither in development environment (64 bit machine)
neither in production machines (32 bit ARM CPUs).
Problems arise with DENM, particularly with very large field "TimestampIts_t".
This is because of asn_ulong2INTEGER(INTEGER_t *st, unsigned long value)
function in INTEGER.c (also other functions have the same problem);
asn_ulong2INTEGER second parameter (4 bytes on 32 bit machines) cannot
support data over 4294967295. Since ReferenceTime and DetectionTime
are millis from 2004, previous value will always be exceeded.
Futhermore TimestampIts contraints in TimestampIts.c :
Hi, I'm also facing same issue while encoding "TimestampIts" with 5bytes on 32-bit machine, but able to succeed in 64-bit machine. Even tried with -fwide-types option still no luck.
Please share the solution, if any one sloved the issue.
Thanks,
pvk
Last edit: pvk 2016-03-07
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hey,
I am running the latest version of asn1c v0.9.24 on Windows 64bit and gcc in cygwin64.
I have a question about the INTEGER_t type and specifically the function asn_long2INTEGER.
Here is a extract of a complex multi-file asn1-specification:
Timestamplts ::= INTEGER {utcStartOf2004(0), oneMillisecAfterUTCStartOf2004(1)} (0..3153600000000)
The asn1c-compiler generates the following code:
/ Dependencies /
typedef enum Timestamplts {
Timestamplts_utcStartOf2004 = 0,
Timestamplts_oneMillisecAfterUTCStartOf2004 = 1
} e_Timestamplts;
/ Timestamplts /
typedef INTEGER_t Timestamplts_t;
I wrote an example program for encoding and decoding the pdu based in the pdf on the homepage.
A other example from this specification works, but I don’t have to use the INTEGER_t-type in it.
Here is the code, that potentially causes the problems:
int retvalue = 0;
retvalue = asn_ulong2INTEGER(&denm->denm.management.detectionTime, 1);
printf("Return value detectionTime: %d.\n", retvalue);
detectionTime is from type Timestamplts and the printed value of retvalue is 0, as excepted.
Here now the code to encode my object. It is basically the example from the pdf with my types:
ec = uper_encode(&asn_DEF_DENM, denm, write_out, fp);
fclose(fp);
if(ec.encoded == -1) {
fprintf(stderr, "Could not encode CamObject (at %s)\n", ec.failed_type ? ec.failed_type->name "unknown");
exit(65); / better, EX_DATAERR /
} else {
fprintf(stderr, "Created %s with BER encoded file\n",
filename);
}
The programs aborts with the message “Could not encode CamObject (at Timestamplts)”.
Am I using the function asn_long2INTEGER the wrong way?
Thanks in advance for your help!
Adrian
Hi Adrian,
a DENM packet must have a field called ReferenceTime that has to be set
to the time of event detection.
I think that the uper_encoder is failing for that missing field.
I'm developing ETSI standards for embedded devices and I have not
problems with CAMS neither in development environment (64 bit machine)
neither in production machines (32 bit ARM CPUs).
Problems arise with DENM, particularly with very large field "TimestampIts_t".
This is because of asn_ulong2INTEGER(INTEGER_t *st, unsigned long value)
function in INTEGER.c (also other functions have the same problem);
asn_ulong2INTEGER second parameter (4 bytes on 32 bit machines) cannot
support data over 4294967295. Since ReferenceTime and DetectionTime
are millis from 2004, previous value will always be exceeded.
Futhermore TimestampIts contraints in TimestampIts.c :
static asn_per_constraints_t asn_PER_type_TimestampIts_constr_1 GCC_NOTUSED = {
{ APC_CONSTRAINED, 42, -1, 0, 4398046511103 } / (0..4398046511103) /,
{ APC_UNCONSTRAINED, -1, -1, 0, 0 },
0, 0 / No PER value map /
};
will always fail during decoding.
Have you experienced same problems and found any valid solution?
Hi !
I've got the same issue with an Integer_t on a similar timestamp structure.
Do you have solved this problem ?
Thanks !
Thibaud
Hi, I'm also facing same issue while encoding "TimestampIts" with 5bytes on 32-bit machine, but able to succeed in 64-bit machine. Even tried with -fwide-types option still no luck.
Please share the solution, if any one sloved the issue.
Thanks,
pvk
Last edit: pvk 2016-03-07