eerimoq / asn1tools

ASN.1 parsing, encoding and decoding.
MIT License
296 stars 100 forks source link

Error when encoding Basic APER Bit String #114

Open tangkai-prc opened 3 years ago

tangkai-prc commented 3 years ago

When Encoding a APER BitString like the following format:

TriggerConditions ::= BIT STRING {
    reserved (0),
    data-change (1),
    quality-change (2),
    data-update (3),
    integrity (4),
    general-interrogation (5)
} (SIZE(6))

foo = asn1tools.compile_files('gsp_commu_service_all.asn','per')
res = foo.encode('TriggerConditions', (b'\xff',6))

And what I am looking for is 0xFC ,but the result is : 0xFF,

however when I modified the asn syntax like this: TriggerConditions := BIT STRING(SIZE(6)) The result would be right. I think maybe something wrong when encode BIT String described like that way.

eerimoq commented 3 years ago

Feel free to implement a fix. I don't have time to do so myself.