wallento / wavedrompy

WaveDrom compatible python command line
Other
97 stars 23 forks source link

When data Is A String, Repeated Whitespace Is Parsed As One Separator #12

Closed MutantPlatypus closed 5 years ago

MutantPlatypus commented 5 years ago

I'm not sure how significant this is, as there's an easy workaround.

Given the JSON:

{ "signal": [
  { "name": "trig", "wave": "lh...............", "node": ".t................"},
  { "name": "0",    "wave": "l..====4=0.......", "node": "...a..............", "data": "       b[0] b[1] b[2] b[3] ... b[n]",            "phase":0},
  { "name": "1",    "wave": "l..====4=0.......", "node": "...b..............", "data": "       b[0] b[1] b[2] b[3] ... b[n]",            "phase":-1},
  { "name": "2",    "wave": "x.3====4==30.....", "node": "...c..............", "data": "SoT    b[0] b[1] b[2] b[3] ... b[n]    CRC EoT", "phase":-1.5},
  { "name": "3",    "wave": "x35====4=5=30....", "node": "...d..............", "data": "SoT PH b[0] b[1] b[2] b[3] ... b[n] PF CRC EoT", "phase":-5}
  ],
  "edge": [
    "t~>a",
    "a~>b",
    "b~>c",
    "c~>d"
  ]
}

wavedrompy seems to collapse repeated whitespace as single delimiter: image

WaveDrom parses repeated whitespace as empty strings: image

A workaround appears to be to just use the undocumented feature of feeding data strings as an array instead of one large string. The below renders the same in both WaveDrom and wavedrompy (that is, the below renders the same as above only in wavedrompy):

{ "signal": [
  { "name": "trig", "wave": "lh...............", "node": ".t................"},
  { "name": "0",    "wave": "l..====4=0.......", "node": "...a..............", "data": [             "b[0]", "b[1]", "b[2]", "b[3]", "...", "b[n]"],                     "phase":0},
  { "name": "1",    "wave": "l..====4=0.......", "node": "...b..............", "data": [             "b[0]", "b[1]", "b[2]", "b[3]", "...", "b[n]"],                     "phase":-1},
  { "name": "2",    "wave": "x.3====4==30.....", "node": "...c..............", "data": ["SoT",       "b[0]", "b[1]", "b[2]", "b[3]", "...", "b[n]",       "CRC", "EoT"], "phase":-1.5},
  { "name": "3",    "wave": "x35====4=5=30....", "node": "...d..............", "data": ["SoT", "PH", "b[0]", "b[1]", "b[2]", "b[3]", "...", "b[n]", "PF", "CRC", "EoT"], "phase":-5}
  ],
  "edge": [
    "t~>a",
    "a~>b",
    "b~>c",
    "c~>d"
  ]
}
wallento commented 5 years ago

Hm, I don't really like the behavior of WaveDrom here. The way you write it, someone would expect something different. Anyhow, that is not achieved either way. I will replicate it anyways.

I didn't even know about the string writing as I always use the latter (arrays). We definitely need a comprehensive spec..

Thanks for reporting, I will get into it!

wallento commented 5 years ago

I reported it to wavedrom, as I want confirmation that it is actual expected behavior or a bug in wavedrom.

wallento commented 5 years ago

As in https://github.com/wavedrom/wavedrom/issues/249 it will be fixed in WaveDrom instead.