Home > Software engineering >  Warrior, please help me to translate this period of CRC check program in vb language program!
Warrior, please help me to translate this period of CRC check program in vb language program!

Time:10-07

/* * * * * * * * * * * * * * * * * * * * *
The Get CRC
* * * * * * * * * * * * * * * * * * * * */
Unsigned short get_crc (buffer, count)
Unsigned char * buffer;
Int count;
{
Unsigned short code.
Unsigned short CRC;

CRC=0;
While (count)
{
Code=(crc> 8) & amp; Oxff;
Code ^=(* buffer + + & amp; Oxff);

Code ^=Code & gt;> 4.
Crc & lt; <=8;
Crc ^=code;
Crc & lt; <=5;
Crc ^=code;
Crc & lt; <=7.
Crc ^=code;
}
The Return of CRC;
}

CodePudding user response:

Don't be A language code is modified to B language code busywork,
Also don't use A language code to directly invoke B language code base, this complicated things so easy to get wrong,
Just make A, B language code of input and output is redirected to A text file, or modify A, B language code let it through text file input and output,
Can easily make A, B coordination between the two languages,

CodePudding user response:



reference 1st floor zhao4zhong1 response:
don't do A language code is modified to B language code busywork,
Also don't use A language code to directly invoke B language code base, this complicated things so easy to get wrong,
Just make A, B language code of input and output is redirected to A text file, or modify A, B language code let it through text file input and output,
You can easily make A, B coordination between the two languages,


Could you tell me this code is generally we use CRC16?

CodePudding user response:

I don't know, reference CRC16 corresponding expressions

CodePudding user response:

refer to the second floor zhuogirllz response:
Quote: refer to 1st floor zhao4zhong1 response:

Don't be A language code is modified to B language code busywork,
Also don't use A language code to directly invoke B language code base, this complicated things so easy to get wrong,
Just make A, B language code of input and output is redirected to A text file, or modify A, B language code let it through text file input and output,
You can easily make A, B coordination between the two languages,


Could you tell me this code is generally we use CRC16?


Commonly used CRC - 16 there are many kinds of agreement,

CodePudding user response:

reference 4 floor of123 response:
Quote: refer to the second floor zhuogirllz response:



Quote: refer to 1st floor zhao4zhong1 response:

Don't be A language code is modified to B language code busywork,
Also don't use A language code to directly invoke B language code base, this complicated things so easy to get wrong,
Just make A, B language code of input and output is redirected to A text file, or modify A, B language code let it through text file input and output,
You can easily make A, B coordination between the two languages,


Could you tell me this code is generally we use CRC16?


CRC - 16 there are many common agreement,


Can you please help me translate this code into the VB version??

CodePudding user response:

Not to, only supplies the reference:
/* * * * * * * * * * * * * * * * * * * * * 
The Get CRC
* * * * * * * * * * * * * * * * * * * * */
The Public Function get_crc (buffer as Byte (), count as Long) as Long 'unsigned short get_crc (buffer, count)
'the unsigned char * buffer;
'int count;
Dim As Long I '{
Dim code As Long 'unsigned short code;
Dim CRC As Long 'unsigned short CRC;
I=0 '
CRC=0 'CRC=0;
Do 'while (count)
The count=count - 1: If the count=0 Then Exit the Do '{
CRC code=\ 'code=256 mod 256 (crc> 8) & amp; 0 XFF.
Code=code xor buffer (I) : I=I + 1 'code ^=(* buffer + + & amp; 0 XFF);
'
Code=code xor (64) code \ 'code ^=code & gt;> 4.
CRC=CRC * 256 'CRC & lt; <=8;
CRC ^==CRC xor CRC code 'code;
CRC=CRC * 32 'CRC & lt; <=5;
CRC ^==CRC xor CRC code 'code;
CRC=CRC * 128 'CRC & lt; <=7.
CRC ^==CRC xor CRC code 'code;
Loop '}
Get_crc=CRC 'return CRC;
End the Function '}

CodePudding user response:

Will overflow, and displacement of each step (multiplication), the top 2 bytes at the end of every clean off:

CRC=(CRC * 128) And & amp; HFFFF&

Or

CRC=65536 * 128 (CRC) Mod

The problem is that you don't know the whether he will use the agreement, no debugging with baseline data (input message and CRC result), unable to verify whether it is right,

CodePudding user response:

Through VB6.0 by use of CRC16 code:

 Public Function CRC16 (data () As Byte) As String 
Dim CRC16Lo As Byte, CRC16Hi As Byte CRC register
'Dim CL As Byte, CH As Byte 'polynomial code & amp; HA001
Dim CRCLo As String, CRCHi As String
Dim SaveHi As Byte, SaveLo As Byte
Dim As Integer I
Dim Flag As Integer
CRC16Lo=& amp; HFF
CRC16Hi=& amp; HFF
CL=& amp; H1
CH=& amp; HA0
For I=0 To UBound (data)
CRC16Lo=CRC16Lo Xor data (I) 'every data with CRC register for exclusive or
nullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnull