小编Jot*_*Rod的帖子

CRC-CCITT 到 CRC16 Modbus 实现

我在使用 PHP 生成 modbus CRC16 代码时遇到了很多麻烦。我在互联网上找到了很多不同的代码,但我已经尝试过,但由于某种原因我没有得到正确的结果。我找到了一个用于生成 CRC16-CCITT 的 PHP 代码。我已将查找表更改为 modbus CRC 对应表,但结果仍然不正确。代码如下。我还需要做什么才能将 CRC16-CCITT 代码转换为 CRC16-MODBUS 代码。

<?php 

/*************************************************************************
 * phpCrc16 v1.1 -- CRC16/CCITT implementation 
 *
 * By Matteo Beccati <matteo@beccati.com>
 * 
 * Original code by:
 * Ashley Roll
 * Digital Nemesis Pty Ltd
 * www.digitalnemesis.com
 * ash@digitalnemesis.com 
 *
 * Test Vector: "123456789" (character string, no quotes)
 * Generated CRC: 0x29B1
 * 
 *************************************************************************/



/*
 * Returns CRC16 of a string as int value
 */
function CRC16($str)
{
    static $CRC16_Lookup = …
Run Code Online (Sandbox Code Playgroud)

php modbus crc16

5
推荐指数
0
解决办法
5537
查看次数

postgreSQL上的时间戳到unix时间戳

我试图使用FLOT图表绘制我存储在PostgreSQL中的值.其中一个轴将有时间戳.我将其存储在数据库中的格式为:( 2013-11-01 00:05:57年 - 月 - 日小时:分:秒).

我尝试使用以下代码将此格式转换为UNIX:

$postgresql_timestamp= 2013-11-01 00:05:57;
$unix_timestamp= strtotime($postgresql_timestamp);
Run Code Online (Sandbox Code Playgroud)

得到的结果1383260757与另一个日期相对应:2013-10-01 23:05:5

我认为我遇到的问题与PostgreSQL上的时间戳格式有关.

postgresql flot unix-timestamp

1
推荐指数
1
解决办法
4716
查看次数

标签 统计

crc16 ×1

flot ×1

modbus ×1

php ×1

postgresql ×1

unix-timestamp ×1