crc16

MODBUS RTU CRC16 calculation

邮差的信 提交于 2019-12-24 07:43:53
问题 I'm coding a MODBUS CRC16 calculator in C. What I have before is a python that do this, I wanted to convert it to C. I found some codes online but it's not giving me the correct answer. For my python code, I have this as my CRC16.py #!/usr/bin/env python def calc(data): crc_table=[0x0000,0xC0C1,0xC181,0x0140,0xC301,0x03C0,0x0280,0xC241,0xC601,0x06C0,0x0780,0xC741,0x0500,0xC5C1,0xC481,0x0440,0xCC01,0x0CC0,0x0D80,0xCD41,0x0F00,0xCFC1,0xCE81,0x0E40,0x0A00,0xCAC1,0xCB81,0x0B40,0xC901,0x09C0

Javascript CRC16 sample code or implementation

回眸只為那壹抹淺笑 提交于 2019-12-24 06:18:24
问题 can anybody share a link or sample code to implement checksum for string in javascript? Thanks a lot in advance 回答1: What do you want? You need to be more specific. There is a huge plethora of CRC16 algorithms, each one with its own polynomial and for a specific use. Some CRC16 algorithms are really good to create hashes ( for Redis, for example ) while others are better for wire communication. https://en.wikipedia.org/wiki/Cyclic_redundancy_check#Polynomial_representations_of_cyclic

Javascript CRC16 sample code or implementation

女生的网名这么多〃 提交于 2019-12-24 06:18:08
问题 can anybody share a link or sample code to implement checksum for string in javascript? Thanks a lot in advance 回答1: What do you want? You need to be more specific. There is a huge plethora of CRC16 algorithms, each one with its own polynomial and for a specific use. Some CRC16 algorithms are really good to create hashes ( for Redis, for example ) while others are better for wire communication. https://en.wikipedia.org/wiki/Cyclic_redundancy_check#Polynomial_representations_of_cyclic

Difference in Boost CRC and linux/lib/crc-ccitt.c

荒凉一梦 提交于 2019-12-24 04:24:08
问题 I have two sources to calculate the seemingly same crc value. I can not figure out why the 'boost/crc.hpp' implementation differs from the 'linux/lib/crc-ccitt.c' implementation. crc-ccitt.c boost Here is an example that illustrates the Problem. It is sligthly longer since i do not have the Linux kernel source on my Computer. It compiles if you link boost to it. The Problem is that Linux and boost do not agree on the crc value. The Linux source states that: The polynomial ... 0x8408. Add the

Calculate 16 bit CRC in java and append it at the end of the byte array

自闭症网瘾萝莉.ら 提交于 2019-12-24 00:44:56
问题 I have the following buffer byte pingBuff[] ={0x01, 0x01,0x00,0x01,0x00,0x20} I need to calculate 16 bit CRC of these 6 bytes and append it at the end of the pingBuff[] I have done it using C++ and tried to change that code in java like below but it didnot work. package org.totalbeginner.tutorial; public class CRCLikeC { /* Table of CRC values for high–order byte */ char auchCRCHi[] = { 0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41, 0x01, 0xC0, 0x80, 0x41, 0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0,

NSData to CRC-16?

大城市里の小女人 提交于 2019-12-24 00:16:06
问题 I am trying to to calculate CRC-16 from NSData. It is not working, I am expecting "BB3D" from 123456789, but I get nothing like it. This is the code that I have: static const unsigned short crc16table[] = { 0x0000, 0xC0C1, 0xC181, 0x0140, 0xC301, 0x03C0, 0x0280, 0xC241, 0xC601, 0x06C0, 0x0780, 0xC741, 0x0500, 0xC5C1, 0xC481, 0x0440, 0xCC01, 0x0CC0, 0x0D80, 0xCD41, 0x0F00, 0xCFC1, 0xCE81, 0x0E40, 0x0A00, 0xCAC1, 0xCB81, 0x0B40, 0xC901, 0x09C0, 0x0880, 0xC841, 0xD801, 0x18C0, 0x1980, 0xD941,

CRC16 checksum: HCS08 vs. Kermit vs. XMODEM

情到浓时终转凉″ 提交于 2019-12-18 12:36:25
问题 I'm trying to add CRC16 error detection to a Motorola HCS08 microcontroller application. My checksums don't match, though. One online CRC calculator provides both the result I see in my PC program and the result I see on the micro. It calls the micro's result "XModem" and the PC's result "Kermit." What is the difference between the way those two ancient protocols specify the use of CRC16? 回答1: you can implement 16 bit IBM, CCITT, XModem, Kermit, and CCITT 1D0F using the same basic code base.

Function to Calculate a CRC16 Checksum

柔情痞子 提交于 2019-12-17 15:26:48
问题 I'm working on a library to provide simple reliable communication over an RS232 or RS485 connection. Part of this code involves using a CRC16 checksum on the data to detect corruption from line noise. I've created a function to calculate a CRC16 checksum, but it doesn't seem to be outputting correct values. The relevant code I've written is below (it can also be found here). #include <stdint.h> #define CRC16 0x8005 uint16_t gen_crc16(const uint8_t *data, uint16_t size) { uint16_t out = 0; int

Crc16 To String

一曲冷凌霜 提交于 2019-12-16 18:03:35
问题 I can convert string to crc16 but I need convert crc16 to string.Is it possible? function TForm1.CRC_16(Icerik: string): word; var valuehex: word; i: integer; CRC: word; Begin CRC := 0; for i := 1 to length(Icerik) do begin valuehex := ((ord(Icerik[i]) XOR CRC) AND $0F) * $1081; CRC := CRC SHR 4; CRC := CRC XOR valuehex; valuehex := (((ord(Icerik[i]) SHR 4) XOR LO(CRC)) AND $0F); CRC := CRC SHR 4; CRC := CRC XOR (valuehex * $1081); end; CRC_16 := (LO(CRC) SHL 8) OR HI(CRC); end; This function

CRC-CCITT to CRC16 Modbus implementation

孤者浪人 提交于 2019-12-14 03:47:32
问题 I am having a lot of trouble on generating a modbus CRC16 code using PHP. I have found a lot of different codes over the internet but i have tried them and for some reason i didnt get right results. I have found a PHP code for generating CRC16-CCITT. I have chenge the look up table to the modbus CRC corresponding table but the result is still not the right one. The code is bellow. What do i need to do more in order to transform a CRC16-CCITT code into CRC16-MODBUS code. <?php /***************