diff cos/utils/bin2c.py @ 25:d3c4bf3720a3

Beginning of multitasking
author windel
date Tue, 27 Dec 2011 13:31:38 +0100
parents
children 47b7df514243
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/cos/utils/bin2c.py	Tue Dec 27 13:31:38 2011 +0100
@@ -0,0 +1,19 @@
+#!/usr/bin/python
+
+import sys
+print(sys.argv)
+if len(sys.argv) < 2:
+   print('Usage: {0} binfile [headerfile]'.format(sys.argv[0]))
+   sys.exit(-1)
+
+with open(sys.argv[1], 'rb') as f:
+   data = f.read()
+
+s = ', '.join(hex(b) for b in data)
+output = 'unsigned char[] data = {{{0}}};'.format(s)
+if len(sys.argv) < 3:
+   print(output)
+else:
+   with open(sys.argv[2], 'w') as f:
+      f.write(output)
+