Skip to content

Get OSMPSensorViewIn binary variables in python #90

@oskr1709

Description

@oskr1709

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    questionGeneral questions about the standard, work-flow and code.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions