# Examples ## CoeSdoUpload ```python def CoeSdoUploadExample(self): wSlaveAddress = 1012 # slave with station address 1012 wObIndex = 0x1018 # object index 0x1018 byObSubIndex = 1 # subindex 1 (Vendor ID, which is from type UDINT with 4 bytes) dwDataLen = 4 # 4 bytes pbyData = [0] * dwDataLen out_dwOutDataLen = CEcWrapperPythonOutParam() dwTimeout = 5000 # timeout 5s dwFlags = EMailBoxFlags.NONE_ # no complete access dwSlaveId = self.m_oEcWrapper.GetSlaveId(wSlaveAddress) eRes = self.m_oEcWrapper.CoeSdoUpload(dwSlaveId, wObIndex, byObSubIndex, pbyData, dwDataLen, out_dwOutDataLen, dwTimeout, dwFlags) if eRes != ECError.EC_NOERROR: self.LogMasterError("CoeSdoUpload failed: ", eRes) return szValue = CEcWrapperPython.ConvValueToString(DN_EC_T_DEFTYPE.ARRAY_OF_BYTE, pbyData) self.LogInfo("CoeSdoUpload success: " + szValue) # 02 00 00 00 ``` ## CoeSdoDownload ```python def CoeSdoDownloadExample(self): wSlaveAddress = 1012 # slave with station address 1012 wObIndex = 0x40A2 # object index 0x40A2 byObSubIndex = 2 # subindex 2 dwValue = 123 # value 123 dwTimeout = 5000 # timeout 5s dwFlags = EMailBoxFlags.NONE_ # no complete access # convert UNSIGNED32 value to 4 bytes out_pbyData = CEcWrapperPythonOutParam() eRes = CEcWrapperPython.ConvValueToBytes(DN_EC_T_DEFTYPE.UNSIGNED32, dwValue, out_pbyData) if eRes != ECError.EC_NOERROR: LogMasterError("ConvValueToBytes failed: ", eRes) return pbyData = out_pbyData.value dwSlaveId = self.m_oEcWrapper.GetSlaveId(wSlaveAddress) eRes = self.m_oEcWrapper.CoeSdoDownload(dwSlaveId, wObIndex, byObSubIndex, pbyData, len(pbyData), dwTimeout, dwFlags) if eRes != ECError.EC_NOERROR: self.LogMasterError("CoeSdoDownload failed: ", eRes) return self.LogInfo("CoeSdoDownload success") ``` ## ReadSlaveEEPRom ```python def ReadSlaveEEPRomExample(self): bFixedAddressing = True # enable fixed addressing wSlaveAddress = 1006 # slave with station address 1006 wEEPRomStartOffset = 0x0 # offset 0 dwReadLen = 10 # 10 bytes pwReadData = [0] * dwReadLen out_dwNumOutData = CEcWrapperPythonOutParam() dwTimeout = 2000 # timeout 2s eRes = self.m_oEcWrapper.ReadSlaveEEPRom(bFixedAddressing, wSlaveAddress, wEEPRomStartOffset, pwReadData, dwReadLen, out_dwNumOutData, dwTimeout) if eRes != ECError.EC_NOERROR: self.LogMasterError("ReadSlaveEEPRom failed: ", eRes) return szValue = CEcWrapperPython.ConvValueToString(DN_EC_T_DEFTYPE.ARRAY_OF_BYTE, pwReadData) self.LogInfo("ReadSlaveEEPRom success: " + szValue) ``` ## FoeFileDownload ```python def FoeFileDownloadExample(self): wSlaveAddress = 1012 # slave with station address 1012 szFileName = "foe.txt" # filename of file in slave pbyData = [ 1, 2, 3, 4 ] # 4 bytes dwPassword = 0 # password is 0 dwTimeout = 2000 # timeout 2s dwSlaveId = self.m_oEcWrapper.GetSlaveId(wSlaveAddress) eRes = self.m_oEcWrapper.FoeFileDownload(dwSlaveId, szFileName, len(szFileName), pbyData, len(pbyData), dwPassword, dwTimeout) if eRes != ECError.EC_NOERROR: self.LogMasterError("FoeFileDownload failed: ", eRes) return self.LogInfo("FoeFileDownload success") ```