CRC

Hi dude , i want to know if someone have a programme for calculete the CRC of an ASCII tram pleas
thanks

Bonjour tout le monde , j’aimerais savoir si quelqu’un a un programme fini pour calculer le CRC d’une tram ASCII svp merci !

Include <util/crc16.h>, and you’ll get access to these CRC functions → avr-libc: <util/crc16.h>: CRC Computations

Man i totaly love you , THANKS !

Pas de problème

Ah damn sorry man , its not that haha , i want calculete the CRC of an ASCII tram with the XOR and not with an polynomial form ^^
(i hope its clear , im not good in english haha)
Have a nice day and thanks for your help

Hmm...are you actually asking for a "checksum," which is just an XOR (^) of all bytes?

Otherwise, I'm not sure what you mean. A CRC is always going to refer to polynomial division. Although CRC algorithms can be written different ways, the ones in avr-libc implement them with XOR (aka ^ in C).

Yes man , i want a checksum ^^ but i don’t know do it because im realy bad on programmation , but i need this information to end my systeme ^^
i have something like that : Phone send a message to an GSM , GSM send a message to my arduino card , and my arduino card calculate the checksum for see if the “information” are corrupted or not , ann then she sand again the TRAM ASCII to my screen
Have you a programme for do that ?
Thanks <3

If this doesn't work for you, you need to post a link to the datasheet for your GSM module:

``````#include "Arduino.h"
// Calcule la somme de contrôle pour le tableau d'octets de données " longueur " pointée par "data_ptr.
uint8_t calc_checksum(uint8_t* data_ptr, uint16_t length)
{
uint8_t checksum = 0;  // Commencez checksum à zéro
while(length--) checksum ^= *data_ptr++; // XOR chaque octet de données dans la somme de contrôle.
return checksum;
}
``````

Okay man ! :D thanks Can you just , put the "//" for explane your wonderfull programme pleas ^^ ? im bad in programation but i want became better , then its better if i understand haha :D thank you realy !!!!!!!!!!!!!!!!!!!!!!!!!

OK, done. Although the C statements are sort of more clear than the comments.

Thanks , if i can , i want to ask you a last question pleas dude ^^ (im realy sorry haha)
Do you have something to convert this checksum on 2 Hexadecimal character
(for put them on the TRAM ASCII) ^^ thanks dude , realy

I have no idea what TRAM ASCII is, but here's calculating the checksum for two bytes:

``````#include "Arduino.h"

// Calcule la somme de contrôle pour le tableau d'octets de données " longueur " pointée par "data_ptr.
uint8_t calc_checksum(uint8_t* data_ptr, uint16_t length)
{
uint8_t checksum = 0;  // Commencez checksum à zéro
while(length--) checksum ^= *data_ptr++; // XOR chaque octet de données dans la somme de contrôle.
return checksum;
}

void setup()
{
Serial.begin(115200);             //! Initialize the serial port to the PC
}

void loop()
{
// Calculate the checksum of the two byte TRAM ASCII?
// Calculer la somme de contrôle des deux octets TRAM ASCII ?
// Berechnen Sie die Prüfsumme der zwei Byte TRAM ASCII ?
// दो बाइट ट्राम ASCII के checksum की गणना ?
// 计算这两个字节TRAM ASCII码的校验？
// Вычислить контрольную сумму два байта Чам ASCII ?
// Se calcula la suma de comprobación del TRAM ASCII de dos bytes ?
// Calcular a soma de verificação do TRAM ASCII de dois bytes ?
uint8_t tram_ascii[2] = {'?', '!'};
uint8_t tram_ascii_checksum = calc_checksum(tram_ascii, sizeof(tram_ascii));
}
``````

hem i can show you if you want ^^
An ASCII tram is like that : A35
its always the same exept this part : A35
“A” is the message send , and 35 the checksum
When your programme calculete the checksum , he did it but i need him on HEXA for put him again on the ASCII tram and send it
^^ i hope its clear because im so bad in english , thanks for your help , again and again you help me to mush ^^ !

There is a french section of the board down below.