author | Lolitech |
Fri, 04 Jun 2010 15:11:27 +0200 | |
changeset 557 | b155ada1c14a |
parent 548 | 1428fd553988 |
child 567 | 72b51ec5be64 |
permissions | -rw-r--r-- |
545
627e5c636a4f
Refactored LPC connector for new bootloader and application modes
Lolitech
parents:
diff
changeset
|
1 |
from LPCProto import * |
627e5c636a4f
Refactored LPC connector for new bootloader and application modes
Lolitech
parents:
diff
changeset
|
2 |
|
627e5c636a4f
Refactored LPC connector for new bootloader and application modes
Lolitech
parents:
diff
changeset
|
3 |
class LPCBootProto(LPCProto): |
627e5c636a4f
Refactored LPC connector for new bootloader and application modes
Lolitech
parents:
diff
changeset
|
4 |
def HandleTransaction(self, transaction): |
627e5c636a4f
Refactored LPC connector for new bootloader and application modes
Lolitech
parents:
diff
changeset
|
5 |
self.TransactionLock.acquire() |
627e5c636a4f
Refactored LPC connector for new bootloader and application modes
Lolitech
parents:
diff
changeset
|
6 |
try: |
627e5c636a4f
Refactored LPC connector for new bootloader and application modes
Lolitech
parents:
diff
changeset
|
7 |
transaction.SetPseudoFile(self.serialPort) |
627e5c636a4f
Refactored LPC connector for new bootloader and application modes
Lolitech
parents:
diff
changeset
|
8 |
res = transaction.ExchangeData() |
627e5c636a4f
Refactored LPC connector for new bootloader and application modes
Lolitech
parents:
diff
changeset
|
9 |
finally: |
627e5c636a4f
Refactored LPC connector for new bootloader and application modes
Lolitech
parents:
diff
changeset
|
10 |
self.TransactionLock.release() |
627e5c636a4f
Refactored LPC connector for new bootloader and application modes
Lolitech
parents:
diff
changeset
|
11 |
return "Stopped", res |
627e5c636a4f
Refactored LPC connector for new bootloader and application modes
Lolitech
parents:
diff
changeset
|
12 |
|
627e5c636a4f
Refactored LPC connector for new bootloader and application modes
Lolitech
parents:
diff
changeset
|
13 |
class LPCBootTransaction: |
627e5c636a4f
Refactored LPC connector for new bootloader and application modes
Lolitech
parents:
diff
changeset
|
14 |
def __init__(self, optdata = ""): |
627e5c636a4f
Refactored LPC connector for new bootloader and application modes
Lolitech
parents:
diff
changeset
|
15 |
self.OptData = optdata |
627e5c636a4f
Refactored LPC connector for new bootloader and application modes
Lolitech
parents:
diff
changeset
|
16 |
self.pseudofile = None |
627e5c636a4f
Refactored LPC connector for new bootloader and application modes
Lolitech
parents:
diff
changeset
|
17 |
|
627e5c636a4f
Refactored LPC connector for new bootloader and application modes
Lolitech
parents:
diff
changeset
|
18 |
def SetPseudoFile(self, pseudofile): |
627e5c636a4f
Refactored LPC connector for new bootloader and application modes
Lolitech
parents:
diff
changeset
|
19 |
self.pseudofile = pseudofile |
627e5c636a4f
Refactored LPC connector for new bootloader and application modes
Lolitech
parents:
diff
changeset
|
20 |
|
627e5c636a4f
Refactored LPC connector for new bootloader and application modes
Lolitech
parents:
diff
changeset
|
21 |
def SendData(self): |
548 | 22 |
res = self.pseudofile.write(self.OptData) |
23 |
return True |
|
545
627e5c636a4f
Refactored LPC connector for new bootloader and application modes
Lolitech
parents:
diff
changeset
|
24 |
|
627e5c636a4f
Refactored LPC connector for new bootloader and application modes
Lolitech
parents:
diff
changeset
|
25 |
def GetData(self): |
627e5c636a4f
Refactored LPC connector for new bootloader and application modes
Lolitech
parents:
diff
changeset
|
26 |
pass # not impl |
627e5c636a4f
Refactored LPC connector for new bootloader and application modes
Lolitech
parents:
diff
changeset
|
27 |
|
627e5c636a4f
Refactored LPC connector for new bootloader and application modes
Lolitech
parents:
diff
changeset
|
28 |
def ExchangeData(self): |
627e5c636a4f
Refactored LPC connector for new bootloader and application modes
Lolitech
parents:
diff
changeset
|
29 |
pass |
627e5c636a4f
Refactored LPC connector for new bootloader and application modes
Lolitech
parents:
diff
changeset
|
30 |
|
627e5c636a4f
Refactored LPC connector for new bootloader and application modes
Lolitech
parents:
diff
changeset
|
31 |
class LOADTransaction(LPCBootTransaction): |
627e5c636a4f
Refactored LPC connector for new bootloader and application modes
Lolitech
parents:
diff
changeset
|
32 |
def __init__(self, data): |
627e5c636a4f
Refactored LPC connector for new bootloader and application modes
Lolitech
parents:
diff
changeset
|
33 |
LPCBootTransaction.__init__(self, data) |
627e5c636a4f
Refactored LPC connector for new bootloader and application modes
Lolitech
parents:
diff
changeset
|
34 |
ExchangeData = LPCBootTransaction.SendData |
627e5c636a4f
Refactored LPC connector for new bootloader and application modes
Lolitech
parents:
diff
changeset
|
35 |