example_encoder.py 585 Bytes
Newer Older
1
2
3
4
5
6
7
#!/usr/bin/python

import labcomm
import sys
import simple

if __name__ == '__main__':
8
    version = sys.argv[2] if len(sys.argv) == 3 else "LabComm2014"
9
    encoder = labcomm.Encoder(labcomm.StreamWriter(open(sys.argv[1], 'w')), version)
10
11
12
13
14
15
16
17
18
19
20
    encoder.add_decl(simple.theTwoInts.signature)
    encoder.add_decl(simple.IntString.signature)
    foo = simple.theTwoInts()
    foo.a = 13
    foo.b = 37
    encoder.encode(foo, simple.theTwoInts.signature)

    bar = simple.IntString()
    bar.x = 1742
    bar.s = "A string from Python"
    encoder.encode(bar, simple.IntString.signature)