Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Get OSMPSensorViewIn binary variables in python #90

Open
oskr1709 opened this issue Oct 28, 2022 · 0 comments
Open

Get OSMPSensorViewIn binary variables in python #90

oskr1709 opened this issue Oct 28, 2022 · 0 comments
Labels
question General questions about the standard, work-flow and code.

Comments

@oskr1709
Copy link

Describe the problem

I want to get OSMPSensorViewIn.base.lo , OSMPSensorViewIn.base.hi and OSMPSensorViewIn.base.size from the serialization:

bytes_buffer = sensorview.SerializeToString()
result = struct.pack("<L", len(bytes_buffer))

That is in order to be the input of an dummy sensor fmu.

Describe what you have already tried

I´m working with this example: https://opensimulationinterface.github.io/open-simulation-interface/
and then got the binary variables in this way:

OSMPSensorViewIn_base_lo = int.from_bytes(result, byteorder='little')
OSMPSensorViewIn_base_hi = int.from_bytes(result, byteorder='big')
OSMPSensorViewIn_size = len(bytes_buffer)

it gives me an error that the python int it too long for C long or it crashed in the OSMPDummySensor line:
data.ParseFromArray(buffer,integer_vars[FMI_INTEGER_SENSORVIEW_IN_SIZE_IDX]);

Describe your research

As I mention, I tried with int.from_bytes (https://docs.python.org/3/library/stdtypes.html) and len of bytes buffer
I have no found similar problem or approach in any other page.

Ask your question

So my basic question is, how do I Get OSMPSensorViewIn binary variables in python to set for dummy sensor fmu?

Does anybody know the correct procedure to do this in python please? @pmai could be possible to help me with this procedure please?
Thanks in advance for your help

@oskr1709 oskr1709 added the question General questions about the standard, work-flow and code. label Oct 28, 2022
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
question General questions about the standard, work-flow and code.
Projects
None yet
Development

No branches or pull requests

1 participant