dongmie3526 2016-01-08 17:14
浏览 26
已采纳

从FM1100记录中提取时间戳[关闭]

I am trying to decode some data from a FM1100 teltonika record such as this :

080400000113fc208dff000f14f650209cca80006f00d60400040004030101150316030001460000015d0000000113fc17610b000f14ffe0209cc580006e00c00500010004030101150316010001460000015e0000000113fc284945000f150f00209cd200009501080400000004030101150016030001460000015d0000000113fc267c5b000f150a50209cccc0009300680400000004030101150016030001460000015b0004

In the above example I actually just want to extract the timestamp of the log. This timestamp is the string "00000113fc208dff".

How can I transform this string to a timestamp?

  • 写回答

1条回答 默认 最新

  • dongyun4010 2016-01-08 23:14
    关注

    According to the protocol documentation I've found here this record actually contains multiple log entries (pg. 5) each of which has its own timestamp.

    Assuming you just need the timestamp of the first log entry you can extract it like this (fiddle here):

    $input = '080400000113fc208dff000f14f650209cca80006f00d60400040004030101150316030001460000015d0000000113fc17610b000f14ffe0209cc580006e00c00500010004030101150316010001460000015e0000000113fc284945000f150f00209cd200009501080400000004030101150016030001460000015d0000000113fc267c5b000f150a50209cccc0009300680400000004030101150016030001460000015b0004';
    
    $data = unpack('A2/A2/A16timestamp', $input);
    $timestamp = hexdec($data['timestamp']);
    
    echo $timestamp . PHP_EOL;
    

    If you need to read the timestamps of each log record you will need parse the IO element data for each one because it is variable in length.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 stm32开发clion时遇到的编译问题
  • ¥15 lna设计 源简并电感型共源放大器
  • ¥15 如何用Labview在myRIO上做LCD显示?(语言-开发语言)
  • ¥15 Vue3地图和异步函数使用
  • ¥15 C++ yoloV5改写遇到的问题
  • ¥20 win11修改中文用户名路径
  • ¥15 win2012磁盘空间不足,c盘正常,d盘无法写入
  • ¥15 用土力学知识进行土坡稳定性分析与挡土墙设计
  • ¥70 PlayWright在Java上连接CDP关联本地Chrome启动失败,貌似是Windows端口转发问题
  • ¥15 帮我写一个c++工程