LPCconnector/LPCBootObject.py
changeset 0 51f5a3138405
equal deleted inserted replaced
-1:000000000000 0:51f5a3138405
       
     1 #!/usr/bin/env python
       
     2 # -*- coding: utf-8 -*-
       
     3 
       
     4 #This file is part of Beremiz, a Integrated Development Environment for
       
     5 #programming IEC 61131-3 automates supporting plcopen standard and CanFestival. 
       
     6 #
       
     7 #Copyright (C) 2007: Edouard TISSERANT and Laurent BESSARD
       
     8 #
       
     9 #See COPYING file for copyrights details.
       
    10 #
       
    11 #This library is free software; you can redistribute it and/or
       
    12 #modify it under the terms of the GNU General Public
       
    13 #License as published by the Free Software Foundation; either
       
    14 #version 2.1 of the License, or (at your option) any later version.
       
    15 #
       
    16 #This library is distributed in the hope that it will be useful,
       
    17 #but WITHOUT ANY WARRANTY; without even the implied warranty of
       
    18 #MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
       
    19 #General Public License for more details.
       
    20 #
       
    21 #You should have received a copy of the GNU General Public
       
    22 #License along with this library; if not, write to the Free Software
       
    23 #Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
       
    24 
       
    25 from LPCBootProto import *
       
    26 from LPCObject import *
       
    27 
       
    28 class LPCBootObject(LPCObject):
       
    29     def __init__(self, confnodesroot, comportstr):
       
    30         LPCObject.__init__(self, confnodesroot, comportstr)
       
    31         self.successfully_transfered = False
       
    32     
       
    33     def connect(self,comport):
       
    34         self.SerialConnection = LPCBootProto(comport,#number
       
    35                                          115200, #speed
       
    36                                          120)      #timeout
       
    37         self.HandleSerialTransaction(KEEPBOOTINGTransaction())
       
    38         self.PLCStatus = "Stopped"
       
    39     
       
    40     def StartPLC(self, debug=False):
       
    41         self.HandleSerialTransaction(STARTTransaction())
       
    42 
       
    43     def NewPLC(self, md5sum, data, extrafiles):
       
    44         self.successfully_transfered = self.HandleSerialTransaction(LOADTransaction(data, self.PLCprint))
       
    45         return self.successfully_transfered
       
    46 
       
    47     def MatchMD5(self, MD5):
       
    48         res = self.HandleSerialTransaction(CHECKMD5Transaction(MD5))
       
    49         if res :
       
    50             return "".join(res).find('FAILED') == -1
       
    51         return False
       
    52 
       
    53 
       
    54     def SetTraceVariablesList(self, idxs):
       
    55         pass
       
    56     
       
    57     def GetTraceVariables(self):
       
    58         return self.PLCStatus, None, None
       
    59