nxp-archive / openil_tsntool

Other
23 stars 11 forks source link

tsntool does not generate and output valid JSON for list elements #5

Open hthiery opened 4 years ago

hthiery commented 4 years ago

especially for:

# tsntool  qbvget --device swp0
echo reply:swp0
tsn: len: 0090 type: 0006 data:
  level2: nla->_len: 96 type: 11

   listcount = 2
   level3: nla->_len: 28 type: 6

     entryid = 0
     gate = 03
     timeperiod = 186a0
   level3: nla->_len: 28 type: 6

     entryid = 1
     gate = 80
     timeperiod = 186a0
   gatestate = 80
   cycletime = 1e8480
   basetime = 2876034e0a6
   configchangetime = 28760536526
   currenttime = 289b35068e6
   listmax = 40
json structure:
 {
    "oper": {
        "listcount":    2,
        "list": {
            "entryid":  0,
            "gate": 3,
            "timeperiod":   100000
        },
        "list": {                               <<<< here the key "list" is used second time and overwrites the first one. and the content is not a list
            "entryid":  1,
            "gate": 128,
            "timeperiod":   100000
        },
        "gatestate":    128,
        "cycletime":    2000000,
        "basetime": 2780457918630
    },
    "configchangetime": 2780459918630,
    "currenttime":  2790442166502,
    "listmax":  64
}

valid json should look like that:

{
    "oper": {
        "listcount":    2,
        "list": [
            {
            "entryid":  0,
            "gate": 3,
            "timeperiod":   100000
            },
            {
            "entryid":  1,
            "gate": 128,
            "timeperiod":   100000
            }
        ],
        "gatestate":    128,
        "cycletime":    2000000,
        "basetime": 2780457918630
    },
    "configchangetime": 2780459918630,
    "currenttime":  2790442166502,
    "listmax":  64
}
liupoer commented 4 years ago

Hi Heiko, You are right. That is a bug. Will fix.

Thanks! Po Liu