TimeTagArgument doesn't hold time

Create issue
Issue #28 new
anjiro created an issue

The docstring for {{{TimeTagArgument}}} specifies that a time tag is the seconds since midnight on 1/1/1900. From then to the UNIX Epoch (1/1/1970) is 2208988800 seconds; from the Epoch to about now is 1297985487.378675 seconds. So from 1/1/1900 to now is 3506974287.378675 seconds. However:

{{{

txosc.osc.TimeTagArgument(3506974287.378675).toBinary() main:1: DeprecationWarning: 'l' format requires -2147483648 <= number <= 2147483647 "\xd1\x08.O\x16\x92\x1f'" }}}

and

{{{

txosc.osc.TimeTagArgument.fromBinary(txosc.osc.TimeTagArgument(3506974287.378675).toBinary())[0].value -787993008.62132502 }}}

which is clearly not 3506974287.378675.

I think this can be fixed by replacing the three occurrences of {{{struct.pack('>ll'}}}... with {{{struct.pack('>qq'}}}... in osc.py.

Comments (5)

  1. Former user Account Deleted

    I applied the patch in the timetags branch, but the test fails, and it seems to me it will need a few hours of work to get it right.

    Thanks for the patch!

    [FAIL]: txosc.test.test_osc.TestTimeTagArgument.testToBinary
    
    Traceback (most recent call last):
      File "/home/aalex/src/txosc/txosc/test/test_osc.py", line 187, in testToBinary
        self.assertEquals(binary, "\0\0\0\1\0\0\0\0")
    twisted.trial.unittest.FailTest: not equal:
    a = '\x00\x00\x00\x00\x00\x00\x00\x01\x00\x00\x00\x00\x00\x00\x00\x00'
    b = '\x00\x00\x00\x01\x00\x00\x00\x00'
    
    ===============================================================================
    [ERROR]: txosc.test.test_async.TestReceiverWithExternalClient.testBundle
    
    Traceback (most recent call last):
    Failure: twisted.internet.defer.TimeoutError: <txosc.test.test_async.TestReceiverWithExternalClient testMethod=testBundle> (testBundle) still running at 1.0 secs
    ===============================================================================
    [ERROR]: txosc.test.test_async.TestReceiverWithExternalClient.testBundle
    
    Traceback (most recent call last):
      File "/usr/lib/python2.6/dist-packages/twisted/internet/udp.py", line 121, in doRead
        self.protocol.datagramReceived(data, addr)
      File "/home/aalex/src/txosc/txosc/async.py", line 145, in datagramReceived
        element = _elementFromBinary(data)
      File "/home/aalex/src/txosc/txosc/osc.py", line 707, in _elementFromBinary
        element, data = Bundle.fromBinary(data)
      File "/home/aalex/src/txosc/txosc/osc.py", line 223, in fromBinary
        raise OscError("Unexpected end of bundle: need %d bytes of data" % size)
    txosc.osc.OscError: Unexpected end of bundle: need 1728053248 bytes of data
    ===============================================================================
    [ERROR]: txosc.test.test_osc.TestTimeTagArgument.testFromBinary
    
    Traceback (most recent call last):
      File "/home/aalex/src/txosc/txosc/test/test_osc.py", line 191, in testFromBinary
        self.assertEquals(1.0, osc.TimeTagArgument.fromBinary("\0\0\0\1\0\0\0\0")[0].value)
      File "/home/aalex/src/txosc/txosc/osc.py", line 456, in fromBinary
        raise OscError("Too few bytes left to get a timetag from %s." % (data))
    txosc.osc.OscError: Too few bytes left to get a timetag from .
    -------------------------------------------------------------------------------
    Ran 59 tests in 1.094s
    
    FAILED (skips=2, failures=1, errors=3, successes=54)
    
    
  2. anjiro reporter

    As it turns out, rather than struct.pack('>qq' it should be struct.pack('>LL', to maintain compatibility with other OSC libraries.

  3. Log in to comment