@@ -282,6 +282,27 @@ class SddfStatus(IntEnum):
282
282
libsdfgen .sdfgen_sddf_lwip_serialise_config .restype = c_bool
283
283
libsdfgen .sdfgen_sddf_lwip_serialise_config .argtypes = [c_void_p , c_char_p ]
284
284
285
+ def ffi_uint8_ptr (n : Optional [int ]):
286
+ """
287
+ Convert an int value to a uint8_t pointer for FFI.
288
+ If 'n' is None then we return None (which acts as a null pointer)
289
+ """
290
+ if n is None :
291
+ return None
292
+
293
+ return pointer (c_uint8 (n ))
294
+
295
+
296
+ def ffi_bool_ptr (val : Optional [bool ]):
297
+ """
298
+ Convert a bool value to a bool pointer for FFI.
299
+ If 'val' is None then we return None (which acts as a null pointer)
300
+ """
301
+ if n is None :
302
+ return None
303
+
304
+ return pointer (c_bool (val ))
305
+
285
306
286
307
class DeviceTree :
287
308
"""
@@ -551,37 +572,23 @@ def __init__(
551
572
notify_a : Optional [bool ] = None ,
552
573
notify_b : Optional [bool ] = None ,
553
574
) -> None :
554
- a_id_ptr = None
555
- if a_id is not None :
556
- a_id_u8 = c_uint8 (a_id )
557
- a_id_ptr = pointer (a_id_u8 )
558
- b_id_ptr = None
559
- if b_id is not None :
560
- b_id_u8 = c_uint8 (b_id )
561
- b_id_ptr = pointer (b_id_u8 )
562
-
563
- pp_ptr = None
564
575
if pp_a is not None :
565
- pp = c_uint8 (0 )
566
- pp_ptr = pointer (pp )
576
+ c_pp = 0
567
577
elif pp_b is not None :
568
- pp = c_uint8 (1 )
569
- pp_ptr = pointer (pp )
570
-
571
-
572
- notify_a_ptr = None
573
- notify_b_ptr = None
574
- if notify_a :
575
- notify_a_c = c_bool (notify_a )
576
- notify_a_ptr = pointer (notify_a_c )
577
- if notify_b :
578
- notify_b_c = c_bool (notify_b )
579
- notify_b_ptr = pointer (notify_b_c )
578
+ c_pp = 1
580
579
581
580
if pp_a is not None and pp_b is not None :
582
581
raise Exception ("attempting to create channel with PP on both ends" )
583
582
584
- self ._obj = libsdfgen .sdfgen_channel_create (a ._obj , b ._obj , a_id_ptr , b_id_ptr , notify_a_ptr , notify_b_ptr , pp_ptr )
583
+ self ._obj = libsdfgen .sdfgen_channel_create (
584
+ a ._obj ,
585
+ b ._obj ,
586
+ ffi_uint8_ptr (a_id ),
587
+ ffi_uint8_ptr (b_id ),
588
+ ffi_bool_ptr (notify_a ),
589
+ ffi_bool_ptr (notify_b ),
590
+ ffi_uint8_ptr (pp_val ),
591
+ )
585
592
586
593
@property
587
594
def pd_a_id (self ) -> int :
0 commit comments