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.

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

报告相同问题?

悬赏问题

  • ¥50 potsgresql15备份问题
  • ¥15 Mac系统vs code使用phpstudy如何配置debug来调试php
  • ¥15 目前主流的音乐软件,像网易云音乐,QQ音乐他们的前端和后台部分是用的什么技术实现的?求解!
  • ¥60 pb数据库修改与连接
  • ¥15 spss统计中二分类变量和有序变量的相关性分析可以用kendall相关分析吗?
  • ¥15 拟通过pc下指令到安卓系统,如果追求响应速度,尽可能无延迟,是不是用安卓模拟器会优于实体的安卓手机?如果是,可以快多少毫秒?
  • ¥20 神经网络Sequential name=sequential, built=False
  • ¥16 Qphython 用xlrd读取excel报错
  • ¥15 单片机学习顺序问题!!
  • ¥15 ikuai客户端多拨vpn,重启总是有个别重拨不上