# Convert C/C++ Code to Excel VBA Code for Checksum CRC Commands VB Visual Basic

We need you to take existing C/C++ code that correctly calculates CRC outputs for 16 bit CCITT CRCs and turn it into something we can use in Excel using VBA. Or if you feel comfortable just writing this directly in VBA, that works just as well. We just need a working method to reliably calculate these 2 main types of CCITT 16 bit CRC types using Excel when we supply it a string of hex characters.

Here are some resources that might be helpful.

A bit more technical details about the CRC we are calculating and some resources, examples and how to calculate novel values online as well.

CRC-CCITT = 0x1021 = x16 + x12 + x5 + 1

Online CRC Calculator for CRC2 and CRC3

Test Data Sequence = %01%07%02%05%02%00%01%00%00 (so it is treated as hex)

CRC order = 16

CRC polynom = 1021

Initial values = 1D0F or FFFF or 0000

Final XOR value = 0

CRC1 cannot be calculated here, see above for instructions on how to calculate

CRC2 = reverse data bytes, reverse CRC result before Final XOR

CRC3 = no reverse data bytes, no reverse CRC result before Final XOR

CRC2 with 0xFFFF CRC Offset Working Example

CRC-CCITT (MCRF4XX)

Result Check Poly Init RefIn RefOut XorOut

0xF083 0x6F91 0x1021 0xFFFF true true 0x0000

01 01 07 02 05 02 00 01 00 00 [65 A8] 04

^^ ^^ ^^ ^^ ^^ ^^ ^^ ^^ ^^ = CRC Calculations (Ignore other values, so 01 and the CRC and 04)

The returned CRC value is A865, which is then flipped to be 65 A8.

Note it is calculating the value based on 01 07 02 05 02 00 01, ignoring the first 01 and the last 04. Also note that it flips the order of the CRC values so they can be used. Something like =RIGHT(A1,2)&LEFT(A2,2) will do that in Excel.

Here are 4 samples with the CRC values already calculated using CRC2 with 0xFFFF CRC Offset.

tx: 01 01 07 02 05 02 00 01 00 00 [83 F0] 04

rx: 01 01 0C 02 00 00 00 F6 40 00 00 3F 08 00 00 [FD B0] 04

tx: 01 01 07 02 05 02 01 01 00 00 [38 EC] 04

rx: 01 01 0C 02 00 00 00 FE 40 00 03 21 09 00 00 [B2 B7] 04

There are a total of 6 "types" of CRC outputs that need to be correctly calculated but there are only two main types, they just use a different initial value. Both CRC types use the same 0x1021 poly.

CRC2 has three types, changing the init values.

CRC2 = CRC-16-CCITT: Polynomial 1021h (MCRF4XX, Kermet)

width=16 poly=0x1021 init=0x1D0F (or 0xFFFF or 0x0000) refin=true refout=true xorout=0x0000 check=0x6f91 residue=0x0000

CRC3 has three types, changing the init values.

CRC3 = CRC-16-CCITT: Polynomial 1021h (CRC-16/AUG-CCITT, XModem)

width=16 poly=0x1021 init=0x1D0F (or 0xFFFF or 0x0000) refin=false refout=false xorout=0x0000 check=0xe5cc residue=0x0000

Also attaching a full sheet of examples to make testing easier. Please see attached files.

It would be nice if you could make a single Excel command to calculate the CRC1 type as well. It is trivially easy to calculate and could probably be done with a single Excel command but it would be nice to be able to do it with VBA. Please see examples for CRC1 as well.

In summary, this project needs to make sure it does the following:

It should do basic error detection to ensure that it does not calculate junk values. We are calculating hex values only.

It should be able to read a string that has a CRC already included and determine what type it is.

It should be able to determine if there is already a CRC calculated in the data.

The above should be able to read a series of HEX values and return just the CRC.

The above should be able to read a series of HEX values and return the entire command with the CRC placed right before the final 04 command.

Note that the Tx and Rx commands always dictate the length of the string (in hex) as the third byte from the left. See attached image for clarification.

Tietoa työnantajasta:
( 23 arvostelua ) Mebane, United States

Projektin tunnus: #20044736

## 10 freelanceria on tarjonnut keskimäärin %project_bid_stats_avg_sub_26% %project_currencyDetails_sign_sub_27% tähän työhön

Mickelson

Hi, sir! I checked your project carefully. I have a deep understanding of the problems you are going to realize in your project. They are not so difficult for me with 12 years of vba development experience. Un Lisää

\$200 USD 2 päivässä
(59 arvostelua)
6.1
TalAkerele

[login to view URL] I am very happy to bid your project. i'd like to work with you. I read your requirements carefully,i see what you mean. i've been experienced with C Programming, C++ Programming, Excel, VB.NET, Visual Basic Lisää

\$111 USD 1 päivässä
(42 arvostelua)
5.4
xinglong717

\$200 USD 7 päivässä
(30 arvostelua)
5.1
Mokshith30

Hi I have Read Your Requirements I am Excel VBA Expert Experianced in VBA Macros & Web Scraping Script... I can finish any kind of vba task in 1 day only pls see my previous projects for my vba experiance T Lisää

\$61 USD 1 päivässä
(33 arvostelua)
4.3
JinTaiZhe

Hi. I hope to see you in chat, to discuss in detail. As you can see from my reviews and profile, I am a experienced developer with full stack knowledge and career on these technologies. I am sure I can do this perfect Lisää

\$140 USD 7 päivässä
(4 arvostelua)
4.3
olrya

I have many experience more than 5+ years in web and app development field. Budget is not important. I need lowest budget among other your freelancer, because I am a new freelancer and my honor is very important for Lisää

\$140 USD 7 päivässä
(1 arvostelu)
1.6
wulongzhu87

Hi there! My name is Longzhu and I’m a professional developer with 7+ years of experience. I'm honesty, communicable, responsible and passionate about web programming holding my hand on a pulse of a new technologies e Lisää

\$140 USD 7 päivässä
(0 arvostelua)
0.0
liwang555

Hi I'm senior C++, C# developer with experience of image processing and databases. Develop and support application programs for administrative, Web systems using ASP.NET and related tools. Analyze code for system t Lisää

\$155 USD 3 päivässä
(0 arvostelua)
0.0
mikhailalexey

Dear Client. I'm interested in your project and I perfectly can your require to convert VBA to VB. I am a full stack web developer with 7+ years experience and I have excellent skills and experience in the projec Lisää

\$120 USD 3 päivässä
(0 arvostelua)
0.0