Open avlapp opened 1 year ago
I think I found the cause:
SendTo calls Bytes method on packet (a osc message) https://github.com/scgolang/osc/blob/master/udp.go#L106C29-L106C29
Bytes method of message calls Bytes method for arguments, in this case a String https://github.com/scgolang/osc/blob/master/message.go#L58
https://github.com/scgolang/osc/blob/master/argument.go#L239
Bytes method of String calls ToBytes. ToBytes returns []byte{} when len(string) == 0 https://github.com/scgolang/osc/blob/master/osc.go#L46
Then Pad doesn't append any null character (it isn't called) https://github.com/scgolang/osc/blob/master/osc.go#L55
ToBytes is also used for msg.Address and BundleTag : https://github.com/scgolang/osc/blob/master/message.go#L54 https://github.com/scgolang/osc/blob/master/bundle.go#L79
Both can't be empty according to the OSC specs I think*.
And a empty string is tested: https://github.com/scgolang/osc/blob/master/osc_test.go#L14 It expects: []byte{} but in this case it should be the following I think: []byte{0,0,0,0}
From the specs: osc string = A sequence of non-null ASCII characters followed by a null, followed by 0-3 additional null characters
( Not related to this issue I think, but ReadString has a similar way of handling empty strings https://github.com/scgolang/osc/blob/master/osc.go#L71 )
Looking at the gosc library, it checks if a string has "\x00" as suffix and adds it when it doesn't have any, as is the case with a empty string. https://github.com/loffa/gosc/blob/master/writer.go#L104
I think something similar is done in the go-osc library: https://github.com/hypebeast/go-osc/blob/master/osc/osc.go#L1027
Sending a empty string doesn't seems to work using osc.String("")
Error 9912
https://github.com/radarsat1/liblo/blob/cb6f43da7cc137a2a64f129cdbb54638658a0d30/lo/lo_errors.h#L35
define LO_EINVALIDARG 9912