pq / osc

A simple Open Sound Control (OSC) protocol implementation for Dart.
BSD 3-Clause "New" or "Revised" License
32 stars 19 forks source link

First osc arg with 4 char string causes decode bug #14

Open bpostlethwaite opened 3 years ago

bpostlethwaite commented 3 years ago
  var msg = OSCMessage("/dun/dap", arguments: ["aaaa", 1, 2]);
  var bytes = msg.toBytes();
  var msg2 = OSCMessage.fromBytes(bytes);
  print(msg2.toString());

prints

OSCMesssage(/dun/dap, args: [aaaa, 0, 1])

Note the 0 as the first argument.

bpostlethwaite commented 3 years ago

Actually same with other combinations such as

var msg = OSCMessage("/set", arguments: ["/dun/dap", 3, 3]);
OSCMesssage(/set, args: [/dun/dap, 0, 3])
bpostlethwaite commented 3 years ago

I tested another OSC implementation and that implementation receives bytes from this library OK which makes me believe it is in the decoding.

bpostlethwaite commented 3 years ago

~Actually this appears to be fixed on the most recent master commit. When cloning this lib and installing from path, it works.~

bpostlethwaite commented 3 years ago

Found the location of the error (line: 336 of convert.dart)

      //  if (value is String) eat(byte: 0);

remove the comment and eating the padded string bytes fixes the issue. Not sure if it causes others.

pq commented 3 years ago

Thanks for tracking this down! @jeffmikels: it looks like that change goes back to some parsing fixes you landed (https://github.com/pq/osc/commit/e1e4662d9b598fdb14666992cdbce723c29c0c64). Any thoughts?

jeffmikels commented 3 years ago

I'll look into it.

pq commented 3 years ago

Thanks!