Can anyone help me with CRC_CHECK and CRC_GEN libraries from oscat304.lib.
My project is using a Wago 750-650 RS232 card to communicate with a laptop. The customer has asked me to use crc and i found the oscat library after some seaching. My problem is, i don't know how to use them. All the information i can find is in German. Can anyone provide me with an example codesys project or provide a step by step guide to implement CRC.
Thank You
Dave
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
IF pReceiveStr = 0 THEN ( receive buffer with address of receivers initialize string )
pReceiveStr:=ADR(ReceiveString);
END_IF;
IF Receive_Buffer.Index>0 THEN ( new data is received )
FORi:=0TO255DOpReceiveStr^[i]:=16#00; (* receive buffer delete *)END_FOR;FORi:=0TOReceive_Buffer.Index-1DOpReceiveStr^[i] :=Receive_Buffer.Data[ i ]; (* ring buffer data in receive buffer to copy *)END_FOR;M_RECVSTR:=TRUE;
oscat304.lib all help about CRC functions in English
CRC_CHECK
FUNCTIONCRC_CHECK : BOOLVAR_INPUT
  pt : POINTERTOARRAY[0..32000] OFBYTE;
  size : UINT;END_VARVAR_INPUTCONSTANT
  Polynom_L : DWORD;
  Polynom_32 : BOOL;END_VARVAREND_VAR(*version1.1  16. mar. 2008programmer   hugotestedby    tobiasCRC_CHECKchecksablockofdataforacrcchecksumandreturnstrueisthechecksumis0andtherforeaerrorfreedatatransmission.
theCRCPolynomisspecifiedwiththeconfigvariablePolynom_Lwhichholdsthelowest32bitsofthepolynomandPolynom_33whichholdsbit33ofthePolynom.
APolynomx4+X+1isrepresentedby10011.
Theinputdataisanarrayofbyteofanysize, thefunctioniscalledbyCRC_CHECK(ADR(array),SIZEOF(array)).
*)
CRC_GEN
FUNCTIONCRC_GEN : DWORDVAR_INPUT
  pt : POINTERTOARRAY[0..32000] OFBYTE;
  size : UINT;END_VARVAR_INPUTCONSTANT
  Polynom_L : DWORD;
  Polynom_32 : BOOL;
  init: DWORD;
  XOR_out : DWORD;
  rev_in : BOOL;
  rev_out : BOOL;END_VARVAR
  polynom : DWORD;
  p_length : INT;
  BS : BYTE;
  data : DWORD;
  count : BYTE;
  temp : BOOL;
  step: INT;
  s4: INT;END_VAR(*version1.4  16. mar. 2008programmer   hugotestedby    tobiasCRC_GENgeneratesaCRCchecksumfromablockofdataandreturns thechecksuminaDWORDtobeconnectedtothedatafortransmission.
theCRCPolynomisspecifiedwiththeconfigvariablePolynom_Lwhichholdsthelowest32bitsofthepolynomandPolynom_33whichholdsbit33ofthePolynom.
APolynomx4+X+1isrepresentedby10011.
Theinputdataisanarrayofbyteofanysize, thefunctioniscalledbyCRC_GEN(ADR(array),SIZEOF(array)).
*)
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Can anyone help me with CRC_CHECK and CRC_GEN libraries from oscat304.lib.
My project is using a Wago 750-650 RS232 card to communicate with a laptop. The customer has asked me to use crc and i found the oscat library after some seaching. My problem is, i don't know how to use them. All the information i can find is in German. Can anyone provide me with an example codesys project or provide a step by step guide to implement CRC.
Thank You
Dave
Try to google "A painless guide to CRC error detection algorithms"
Good luck!
Thanks for the reply Avgur.
But my problem is that i don't know how to use the CRC_CHECK and CRC_GEN functions from the oscat304.lib
What i need is a guide on how to use the two functions.
My code so far is below.
PROGRAM COMM2
VAR
END_VAR
COMM2( bCOM_PORT_NR := 2,
IF pReceiveStr = 0 THEN ( receive buffer with address of receivers initialize string )
END_IF;
IF Receive_Buffer.Index>0 THEN ( new data is received )
END_IF;
IF CLEAR_BUFFER THEN ( new request will be sent )
Receive_Buffer.Index := 0; ( receive buffer delete )
END_IF
CRC:= CRC_CHECK(pRECEIVESTR, I, 469, Polynom_32);
Any help would be appreciated.
Dave
oscat304.lib all help about CRC functions in English
CRC_CHECK
CRC_GEN