You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm using the function getBinary to obtain array data which is represented as uint8_t* in my C-Code. The data of length 8 bytes may contain several zeros at varying indices within this array, e.g. 01 02 03 04 00 06 00 08.
Reading out this data using getBinary yields an instance of class 'bytes' with the data content of 01 02 03 04. Playing around with the position of the zero entries, it seems that the data is truncated before the first occurrence of a zero entry - as I would expect in a zero-terminated string setting.
Indeed, according to the sources of fmi3.py, FMPy uses c_char_p for C-Function to Python binary data passing which is correct for passing a string, but not for a data buffer which may contain several zeros inbetween.
Is this an implementation issue of FMPy or did I miss relevant parts of the FMI 3 specification ?
Thank you in advance.
Best regards
Philippe
The text was updated successfully, but these errors were encountered:
thank you for your quick reply. In the binaryTest zip attached, you can find the C-sources that contain the corresponding binary setter and getter methods. Furthermore, you can find an FMU revealing the above mentioned problem. The FMU consists of a binary input and a binary output, where the binary data for the binary output is created on-the-fly in the FMU. And finally, I attached a pyhon script, that sets binary data and gets binary data afterwards.
Setting binary data seems to work, where getting binary data using FMPy seems to be broken. In the example, 8 bytes should be read, but only 5 bytes are returned.
The FMU is compiled on a Windows OS with FMPy version: 0.3.21 installed.
Hi,
I'm using the function getBinary to obtain array data which is represented as uint8_t* in my C-Code. The data of length 8 bytes may contain several zeros at varying indices within this array, e.g. 01 02 03 04 00 06 00 08.
Reading out this data using getBinary yields an instance of class 'bytes' with the data content of 01 02 03 04. Playing around with the position of the zero entries, it seems that the data is truncated before the first occurrence of a zero entry - as I would expect in a zero-terminated string setting.
Indeed, according to the sources of fmi3.py, FMPy uses c_char_p for C-Function to Python binary data passing which is correct for passing a string, but not for a data buffer which may contain several zeros inbetween.
Is this an implementation issue of FMPy or did I miss relevant parts of the FMI 3 specification ?
Thank you in advance.
Best regards
Philippe
The text was updated successfully, but these errors were encountered: