#!/usr/bin/env python import sys, string print "Serial uploader" if len(sys.argv) < 2: print "usage: uploader.py " sys.exit(0) print "Reading file..." f = open(sys.argv[1], "r") lines = string.split(f.read(), "\r\n") print "Starting upload..." com = open("/dev/ttyS0", "w") cnt = 0 for i in lines: if not (cnt % 10): sys.stdout.write("%d%% \r" % (cnt * 100 / len(lines))) sys.stdout.flush() cnt = cnt + 1 com.write(i + "\r\n") print "Upload complete."