Utils¶
C/Python co-simulation utilities
-
cosim.utils.
b64enc_int_list
(lst, width, height)¶ Encode list of numbers as a base64 encoded PNG image.
- Parameters
lst – list of pixel values (len = height x width) in row-major order
width – spatial width
height – spatial height
-
cosim.utils.
b64enc_list_of_int_lists
(lst, width, height)¶ Convert list of lists of numbers to list of base64 encoded PNG images.
- Parameters
lst – list of lists of pixel values (len = height x width) in row-major order
width – spatial width
height – spatial height
-
cosim.utils.
byte_buf
(lst)¶ Convert array to a string buffer (uint8_t* in C).
- Parameters
lst – list of naturals range [0,255]
-
cosim.utils.
dlclose
(obj)¶ Close/unload a PIE binary or a shared library.
- Parameters
obj – object returned by ctypes.CDLL when the resource was loaded
-
cosim.utils.
dlopen
(path)¶ Open/load a PIE binary or a shared library.
-
cosim.utils.
enc_args
(args)¶ Convert args to a suitable format for a foreign C function.
- Parameters
args – list of strings
-
cosim.utils.
int_buf
(lst, bpw=4, signed=True)¶ Convert array to a string buffer (uint8_t* in C).
- Parameters
lst – list of integers
bpw – number of bytes per word/integer
signed – whether to encode the numbers as signed
-
cosim.utils.
read_byte_buf
(buf)¶ Read byte/string buffer (uint8_t* in C) as a list of numbers.
-
cosim.utils.
read_int_buf
(buf, bpw=4, signed=True)¶ Read byte/string buffer as a list of numbers.
- Parameters
buf – byte/string buffer (uint8_t* in C) to read from
bpw – number of bytes per word/integer
signed – whether to decode the numbers as signed