0

Hi, I am trying to implement a crc check but I am not having the correct output. i.e. I am having a "Corrupted file" when the file is not corrupted, and vice versa. I am not "seeing" my mistake since according to me the logic is right. The wierd thing is that before I have implemented the CRC in a function it used to work...now that it is in a function I am having the opposite output. below is my code

before implemented into a function (when it used to work)

P.S adder is the counter of 'corrupted' bits in file.

if (adder != 0)
{
 printf("NOT Corrupted");
}
else
{
printf("Corrupted");
}

now that it is in a function (not working)

void CRC(int check)
{
	if (check != 0)
	{												printf("NOT Corrupted");
	}
	else
	{
		printf("Corrupted");
	}
// return 0;
	
}

Thanks a lot.

3
Contributors
4
Replies
5
Views
7 Years
Discussion Span
Last Post by thomas_naveen
0

This is the part were I am calling the function. adder1 is a counter that contains the number of errors in the file. Then afterwards I am resetting the counter to 0 again so that it starts again from 0 when reading from another file.

CRC(adder1);
	 		if (adder1==0){
	 			nta=nta+0.025;
	 			printf("ACK to A arrives at %.3f\n", nta);
	 		}
	 		adder1=0;

Thanks a lot.

0

did you try displaying the value of int check, just to be sure its what you expect it to be?

void CRC(int check)
{
/*display check here*/
	if (check != 0)
	{												printf("NOT Corrupted");
	}
	else
	{
		printf("Corrupted");
	}
// return 0;
	
}

Your not really give us much to work with..

Edited by gerard4143: n/a

0

The only discrepancy that I can spot is that 'adder' is used in the if check (outside the function , in the first post) and 'adder1' is being passed to the function.

Edited by thomas_naveen: added more clarity to explanation

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.