aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Buesch <m@bues.ch>2018-09-15 22:44:52 +0200
committerMichael Buesch <m@bues.ch>2018-09-15 22:44:52 +0200
commit55f1183b3b3eae7226cd0cf59b8871cc54fb7064 (patch)
tree05d318ac6ad2fb55b5ea58d9841bbccd0ca78c60
parent037369725529ec5c3b85ba5138d59b1c0d10de6c (diff)
downloadawlsim-55f1183b3b3eae7226cd0cf59b8871cc54fb7064.tar.xz
awlsim-55f1183b3b3eae7226cd0cf59b8871cc54fb7064.zip
coreserver/memarea: Mask out upper 16 bits of counter and timer value
Signed-off-by: Michael Buesch <m@bues.ch>
-rw-r--r--awlsim/coreserver/memarea.py8
1 files changed, 2 insertions, 6 deletions
diff --git a/awlsim/coreserver/memarea.py b/awlsim/coreserver/memarea.py
index 52846684..de46d00b 100644
--- a/awlsim/coreserver/memarea.py
+++ b/awlsim/coreserver/memarea.py
@@ -211,9 +211,7 @@ class MemoryArea(object):
self.length != len(self.data)):
raise ValueError
dword = WordPacker.fromBytes(self.data, self.length * 8, 0)
- if dword > 0xFFFF:
- raise ValueError
- timer.setTimevalS5T(dword)
+ timer.setTimevalS5T(dword & 0xFFFF)
except (ValueError, AwlSimError) as e:
self.__raiseWriteErr(
AwlSimError("MemoryArea: Timer value error")
@@ -231,9 +229,7 @@ class MemoryArea(object):
self.length != len(self.data)):
raise ValueError
dword = WordPacker.fromBytes(self.data, self.length * 8, 0)
- if dword > 0xFFFF:
- raise ValueError
- counter.setValueBCD(dword)
+ counter.setValueBCD(dword & 0xFFFF)
except (ValueError, AwlSimError) as e:
self.__raiseWriteErr(
AwlSimError("MemoryArea: Counter value error")
bues.ch cgit interface