Write EthernetHeaderEx to blf files.

Issue #40 open
Deepen M created an issue
        I want to write Ethernet data to Blf file in Linux. Below logic i used to write in Window.
        But when i am trying to write it in Linux, i cant find Message ID. Can you please help me with a sample code ?


        BLF_VBLEthernetFrameEx_t ethernetEx;
        EthernetHeaderEx header;
        header.messageID = messageID;
        header.size = uint32_t(size);
        header.reverseBytes();

        ethernetEx.mHeader.mObjectTimeStamp = time_ns;
        ethernetEx.mChannel = channel;
        //ethernetEx.mFrameLength = 74 + uint16_t(size);  //20 bytes more data size
        ethernetEx.mFrameLength = 54 + uint16_t(size);    //Mu
//        std::cout << messageID << ethernetEx.mFrameLength << endl;        //SIL
//        system("pause");   //SIL
        ethernetEx.mFrameData = new BYTE[ethernetEx.mFrameLength];
        memcpy(ethernetEx.mFrameData, &header.Mac_ADAS, 54);
        memcpy(ethernetEx.mFrameData + 54, data, size);
        ethernetEx.mHeader.mBase.mObjectSize = offsetof(VBLEthernetFrameEx, mFrameData) + ethernetEx.mFrameLength;

        bool ok = BLWriteObject(hFile, &ethernetEx.mHeader.mBase);
        delete[] ethernetEx.mFrameData;
        return ok;

Comments (3)

  1. Deepen M reporter

    I am using the following piece of code but i am getting data size and data as null.

    if (!hFile.is_open()) {
           std::cout << "Unable to open file" << std::endl;
           return 0;
       }
    

    auto* ethernet = new EthernetFrameEx;
    ethernet->channel = channel;
    ethernet->objectTimeStamp = time_ns;
    ethernet->clientIndex = messageID; // Could not find any message ID related variable.
    ethernet->frameLength = uint16_t(size);
    ethernet->flags = 1; // I have tried with 1 also, but same result
    ethernet->frameData.reserve(size);
    memcpy(&(ethernet->frameData[0]), var, size);

    hFile.write(ethernet);

  2. Tobias Lorenz repo owner

    Sorry for the delayed answer. I think the way you use memcpy is not the recommended way for copying data to a vector. Can you try the following instead:

    memcpy(ethernet->frameData.data(), var, size);

    Maybe this solves the issue already. 😉

  3. Log in to comment