added further exit function, so the board restarts after reset
[pyfrprog.git] / pkernel / kernel.py
index 3ebda56f3ad0952f12990f1d951df6ce1532b488..8bf955b377dd0ec822f430910f666829292d0684 100755 (executable)
@@ -9,9 +9,6 @@ KERNEL_BAUDRATE=38400
 
 def recvByte():
        i = tty.read()
-       while len(i)==0:
-               time.sleep(0.03)
-               i = tty.read()
        return ord(i)
 
 def sendByte(byte):
@@ -59,18 +56,10 @@ def pkernWRITE(address, size, data):
        sendDWord(address)
        sendWord(size)
 
-       if (recvByte() != 0x04):
-               raise Exception
-       print "Received Metadata."
-
        # write binary stream of data
        for i in range(0, size):
                sendByte(data[i])
 
-       if (recvByte() != 0x08):
-               raise Exception
-       print "Received Data."
-
        if (recvByte() != 0x28):
                raise Exception
        print "Flashing done."
@@ -86,7 +75,7 @@ flashseqs = []
 
 
 print "Initializing serial port..."
-tty = SerialPort(DEVICE, 0, KERNEL_BAUDRATE)
+tty = SerialPort(DEVICE, None, KERNEL_BAUDRATE)
 
 # check command line arguments
 if len(sys.argv) != 2:
@@ -147,6 +136,9 @@ for seq in flashseqs:
        print "Flashing", len(seq.data), "bytes at address", hex(seq.address)
        pkernWRITE(seq.address, len(seq.data), seq.data)
 
-sendByte(0x99);
-
+"""
+sendByte(0x99) #exit and wait
 print "Reset your board now to run code from Flash"
+"""
+
+sendByte(0x97) #exit and restart