Menu

BlockInfo not correct Code and Interface timestamps

2015-03-27
2025-06-13
  • Benjamin Prömmer

    The timestamps in blockinfo are only dates, but it should be date and time.

     
  • Benjamin Prömmer

    Hi once again,

    could you please fix this bug? Here is a Little description:

    The problem is in s7_micro_client.cpp in the method FillTime which you used in GetPgBlockInfo and opAgBlockInfo.
    You use in your FillTime only the day value, but if you use both, the day and the MS value it will be correct. I tried this in c# and here is my codesnippet about this test:

            var dt = new DateTime(1984, 1, 1, 0, 0, 0, 0);
            dt = dt.AddMilliseconds(ms); // this is the ResData->CodeTime_ms value
            dt = dt.AddDays(dy);         // this is the ResData->CodeTime_dy value
    

    Now in dt is the correct date and time.

    Best regards
    Benji

     
    • Marco

      Marco - 2020-02-27

      Benji,
      Did you manage to fix this at all? I guess this was almost 5 years ago so you have probably moved on since then! :)

      Thanks,
      Marco

       
  • Davide Nardella

    Davide Nardella - 2015-04-25

    Hi,
    this is not a bug but a choice.

    The TS7BlockInfo struct contains 11 chars as CodeDate and IntfDate which are encoded as text.
    Adding the time info would break the compatibility with all previous releases and this would be justified only if many people so requires.

    Sorry, but you're the only one who suffers from this problem.

    Thanks for reporting anyway...

    Regards
    Dave

     
  • Marco

    Marco - 2020-02-27

    Hi Davide,

    I am also curious about this - is there no possible way without changing the core files?

    All the best,
    Marco

     
  • Anandhakumar Palanisamy

    Dear @Davide Nardella,

    I have fixed this issue in the C++ part of the source code.

    Changes related to the fix : https://github.com/Securenok/snap7/pull/2

    • In the c++ version of the library -> added two new fields, char CodeDateTime[25]; and char IntfDateTime[25];, to the structs TS7BlockInfo and PS7BlockInfo.
    • Added a helper function TSnap7MicroClient::FillDateTime(word SiemensDay, u_int SiemensMs, char *PTime) to fill the full timestamp information of the memory blocks to the newly added fields CodeDateTime and IntfDateTime.

    The fixed version is made available for public use : https://github.com/Securenok/snap7

    Kindly let me know if you find any issues with the above mentioned changes.

    Thanks & regards,
    Anand

     

    Last edit: Anandhakumar Palanisamy 2025-06-13

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.