ihedvall / mdflib

Implementation of the ASAM MDF data file.
https://ihedvall.github.io/mdflib/
MIT License
57 stars 25 forks source link

Cannot create reference link under cc #52

Closed TheElesty closed 7 months ago

TheElesty commented 7 months ago

I cannot create a reference link under CC to link value to its text representation, that's visible under CN. Is that not implemented or Im just missing something in Docu? When loading other files in MDFViewer, I can see these data.

ihedvall commented 7 months ago

I assume that you are creating MDF files (through MdWriter). There is a IChannelConversion::Reference() function that should do the thing. It's in the online documentation but unfortunately is the online documentation only updated at major releases so the last update was just some days ago.

The mdflib is a support library that I'm using in my other projects and it was originally only for reading MDF files. Lately, I added the write support but I'm not using it in my projects. Therefore are your user input of importance. I just added the CAN bus logging feature.

I assume that you want to add a so-called enumerate (key to string). This is very common in CAN (DBC), ECU (A2L) and in ODS applications. The implementation in MDF is little bit funky as the key is stored in a parameter list (Parameter()) while the text strings are stored in another list. You need a lot of MDF knowledge to create the correct CC block. In the ODS interface, there exist a high level interface to an enumerate (list). It might be a good idea to add such an interface here as well.

Please let me know if you want any enhancement or documentation of the MDF library.

TheElesty commented 7 months ago

Yes, I'm creating it using MdfWriter, I can see in docu IChanelConversion::Reference(), but I cant use it on MdfChannelConversion. And yes, it need to use it, to link value - string as enumeration.

ihedvall commented 7 months ago

OK, you are using the C# interface and yes the Reference interface is missing. I can add it.

TheElesty commented 7 months ago

oh, so the mdflibrary is c# interface ? im using it in cpp project, and example etc lead to using MdfReader/Writer, so I use that

ihedvall commented 7 months ago

C++ shall use the mdflib library while the mdflibrary is a C# assembly (C++/CLI). The C# is little bit of a mess as it only works on windows, Well it sort of works on MacOS and did work on Linux, but not any more. There exist both Visual Studio Solution/Project file (mdflib.vcxproj) and CMake config file (CMakeLists.txt).

There is a google unit test directory. Check the testwrite.cpp file that have several example on how to create MDF files. The ASSERT_XX and EXPECT_XXX are Google Unit test macro, so ignore them in your code..

ihedvall commented 7 months ago

Sorry, the mdflibrary is a .NET assembly not a C# assembly but it should be used in C# applications.

TheElesty commented 7 months ago

maybe to give you a little bit more info (but still a bit crooped cos of NDA), I'm currently testing if this lib is usable in our env, we use c++ with cmake (in vs2022) for windows. currently I'm using the mdflibrary.lib, but from what u wrote i should probably use the mdf.lib, right ? it has both read and write interface ?

ihedvall commented 7 months ago

Yes, you should use the mdflib only. The mdflibrary is just a .NET wrapper around the C++ library. The C++ library also works on most operating systems/platforms.

TheElesty commented 7 months ago

ok, and in that case that cc reference will work right ? so this issue can be closed maybe ?

ihedvall commented 7 months ago

Well, It is some .NET wrapper code still missing so I need to fix that.

The cropped cos of NDA sounds more interesting?

TheElesty commented 7 months ago

So Im testing the mdf-lib, I have similar erros as, when i was building mdeflib from source, I got a lot of _LNK2038 mismatch detected for 'ITERATOR_DEBUG_LEVEL': value '0' doesn't match value '2' errors for debug, and some errors about linking EXPAT (and maybe zlib), I had both expat and zlib installed manually, but probably some wrong versions, cos it missed something from zlib (zlibstatic.lib or similar)

ihedvall commented 7 months ago

These ITERATOR... is just gibberish messages. Take a step back and check the cmake configuration log output. I print out a lot of trace messages about path for EXPAT and ZLIB.

If you look at CMakeList.txt you can either build using VCPKG or by a Component Directory.

If you intend to use VCPKG, it will build the right EXPAT and ZLIB for you. You need to add the -D CMAKE_TOOLCHAIN_FILE = C:/vcpkg/scripts/buildsystems/vcpkg.cmake (or where the VCPKG is installed. GitHub Action uses vcpkg so you can spy on the ".github/workflows/ cmake_windows.yml" file.

The other preferred way is to use component dir. If you check the script/expat.cmake file, it checks for CMake option COMP_DIR. If it set to where EXPAT and ZLIB is built it uses that path for ZLIB_ROOT and EXPAT_ROOT. The ihedvall/components repository have all bash/bat scripts needed to create a COMP_DIR. Use CMake -D COMP_DIR = "where you built/installed the third-party library.

The third way is to set the EXPAT_ROOT and ZLIB_ROOT to where you installed the libraries. Use -D EXPAT_ROOT="install path" and ZLIB_ROOT="install path".

The ITERATOR... message is complaining on mismatch between when linking your application against the MDF C++ lib, so there is something mismatching. Remember to turn the MDF_BUILD_SHARED_LIB=OFF so it doesn't build any .NET stuff.

But check the cmake log messages

ihedvall commented 7 months ago

I think I have fixed the Ref Link problems now. There where actual several errors. I have added a C# unit test.

Have you solved the build problem with mixed debug and release libraries/executable?

TheElesty commented 7 months ago

Hi, I'm trying that c++ lib (prebuild) to run in my test project, but whatever I do I still getting problems from expat (I downloaded it from git), I tried different ways to add it to that project bud unsucsefyly

ihedvall commented 7 months ago

Don't worry to much, This how C++ projects works. You often get stuck in linker problem and the days fly by. All C++ hackers have done this journey several times. The below CMake log snippet, show my setup with the COMP_DIR approach.

-- ZLIB Include Dirs: K:/zlib/master/include
-- ZLIB Libraries: optimizedK:/zlib/master/lib/zlibstatic.libdebugK:/zlib/master/lib/zlibstaticd.lib
-- EXPAT Found: TRUE
-- EXPAT Include Dirs: K:/expat/master/include
-- EXPAT Libraries: optimizedK:/expat/master/lib/libexpat.libdebugK:/expat/master/lib/libexpatd.lib
-- Could NOT find wxWidgets (missing: wxWidgets_LIBRARIES wxWidgets_INCLUDE_DIRS adv core base) 
-- Found wxWidgets: debug;K:/wxwidgets/master/lib/vc_x64_lib/wxmsw33ud_adv.lib;optimized;K:/wxwidgets/maste 

The GitHub:ihedvall/components repository, contains some scripts. The build_EXPAT scripts are of interest. We can setup an on-line meeting (MS Teams or similar). My email address is ihedvall@telia.com.

TheElesty commented 7 months ago

Its probably unnecesery, we will probably use other solution.