91 def GetPLCstatus(self): |
91 def GetPLCstatus(self): |
92 self.HandleSerialTransaction(IDLETransaction()) |
92 self.HandleSerialTransaction(IDLETransaction()) |
93 return self.PLCStatus |
93 return self.PLCStatus |
94 |
94 |
95 def NewPLC(self, md5sum, data, extrafiles): |
95 def NewPLC(self, md5sum, data, extrafiles): |
96 pass |
96 if os.path.exists(self.StorageConnection): |
|
97 firmwarepath = os.path.join( |
|
98 self.StorageConnection, |
|
99 "firmware.bin") |
|
100 try: |
|
101 if os.path.exists(firmwarepath ): |
|
102 os.unlink(firmwarepath) |
|
103 f = open(firmwarepath, "wb") |
|
104 f.write(data) |
|
105 f.close() |
|
106 return True |
|
107 except LPCError,e: |
|
108 self.StorageConnection = None |
|
109 self.PLCStatus = "Disconnected" |
|
110 self.pluginsroot.logger.write_error( |
|
111 "LPC transfer error : "+ |
|
112 str(e)+"\n") |
97 |
113 |
98 def MatchMD5(self, MD5): |
114 def MatchMD5(self, MD5): |
99 data = self.HandleSerialTransaction(PLCIDTransaction()) |
115 data = self.HandleSerialTransaction(GET_PLCIDTransaction()) |
100 return data == MD5 |
116 return data[:32] == MD5 |
|
117 |
|
118 def GetPLCInfo(self, MD5): |
|
119 data = self.HandleSerialTransaction(GET_PLCIDTransaction()) |
|
120 return data[32:] |
101 |
121 |
102 class IEC_STRING(ctypes.Structure): |
122 class IEC_STRING(ctypes.Structure): |
103 """ |
123 """ |
104 Must be changed according to changes in iec_types.h |
124 Must be changed according to changes in iec_types.h |
105 """ |
125 """ |