# HG changeset patch # User edouard # Date 1260897890 -3600 # Node ID 02cb9e5fb6f6c0d2c00588b3b9f490ed0ccf4c11 # Parent ca5a2047e0ed32357418b832aae5f5b700fd1921 LPC transfer tested, added PLCInfo along MD5 checksum while invoking makefile diff -r ca5a2047e0ed -r 02cb9e5fb6f6 LPCBeremiz.py --- a/LPCBeremiz.py Tue Dec 15 16:04:28 2009 +0100 +++ b/LPCBeremiz.py Tue Dec 15 18:24:50 2009 +0100 @@ -561,7 +561,7 @@ if self._connector is not None: simulating = self._connector.GetPLCstatus() == "Started" status = "Disconnected" - elif self.OnlineMode == 1: + elif self.OnlineMode == 2: if self._connector is not None: simulating = self._connector.GetPLCstatus() == "Started" status = "Connected" diff -r ca5a2047e0ed -r 02cb9e5fb6f6 connectors/LPC/LPCObject.py --- a/connectors/LPC/LPCObject.py Tue Dec 15 16:04:28 2009 +0100 +++ b/connectors/LPC/LPCObject.py Tue Dec 15 18:24:50 2009 +0100 @@ -93,11 +93,31 @@ return self.PLCStatus def NewPLC(self, md5sum, data, extrafiles): - pass + if os.path.exists(self.StorageConnection): + firmwarepath = os.path.join( + self.StorageConnection, + "firmware.bin") + try: + if os.path.exists(firmwarepath ): + os.unlink(firmwarepath) + f = open(firmwarepath, "wb") + f.write(data) + f.close() + return True + except LPCError,e: + self.StorageConnection = None + self.PLCStatus = "Disconnected" + self.pluginsroot.logger.write_error( + "LPC transfer error : "+ + str(e)+"\n") def MatchMD5(self, MD5): - data = self.HandleSerialTransaction(PLCIDTransaction()) - return data == MD5 + data = self.HandleSerialTransaction(GET_PLCIDTransaction()) + return data[:32] == MD5 + + def GetPLCInfo(self, MD5): + data = self.HandleSerialTransaction(GET_PLCIDTransaction()) + return data[32:] class IEC_STRING(ctypes.Structure): """ diff -r ca5a2047e0ed -r 02cb9e5fb6f6 targets/LPC/plc_LPC_main.c --- a/targets/LPC/plc_LPC_main.c Tue Dec 15 16:04:28 2009 +0100 +++ b/targets/LPC/plc_LPC_main.c Tue Dec 15 18:24:50 2009 +0100 @@ -82,10 +82,18 @@ __DEBUG = 1; } +int CheckRetainBuffer(void) +{ + /* TODO : compare RETAIN buffer start with MD5 */ + return 0; +} + void Retain(unsigned int offset, unsigned int count, void *p) { + /* TODO : write in RETAIN buffer at offset*/ } void Remind(unsigned int offset, unsigned int count, void *p) { + /* TODO : read at offset in RETAIN buffer */ } diff -r ca5a2047e0ed -r 02cb9e5fb6f6 targets/Win32/plc_Win32_main.c --- a/targets/Win32/plc_Win32_main.c Tue Dec 15 16:04:28 2009 +0100 +++ b/targets/Win32/plc_Win32_main.c Tue Dec 15 18:24:50 2009 +0100 @@ -227,6 +227,11 @@ WaitForSingleObject(python_sem, INFINITE); } +int CheckRetainBuffer(void) +{ + return 1; +} + void Retain(unsigned int offset, unsigned int count, void * p) { unsigned int position; diff -r ca5a2047e0ed -r 02cb9e5fb6f6 targets/plc_debug.c --- a/targets/plc_debug.c Tue Dec 15 16:04:28 2009 +0100 +++ b/targets/plc_debug.c Tue Dec 15 18:24:50 2009 +0100 @@ -102,6 +102,8 @@ } } +int CheckRetainBuffer(void); + void __init_debug(void) { /* init local static vars */ @@ -109,7 +111,8 @@ retain_offset = 0; buffer_state = BUFFER_FREE; /* Iterate over all variables to fill debug buffer */ - __for_each_variable_do(RemindIterator); + if(CheckRetainBuffer()) + __for_each_variable_do(RemindIterator); retain_offset = 0; } diff -r ca5a2047e0ed -r 02cb9e5fb6f6 targets/toolchain_makefile.py --- a/targets/toolchain_makefile.py Tue Dec 15 16:04:28 2009 +0100 +++ b/targets/toolchain_makefile.py Tue Dec 15 18:24:50 2009 +0100 @@ -2,6 +2,8 @@ from wxPopen import ProcessLogger import hashlib +import time + includes_re = re.compile('\s*#include\s*["<]([^">]*)[">].*') class toolchain_makefile(): @@ -48,6 +50,11 @@ cflags.append(CFLAGS) self.md5key = hashlib.md5(wholesrcdata).hexdigest() + props = self.PluginsRootInstance.GetProjectProperties() + self.md5key += '|'.join([props[key] for key in ['companyName', + 'projectName', + 'productName']]) + self.md5key += '|'+','.join(map(str,time.localtime())) # Store new PLC filename based on md5 key f = open(self._GetMD5FileName(), "w") f.write(self.md5key)