wallento / wavedrompy

WaveDrom compatible python command line

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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

MutantPlatypus opened this issue · comments

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"
  ]
}

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!

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

As in wavedrom/wavedrom#249 it will be fixed in WaveDrom instead.