Question
write a C/C++ program which computes the CRC of characters using the CRC-16 polynomial x16+x15+x2+1 . Your program should read data from the standard input
write a C/C++ program which computes the CRC of characters using the CRC-16 polynomialx16+x15+x2+1. Your program should read data from the standard input and output the 16-bit CRC in hexadecimal.
Your program should provide the following function:
unsigned short crc(unsigned char msg[], int len)
where the parameter len contains length of the msg. Your main() function will read the input data (including the newline character, the space character, etc. ) until reach EOF (not included in the msg), pass the data to the function crc(), and print the CRC value that the function crc() returns. Next, append the returned CRC value at the end of input data and call the function crc() again. Your crc() function should return 0 this time. Your program should work for input up to 512 characters. Your crc function should emulate the hardware scheme discussed in the class. The circuits shown in the bottom right portion (see textbook Figure B.5) can be ignored. Note that NO CREDIT will be given if you use Figure B.6 algorithm which is based on hand calculation method as in Figure B.4.
For program tracing and debugging purpose, your program should also support the command line option --debug to print the intermediate result (in hexadecimal) stored in the FCS shift register for each clock pulse.
Review Cs bit manipulation facilities, including the shift operator >, the XOR operator ,>
the bitwise OR operator |, the bitwise AND operator &, and the bit negation operator . Be sure and useunsignedvariables when working with checksums.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started