author | laurent |
Tue, 24 May 2011 11:27:00 +0200 | |
changeset 607 | c68b662e0c2a |
parent 577 | 04baf6607a44 |
child 717 | 1c23952dbde1 |
permissions | -rw-r--r-- |
545
627e5c636a4f
Refactored LPC connector for new bootloader and application modes
Lolitech
parents:
diff
changeset
|
1 |
#!/usr/bin/env python |
627e5c636a4f
Refactored LPC connector for new bootloader and application modes
Lolitech
parents:
diff
changeset
|
2 |
# -*- coding: utf-8 -*- |
627e5c636a4f
Refactored LPC connector for new bootloader and application modes
Lolitech
parents:
diff
changeset
|
3 |
|
627e5c636a4f
Refactored LPC connector for new bootloader and application modes
Lolitech
parents:
diff
changeset
|
4 |
#This file is part of Beremiz, a Integrated Development Environment for |
627e5c636a4f
Refactored LPC connector for new bootloader and application modes
Lolitech
parents:
diff
changeset
|
5 |
#programming IEC 61131-3 automates supporting plcopen standard and CanFestival. |
627e5c636a4f
Refactored LPC connector for new bootloader and application modes
Lolitech
parents:
diff
changeset
|
6 |
# |
627e5c636a4f
Refactored LPC connector for new bootloader and application modes
Lolitech
parents:
diff
changeset
|
7 |
#Copyright (C) 2007: Edouard TISSERANT and Laurent BESSARD |
627e5c636a4f
Refactored LPC connector for new bootloader and application modes
Lolitech
parents:
diff
changeset
|
8 |
# |
627e5c636a4f
Refactored LPC connector for new bootloader and application modes
Lolitech
parents:
diff
changeset
|
9 |
#See COPYING file for copyrights details. |
627e5c636a4f
Refactored LPC connector for new bootloader and application modes
Lolitech
parents:
diff
changeset
|
10 |
# |
627e5c636a4f
Refactored LPC connector for new bootloader and application modes
Lolitech
parents:
diff
changeset
|
11 |
#This library is free software; you can redistribute it and/or |
627e5c636a4f
Refactored LPC connector for new bootloader and application modes
Lolitech
parents:
diff
changeset
|
12 |
#modify it under the terms of the GNU General Public |
627e5c636a4f
Refactored LPC connector for new bootloader and application modes
Lolitech
parents:
diff
changeset
|
13 |
#License as published by the Free Software Foundation; either |
627e5c636a4f
Refactored LPC connector for new bootloader and application modes
Lolitech
parents:
diff
changeset
|
14 |
#version 2.1 of the License, or (at your option) any later version. |
627e5c636a4f
Refactored LPC connector for new bootloader and application modes
Lolitech
parents:
diff
changeset
|
15 |
# |
627e5c636a4f
Refactored LPC connector for new bootloader and application modes
Lolitech
parents:
diff
changeset
|
16 |
#This library is distributed in the hope that it will be useful, |
627e5c636a4f
Refactored LPC connector for new bootloader and application modes
Lolitech
parents:
diff
changeset
|
17 |
#but WITHOUT ANY WARRANTY; without even the implied warranty of |
627e5c636a4f
Refactored LPC connector for new bootloader and application modes
Lolitech
parents:
diff
changeset
|
18 |
#MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
627e5c636a4f
Refactored LPC connector for new bootloader and application modes
Lolitech
parents:
diff
changeset
|
19 |
#General Public License for more details. |
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 |
#You should have received a copy of the GNU General Public |
627e5c636a4f
Refactored LPC connector for new bootloader and application modes
Lolitech
parents:
diff
changeset
|
22 |
#License along with this library; if not, write to the Free Software |
627e5c636a4f
Refactored LPC connector for new bootloader and application modes
Lolitech
parents:
diff
changeset
|
23 |
#Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
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 |
from LPCBootProto import * |
627e5c636a4f
Refactored LPC connector for new bootloader and application modes
Lolitech
parents:
diff
changeset
|
26 |
from LPCObject import * |
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 |
class LPCBootObject(LPCObject): |
627e5c636a4f
Refactored LPC connector for new bootloader and application modes
Lolitech
parents:
diff
changeset
|
29 |
def __init__(self, pluginsroot, comportstr): |
627e5c636a4f
Refactored LPC connector for new bootloader and application modes
Lolitech
parents:
diff
changeset
|
30 |
LPCObject.__init__(self, pluginsroot, comportstr) |
627e5c636a4f
Refactored LPC connector for new bootloader and application modes
Lolitech
parents:
diff
changeset
|
31 |
self.successfully_transfered = False |
627e5c636a4f
Refactored LPC connector for new bootloader and application modes
Lolitech
parents:
diff
changeset
|
32 |
|
627e5c636a4f
Refactored LPC connector for new bootloader and application modes
Lolitech
parents:
diff
changeset
|
33 |
def connect(self,comport): |
627e5c636a4f
Refactored LPC connector for new bootloader and application modes
Lolitech
parents:
diff
changeset
|
34 |
self.SerialConnection = LPCBootProto(comport,#number |
627e5c636a4f
Refactored LPC connector for new bootloader and application modes
Lolitech
parents:
diff
changeset
|
35 |
115200, #speed |
627e5c636a4f
Refactored LPC connector for new bootloader and application modes
Lolitech
parents:
diff
changeset
|
36 |
120) #timeout |
567
72b51ec5be64
keep LPC in boot mode to give a chance to ask for a transfer
edouard
parents:
548
diff
changeset
|
37 |
self.HandleSerialTransaction(KEEPBOOTINGTransaction()) |
545
627e5c636a4f
Refactored LPC connector for new bootloader and application modes
Lolitech
parents:
diff
changeset
|
38 |
self.PLCStatus = "Stopped" |
627e5c636a4f
Refactored LPC connector for new bootloader and application modes
Lolitech
parents:
diff
changeset
|
39 |
|
571
427bf9130d12
Debug switch (file in CWD). LPC : better MD5 handling, Run button in boot mode, handling data feedback in boot protocol
edouard
parents:
569
diff
changeset
|
40 |
def StartPLC(self, debug=False): |
427bf9130d12
Debug switch (file in CWD). LPC : better MD5 handling, Run button in boot mode, handling data feedback in boot protocol
edouard
parents:
569
diff
changeset
|
41 |
self.HandleSerialTransaction(STARTTransaction()) |
427bf9130d12
Debug switch (file in CWD). LPC : better MD5 handling, Run button in boot mode, handling data feedback in boot protocol
edouard
parents:
569
diff
changeset
|
42 |
|
545
627e5c636a4f
Refactored LPC connector for new bootloader and application modes
Lolitech
parents:
diff
changeset
|
43 |
def NewPLC(self, md5sum, data, extrafiles): |
569
37af7286dd65
LPC program transfer more verbose, test code added in __main__ of LPCBootProto
Edouqrd Tisserant <edouard.tisserant@gmail.com>
parents:
567
diff
changeset
|
44 |
self.successfully_transfered = self.HandleSerialTransaction(LOADTransaction(data, self.PLCprint)) |
548 | 45 |
return self.successfully_transfered |
545
627e5c636a4f
Refactored LPC connector for new bootloader and application modes
Lolitech
parents:
diff
changeset
|
46 |
|
627e5c636a4f
Refactored LPC connector for new bootloader and application modes
Lolitech
parents:
diff
changeset
|
47 |
def MatchMD5(self, MD5): |
571
427bf9130d12
Debug switch (file in CWD). LPC : better MD5 handling, Run button in boot mode, handling data feedback in boot protocol
edouard
parents:
569
diff
changeset
|
48 |
res = self.HandleSerialTransaction(CHECKMD5Transaction(MD5)) |
577 | 49 |
if res : |
50 |
return "".join(res).find('FAILED') == -1 |
|
51 |
return False |
|
545
627e5c636a4f
Refactored LPC connector for new bootloader and application modes
Lolitech
parents:
diff
changeset
|
52 |
|
627e5c636a4f
Refactored LPC connector for new bootloader and application modes
Lolitech
parents:
diff
changeset
|
53 |
|
627e5c636a4f
Refactored LPC connector for new bootloader and application modes
Lolitech
parents:
diff
changeset
|
54 |
def SetTraceVariablesList(self, idxs): |
627e5c636a4f
Refactored LPC connector for new bootloader and application modes
Lolitech
parents:
diff
changeset
|
55 |
pass |
627e5c636a4f
Refactored LPC connector for new bootloader and application modes
Lolitech
parents:
diff
changeset
|
56 |
|
627e5c636a4f
Refactored LPC connector for new bootloader and application modes
Lolitech
parents:
diff
changeset
|
57 |
def GetTraceVariables(self): |
627e5c636a4f
Refactored LPC connector for new bootloader and application modes
Lolitech
parents:
diff
changeset
|
58 |
return self.PLCStatus, None, None |
627e5c636a4f
Refactored LPC connector for new bootloader and application modes
Lolitech
parents:
diff
changeset
|
59 |