core-wg / yang-cbor

Internet-Draft for CBOR representation of YANG data
5 stars 10 forks source link

anydata example bug in yang-cbor draft #129

Closed abierman closed 2 years ago

abierman commented 2 years ago
   {
     60123 : {                   / last-event (SID 60123) /
       77 : {                    / example-port-fault (SID 60200) /
         1 : "0/4/21",           / port-name (SID 60201) /
         2 : "Open pin 2"        / port-fault (SID 60202) /
       }
     }
   }

   CBOR encoding:

   A1                               # map(1)
      19 EADB                       # unsigned(60123)
      A1                            # map(1)
         18 4D                      # unsigned(77)
         A2                         # map(2)
            18 4E                   # unsigned(78)
            66                      # text(6)
               302F342F3231         # "0/4/21"
            18 4F                   # unsigned(79)
            6A                      # text(10)
               4F70656E2070696E2032 # "Open pin 2"

It appears the example in 4.5.1 is wrong for the port-name and port-fault leafs. The SID parent should restart for the notification "container". The diagnostic notation correctly shows +1 and +2 deltas for these SIDs. The CBOR encoding shows +78 and +79 deltas.

Corrected CBOR encoding:

   A1                               # map(1)
      19 EADB                       # unsigned(60123)
      A1                            # map(1)
         18 4D                      # unsigned(77)
         A2                         # map(2)
            01                      # unsigned(1)
            66                      # text(6)
               302F342F3231         # "0/4/21"
            02                      # unsigned(2)
            6A                      # text(10)
               4F70656E2070696E2032 # "Open pin 2"
mcr commented 2 years ago

Should we correct this manually, or is there a script somewhere that we need to fix? Maybe this applies to other examples too?