From 0d9fc9a7dabdf8dd64c61feca3de26d7087f76a9 Mon Sep 17 00:00:00 2001 From: ximenes Date: Mon, 14 May 2018 12:46:29 -0300 Subject: [PATCH] Add check of curve length --- siriuspy/siriuspy/pwrsupply/prucontroller.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/siriuspy/siriuspy/pwrsupply/prucontroller.py b/siriuspy/siriuspy/pwrsupply/prucontroller.py index c8b666936..a9935631f 100644 --- a/siriuspy/siriuspy/pwrsupply/prucontroller.py +++ b/siriuspy/siriuspy/pwrsupply/prucontroller.py @@ -17,6 +17,7 @@ from siriuspy.bsmp import BSMP as _BSMP from siriuspy.bsmp import Response as _Response from siriuspy.bsmp.exceptions import SerialError as _SerialError +from siriuspy.csdevice.pwrsupply import MAX_WFMSIZE as _MAX_WFMSIZE from siriuspy.csdevice.pwrsupply import DEFAULT_WFMDATA as _DEFAULT_WFMDATA from siriuspy.pwrsupply.pru import Const as _PRUConst # from siriuspy.pwrsupply.pru import PRUInterface as _PRUInterface @@ -768,6 +769,8 @@ def pru_curve_write(self, device_id, curve): n, n0 = len(curve), len(self._curves[idx]) if n == 0: raise ValueError('Invalid empty curve!') + elif n > _MAX_WFMSIZE: + raise ValueError('Curve length exceeds maximum value!') elif n > n0: for i in self.device_ids: # padd wfmdata with current last value