From a2f0d0af3adb9eb16e1e228010155001fa88c8db Mon Sep 17 00:00:00 2001 From: Bart de Waal Date: Thu, 2 Apr 2015 22:14:55 +0200 Subject: [PATCH] Execute methods of Requests accept context There were errors whenever a request that got handles in other_message.py got it's execute method called, as it was being called with a context parameter. The functions now accept this parameter, although they don't do anything with it. The tests have also been updated. --- pymodbus/other_message.py | 8 ++++---- test/test_other_messages.py | 10 +++++----- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/pymodbus/other_message.py b/pymodbus/other_message.py index 88e1be2ec..c122bb019 100644 --- a/pymodbus/other_message.py +++ b/pymodbus/other_message.py @@ -42,7 +42,7 @@ def decode(self, data): ''' pass - def execute(self): + def execute(self, context): ''' Run a read exeception status request against the store :returns: The populated response @@ -143,7 +143,7 @@ def decode(self, data): ''' pass - def execute(self): + def execute(self, context): ''' Run a read exeception status request against the store :returns: The populated response @@ -248,7 +248,7 @@ def decode(self, data): ''' pass - def execute(self): + def execute(self, context): ''' Run a read exeception status request against the store :returns: The populated response @@ -358,7 +358,7 @@ def decode(self, data): ''' pass - def execute(self): + def execute(self, context): ''' Run a read exeception status request against the store :returns: The populated response diff --git a/test/test_other_messages.py b/test/test_other_messages.py index 67e07a2ed..efa80c0dc 100644 --- a/test/test_other_messages.py +++ b/test/test_other_messages.py @@ -37,7 +37,7 @@ def testReadExceptionStatus(self): request = ReadExceptionStatusRequest() request.decode('\x12') self.assertEqual(request.encode(), '') - self.assertEqual(request.execute().function_code, 0x07) + self.assertEqual(request.execute(None).function_code, 0x07) response = ReadExceptionStatusResponse(0x12) self.assertEqual(response.encode(), '\x12') @@ -48,7 +48,7 @@ def testGetCommEventCounter(self): request = GetCommEventCounterRequest() request.decode('\x12') self.assertEqual(request.encode(), '') - self.assertEqual(request.execute().function_code, 0x0b) + self.assertEqual(request.execute(None).function_code, 0x0b) response = GetCommEventCounterResponse(0x12) self.assertEqual(response.encode(), '\x00\x00\x00\x12') @@ -63,7 +63,7 @@ def testGetCommEventLog(self): request = GetCommEventLogRequest() request.decode('\x12') self.assertEqual(request.encode(), '') - self.assertEqual(request.execute().function_code, 0x0c) + self.assertEqual(request.execute(None).function_code, 0x0c) response = GetCommEventLogResponse() self.assertEqual(response.encode(), '\x06\x00\x00\x00\x00\x00\x00') @@ -89,9 +89,9 @@ def testReportSlaveId(self): request = ReportSlaveIdRequest() request.decode('\x12') self.assertEqual(request.encode(), '') - self.assertEqual(request.execute().function_code, 0x11) + self.assertEqual(request.execute(None).function_code, 0x11) - response = ReportSlaveIdResponse(request.execute().identifier, True) + response = ReportSlaveIdResponse(request.execute(None).identifier, True) self.assertEqual(response.encode(), '\x0apymodbus\xff') response.decode('\x03\x12\x00') self.assertEqual(response.status, False)