LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

RS232 CHECKSUM

I want to make sure that Data send from my CVI application to a
hardware-component (programmed in C by myself) are received correct. I think
a validation via checksum is the right way. Does anybody know a simple
Routine to build a checksum or another simple way to crosscheck transmitted
/ received data ?

--
iSiTEC GmbH
Dipl.-Ing. Norbert Rieper
Stresemannstr. 46 / 0.10
27570 Bremerhaven
Tel: 0471 / 92234-31
Fax: 0471 / 92234-44
nrieper@isitec.de
0 Kudos
Message 1 of 6
(4,638 Views)
I would use CRC. There is lots of documentation around on it. I have a
little.

Richard


"Norbert Rieper" wrote in message
news:39f69f75@newsgroups.ni.com...
> I want to make sure that Data send from my CVI application to a
> hardware-component (programmed in C by myself) are received correct. I
think
> a validation via checksum is the right way. Does anybody know a simple
> Routine to build a checksum or another simple way to crosscheck
transmitted
> / received data ?
>
> --
> iSiTEC GmbH
> Dipl.-Ing. Norbert Rieper
> Stresemannstr. 46 / 0.10
> 27570 Bremerhaven
> Tel: 0471 / 92234-31
> Fax: 0471 / 92234-44
> nrieper@isitec.de
>
>
0 Kudos
Message 2 of 6
(4,636 Views)
Thanks Richard,

I would like to use CRC too, but there is no possibility to programm the
serial port of the hardware (microcontroller 8051) to xmit or receive with
any protocol. So I have to write my own protocol. I thought that somebody
already has done something like this.



RBL schrieb in im Newsbeitrag:
39f6ae45@newsgroups.ni.com...
> I would use CRC. There is lots of documentation around on it. I have a
> little.
>
> Richard
>
>
> "Norbert Rieper" wrote in message
> news:39f69f75@newsgroups.ni.com...
> > I want to make sure that Data send from my CVI application to a
> > hardware-component (programmed in C by myself) are received correct. I
> think
> > a validation via checksum is the right way. Does an
ybody know a simple
> > Routine to build a checksum or another simple way to crosscheck
> transmitted
> > / received data ?
> >
> > --
> > iSiTEC GmbH
> > Dipl.-Ing. Norbert Rieper
> > Stresemannstr. 46 / 0.10
> > 27570 Bremerhaven
> > Tel: 0471 / 92234-31
> > Fax: 0471 / 92234-44
> > nrieper@isitec.de
> >
> >
>
>
0 Kudos
Message 3 of 6
(4,637 Views)
Hi ,
here's simple CRC check for modbus:
p.s. If you care for speed of calculating the Crc ther's also CrcFast(),
but it uses array of fixed 255 words table, if you have ebough code in the
micricontroller ...

//*******************
// It builds the crc word usCrcReturn form the bytes in the telegram
// Telegram: byte0 byte1 ... byten CRCbyteHi CRCByteLo
unsigned short int CalcCrc ( unsigned char *ptr, int iBufferLength ) {
unsigned short int usCrc=0xFFFF;
unsigned short int usCrcReturn;
int i,j;
for (i=0; i usCrc ^= ptr[i];
for (j=0; j<8; j++) {
if (usCrc & 1) {
usCrc >>= 1;
usCrc ^= 0xA001;
}
else
usCrc >>= 1;
}
}

*(((unsigned char *)&usCrcReturn)+1) = *(((unsigned char *)&usCrc)+0);
*(((unsigned char *)&usCrcReturn)+0) = *(((unsigned char *)&usCrc)+1);

return (usCrcReturn);
}
//*******************



OR you can use simple XOR of all bytes ...

Hope this helps

"Norbert Rieper" wrote:
>Thanks Richard,>>I would like to use CRC too, but there is no possibility
to programm the>serial port of the hardware (microcontroller 8051) to xmit
or receive with>any protocol. So I have to write my own protocol. I thought
that somebody>already has done something like this.>>>>RBL
schrieb in im Newsbeitrag:>39f6ae45@newsgroups.ni.com...>> I would use CRC.
There is lots of documentation around on it. I have a>> little.>>>> Richard>>>>>>
"Norbert Rieper" wrote in message>> news:39f69f75@newsgroups.ni.com...>>
> I want to make sure that Data send from my CVI application to a>> > hardware-component
(programmed in C by myself) are received correct. I>> think>> > a validation
via checksum is the right way. Does anybody know a simple>> > Routine to
build a checksum or another simple way to crosscheck>> transmitted>> > /
received data ?>> >>> > -->> > iSiTEC GmbH>> > Dipl.-Ing. Norbert Rieper>>
> Stresemannstr. 46 / 0.10>> > 27570 Bremerhaven>> > Tel: 0471 / 92234-31>>
> Fax: 0471 / 92234-44>> > nrieper@isitec.de>> >>> >>>>>>>
0 Kudos
Message 4 of 6
(4,636 Views)
Just cast the transmitted data as a byte array and add all the entries
to a preininialized byte variable using a loop. The result is the sum
(without carry). This is very easy to do also inside a micro controller
(MC). CRC is a little bit more expensive.

Maybe it's also imaginable to echo all received data. So when you send a
command to your MC, the MC echos the same command back to the PC and the
PC checks the received data against the transmitted. If this is
suitable, depends on your application.

Regards
Torsten

Norbert Rieper schrieb:
>
> I want to make sure that Data send from my CVI application to a
> hardware-component (programmed in C by myself) are received correct. I think
> a validation via checksum is the right way. Does anybody know a simple
> Routine
to build a checksum or another simple way to crosscheck transmitted
> / received data ?
>
> --
> iSiTEC GmbH
> Dipl.-Ing. Norbert Rieper
> Stresemannstr. 46 / 0.10
> 27570 Bremerhaven
> Tel: 0471 / 92234-31
> Fax: 0471 / 92234-44
> nrieper@isitec.de

--
Torsten Levin Tel.: ++49-(0)89-72495-451
Kayser-Threde GmbH Fax: ++49-(0)89-72495-291
Perchtinger Str. 3 mailto:TL@kayser-threde.de
D-81379 München http://www.kayser-threde.de
0 Kudos
Message 5 of 6
(4,636 Views)
Look at
ftp.natinst.com/incoming

for crc.zip

Regards
Rainer


Norbert Rieper schrieb:
>
> I want to make sure that Data send from my CVI application to a
> hardware-component (programmed in C by myself) are received correct. I think
> a validation via checksum is the right way. Does anybody know a simple
> Routine to build a checksum or another simple way to crosscheck transmitted
> / received data ?
>
> --
> iSiTEC GmbH
> Dipl.-Ing. Norbert Rieper
> Stresemannstr. 46 / 0.10
> 27570 Bremerhaven
> Tel: 0471 / 92234-31
> Fax: 0471 / 92234-44
> nrieper@isitec.de

--
Rainer Zieschang

--

LDIC Germany

Voice +49 35207 863 0 LEMKE DIAGNOSTICS GmbH
Fax +49 35207 863 11 Radeburgerstr. 47
01468 Volkersdorf, German
y
mailto: zieschang@ldic.de http://www.ldic.de/


=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+
0 Kudos
Message 6 of 6
(4,634 Views)