Archived OpenModelica forums. Posting is disabled.

Alternative forums include GitHub discussions or StackOverflow (make sure to read the Stack Overflow rules; you need to have well-formed questions)


Forgot password? | Forgot username? | Register

Illegal Instruction - Fixed!

Illegal Instruction - Fixed!

I've coded a lookup table in C and trying to call the function from within OM but it keeps crashing and I can't figure out why.

I pass the function a lookup string and a temperature. The function then looks up the coefficients and calculates the polynomial, which is returned. The function works fine when called from C but not OM. OMEdit compiles the code but on running produces errors:

Process crashed
Process crashed
Simulation process failed. Exited with code 4.

Any help will be appreciated.

SteamTables.zip

Edited by: alidaf - Nov-21-19 08:17:50
Attachments:

Re: Illegal Instruction - Fixed!

Ok, I think I sorted it out. The function is expecting a char array (C doesn't have strings) but OM was passing a string. I changed the requirement from string to an enumerated type in the C function and passed an integer from OM. At least the there are no errors now but the returned value isn't what I was expecting. At least its a step in the right direction.

Re: Illegal Instruction - Fixed!

I think more examples are needed so if anyone is interested I have attached the files that now actually work.
SteamTables.zip

I compiled the C code in NetBeans as a dynamic library and copied the .so file to /usr/lib/x86_64-linux-gnu, which is one of the standard library locations in linux. The .c and .h files are in the same folder as the .mo file. Using the method where the .h file isn't needed doesn't work for me. I also couldn't get the Python version to work but this does exactly what I want it to.

Attachments:
There are 0 guests and 0 other users also viewing this topic
You are here: