@@ -204,7 +204,7 @@ def test_logix_multiple():
204204 description , encoded , response )
205205
206206
207- # Test that we correctly compute beg,end,endactual for various Read Tag Fragmented scenarios,
207+ # Test that we correctly compute beg,end,endact for various Read Tag Fragmented scenarios,
208208 # with 2-byte and 4-byte types. For the purposes of this test, we only look at path...elements.
209209 data = cpppo .dotdict ()
210210 data .service = Obj .RD_FRG_RPY
@@ -215,28 +215,29 @@ def test_logix_multiple():
215215 data .read_frag = {}
216216 data .read_frag .elements = 1000
217217 data .read_frag .offset = 0
218+ data .read_frag .max_size = 500
218219
219220 # Reply maximum size limited
220- beg ,end ,endactual = Obj .reply_elements ( Obj_a1 , data , 'read_frag' )
221- assert beg == 0 and end == 125 and endactual == 1000 # DINT == 4 bytes
222- beg ,end ,endactual = Obj .reply_elements ( Obj_a3 , data , 'read_frag' )
223- assert beg == 0 and end == 250 and endactual == 1000 # INT == 2 bytes
221+ beg ,end ,endact , offrem , maxsiz = Obj .reply_elements ( Obj_a1 , data , 'read_frag' )
222+ assert beg == 0 and end == 125 and endact == 1000 and offrem == 0 and maxsiz == 500 # DINT == 4 bytes
223+ beg ,end ,endact , offrem , maxsiz = Obj .reply_elements ( Obj_a3 , data , 'read_frag' )
224+ assert beg == 0 and end == 250 and endact == 1000 and offrem == 0 and maxsiz == 500 # INT == 2 bytes
224225
225226 data .read_frag .offset = 125 * 4 # OK, second request; begin after byte offset of first
226- beg ,end ,endactual = Obj .reply_elements ( Obj_a1 , data , 'read_frag' )
227- assert beg == 125 and end == 250 and endactual == 1000 # DINT == 4 bytes
227+ beg ,end ,endact , offrem , maxsiz = Obj .reply_elements ( Obj_a1 , data , 'read_frag' )
228+ assert beg == 125 and end == 250 and endact == 1000 and offrem == 0 and maxsiz == 500 # DINT == 4 bytes
228229
229230 # Request elements limited; 0 offset
230231 data .read_frag .elements = 30
231232 data .read_frag .offset = 0
232- beg ,end ,endactual = Obj .reply_elements ( Obj_a3 , data , 'read_frag' )
233- assert beg == 0 and end == 30 and endactual == 30 # INT == 2 bytes
233+ beg ,end ,endact , offrem , maxsiz = Obj .reply_elements ( Obj_a3 , data , 'read_frag' )
234+ assert beg == 0 and end == 30 and endact == 30 and offrem == 0 and maxsiz == 500 # INT == 2 bytes
234235
235236 # Request elements limited; +'ve offset
236237 data .read_frag .elements = 70
237238 data .read_frag .offset = 80
238- beg ,end ,endactual = Obj .reply_elements ( Obj_a3 , data , 'read_frag' )
239- assert beg == 40 and end == 70 and endactual == 70 # INT == 2 bytes
239+ beg ,end ,endact , offrem , maxsiz = Obj .reply_elements ( Obj_a3 , data , 'read_frag' )
240+ assert beg == 40 and end == 70 and endact == 70 and offrem == 0 and maxsiz == 500 # INT == 2 bytes
240241
241242 # Request limited by size of data provided (Write Tag [Fragmented])
242243 data = cpppo .dotdict ()
@@ -249,16 +250,16 @@ def test_logix_multiple():
249250 data .write_frag .data = [0 ] * 100 # 100 elements provided in this request
250251 data .write_frag .elements = 200 # Total request is to write 200 elements
251252 data .write_frag .offset = 16 # request starts 16 bytes in (8 INTs)
252- beg ,end ,endactual = Obj .reply_elements ( Obj_a3 , data , 'write_frag' )
253- assert beg == 8 and end == 108 and endactual == 200 # INT == 2 bytes
253+ beg ,end ,endact , offrem , maxsiz = Obj .reply_elements ( Obj_a3 , data , 'write_frag' )
254+ assert beg == 8 and end == 108 and endact == 200 # INT == 2 bytes
254255
255256 # ... same, but lets say request started somewhere in the middle of the array
256257 data .path = { 'segment' : [ cpppo .dotdict ( d )
257258 for d in [
258259 {'element' : 222 },
259260 ]] }
260- beg ,end ,endactual = Obj .reply_elements ( Obj_a3 , data , 'write_frag' )
261- assert beg == 8 + 222 and end == 108 + 222 and endactual == 200 + 222 # INT == 2 bytes
261+ beg ,end ,endact , offrem , maxsiz = Obj .reply_elements ( Obj_a3 , data , 'write_frag' )
262+ assert beg == 8 + 222 and end == 108 + 222 and endact == 200 + 222 # INT == 2 bytes
262263
263264 # Ensure correct computation of (beg,end] that are byte-offset and data/size limited
264265 data = cpppo .dotdict ()
@@ -268,15 +269,15 @@ def test_logix_multiple():
268269 data .write_frag = {}
269270 data .write_frag .data = [3 ,4 ,5 ,6 ]
270271 data .write_frag .offset = 6
271- beg ,end ,endactual = Obj .reply_elements ( Obj_a3 , data , 'write_frag' )
272- assert beg == 3 and end == 7 and endactual == 1000 # INT == 2 bytes
272+ beg ,end ,endact , offrem , maxsiz = Obj .reply_elements ( Obj_a3 , data , 'write_frag' )
273+ assert beg == 3 and end == 7 and endact == 1000 # INT == 2 bytes
273274
274275 # Trigger the error cases only accessible via write
275276
276277 # Too many elements provided for attribute capacity
277278 data .write_frag .offset = ( 1000 - 3 ) * 2
278279 try :
279- beg ,end ,endactual = Obj .reply_elements ( Obj_a3 , data , 'write_frag' )
280+ beg ,end ,endact , offrem , maxsiz = Obj .reply_elements ( Obj_a3 , data , 'write_frag' )
280281 assert False , "Should have raised Exception due to capacity"
281282 except Exception as exc :
282283 assert "capacity exceeded" in str ( exc )
@@ -287,38 +288,36 @@ def test_logix_multiple():
287288
288289 data .read_frag = {}
289290 data .read_frag .offset = 6
290- beg ,end ,endactual = Obj .reply_elements ( Obj_a3 , data , 'read_frag' )
291- assert beg == 3 and end == 253 and endactual == 1000 # INT == 2 bytes
291+ data .read_frag .max_size = 500
292+ beg ,end ,endact ,offrem ,maxsiz = Obj .reply_elements ( Obj_a3 , data , 'read_frag' )
293+ assert beg == 3 and end == 253 and endact == 1000 # INT == 2 bytes
292294
293295 # And we should be able to read with an offset right up to the last element
294296 data .read_frag .offset = 1998
295- beg ,end ,endactual = Obj .reply_elements ( Obj_a3 , data , 'read_frag' )
296- assert beg == 999 and end == 1000 and endactual == 1000 # INT == 2 bytes
297+ beg ,end ,endact , offrem , maxsiz = Obj .reply_elements ( Obj_a3 , data , 'read_frag' )
298+ assert beg == 999 and end == 1000 and endact == 1000 # INT == 2 bytes
297299
298300
299301 # Trigger all the remaining error cases
300302
301303 # Unknown service
302304 data .service = Obj .RD_FRG_REQ
303305 try :
304- beg ,end ,endactual = Obj .reply_elements ( Obj_a3 , data , 'read_frag' )
306+ beg ,end ,endact , offrem , maxsiz = Obj .reply_elements ( Obj_a3 , data , 'read_frag' )
305307 assert False , "Should have raised Exception due to service"
306308 except Exception as exc :
307309 assert "unknown service" in str ( exc )
308310
309311 # Offset indivisible by element size
310312 data .service = Obj .RD_FRG_RPY
311313 data .read_frag .offset = 7
312- try :
313- beg ,end ,endactual = Obj .reply_elements ( Obj_a3 , data , 'read_frag' )
314- assert False , "Should have raised Exception due to odd byte offset"
315- except Exception as exc :
316- assert "element boundary" in str ( exc )
314+ beg ,end ,endact ,offrem ,maxsiz = Obj .reply_elements ( Obj_a3 , data , 'read_frag' )
315+ assert beg == 3 and end == 254 and endact == 1000 and offrem == 1 and maxsiz == 500
317316
318317 # Initial element outside bounds
319318 data .read_frag .offset = 2000
320319 try :
321- beg ,end ,endactual = Obj .reply_elements ( Obj_a3 , data , 'read_frag' )
320+ beg ,end ,endact , offrem , maxsiz = Obj .reply_elements ( Obj_a3 , data , 'read_frag' )
322321 assert False , "Should have raised Exception due to initial element"
323322 except Exception as exc :
324323 assert "initial element invalid" in str ( exc )
@@ -327,26 +326,25 @@ def test_logix_multiple():
327326 data .read_frag .offset = 0
328327 data .read_frag .elements = 1001
329328 try :
330- beg ,end ,endactual = Obj .reply_elements ( Obj_a3 , data , 'read_frag' )
329+ beg ,end ,endact , offrem , maxsiz = Obj .reply_elements ( Obj_a3 , data , 'read_frag' )
331330 assert False , "Should have raised Exception due to ending element"
332331 except Exception as exc :
333- assert "ending element invalid" in str ( exc )
332+ assert "elements requested invalid" in str ( exc )
334333
335334 # Beginning element after ending (should be no way to trigger). This request doesn't specify an
336335 # element in the path, hence defaults to element 0, and asks for a number of elements == 2.
337336 # Thus, there is no 6-byte offset possible (a 2-byte offset is, though).
338337 data .read_frag .offset = 6
339338 data .read_frag .elements = 2
340339 try :
341- beg ,end ,endactual = Obj .reply_elements ( Obj_a3 , data , 'read_frag' )
340+ beg ,end ,endact , offrem , maxsiz = Obj .reply_elements ( Obj_a3 , data , 'read_frag' )
342341 assert False , "Should have raised Exception due to ending element order"
343342 except Exception as exc :
344343 assert "ending element before beginning" in str ( exc )
345344 data .read_frag .offset = 2
346345 data .read_frag .elements = 2
347- beg ,end ,endactual = Obj .reply_elements ( Obj_a3 , data , 'read_frag' )
348- assert beg == 1 and end == 2 and endactual == 2 # INT == 2 bytes
349-
346+ beg ,end ,endact ,offrem ,maxsiz = Obj .reply_elements ( Obj_a3 , data , 'read_frag' )
347+ assert beg == 1 and end == 2 and endact == 2 # INT == 2 bytes
350348
351349 # Test an example valid multiple request
352350 data = cpppo .dotdict ()
0 commit comments