Source

radio-data / push9k

#!/usr/bin/env python
# -*- coding: utf-8 -*-
import optparse
from serial9k import Serial9k

def main():
    parser = optparse.OptionParser(usage='%prog <port name>',
        version='0.1')
    args = parser.parse_args()[1]

    if len(args) < 2:
        parser.error('port name is mandatory')
    port = args[0]
    f = open(args[1], 'rb')
    file_buffer = f.read()
    print file_buffer
    comm = Serial9k(port=port)
    comm.write(file_buffer)
    comm.close()
    f.close()

if __name__ == '__main__':
    main()