Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sensorcal not working #45

Open
iglesiasmarianod opened this issue Mar 1, 2022 · 1 comment · May be fixed by #46
Open

Sensorcal not working #45

iglesiasmarianod opened this issue Mar 1, 2022 · 1 comment · May be fixed by #46
Assignees

Comments

@iglesiasmarianod
Copy link
Contributor

iglesiasmarianod commented Mar 1, 2022

I've built the latest image and found sensorcal is not working.
It finds sensorboard as virgin and asks to initialize (even when the sensorboard is been calibrated before).
I clicked on "yes" to initialize the board again, but keeps seeing the board as virgin.
I ran sensorcal -c. The output is "EEPROM content not valid, run sensorcal -i"
I ran sensorcal -i and seems to run OK.
I suspect it has something to do with Checksum calculation or verification.
Running sensorcal -d The output is "EEPROM content not valid, run sensorcal -i" twice
From sensorcal:


		case 'd':
				// read actual EEPROM values
				printf("Reading EEPROM values ...\n\n");
				if( eeprom_read_data(&eeprom, &data) == 0)
				{
				  memcpy(sn,data.serial,6);
					printf("Actual EEPROM values:\n");
					printf("---------------------\n");
					printf("Serial: \t\t\t%s\n", sn);
					printf("Differential pressure offset:\t%f\n",data.zero_offset);
				}
				else
				{
					printf("EEPROM content not valid !!\n");
					printf("Please use -i to initialize EEPROM !!\n");
					exit_code=2;
					break;
				}

from 24c16.cpp

int eeprom_read_data(t_24c16 *eeprom, t_eeprom_data *data)
{
	// read eeprom data to struct
	if (eeprom_read(eeprom, (char*)data, 0x00, sizeof(*data))==1)
		return 1;						// Failed to read the EEPROM

	// verify checksum
	if (!verify_checksum(data))
	{
		printf("EEPROM content not valid !!\n");
		printf("Please use -i to initialize EEPROM !!\n");
		return 2;
	}
	else
	{
		return 0;
	}
}

It seems to be returning 2 and printing error message twice as eeprom_read() is not printing error messages.

@iglesiasmarianod
Copy link
Contributor Author

iglesiasmarianod commented Mar 1, 2022

Going back from

int update_checksum(t_eeprom_data* data)
{
	char* p_data;
	char checksum=0x00;

	p_data = (char*)data;

	for (size_t i=0; i<sizeof(*data); i++)
	{
		checksum += *p_data;
		p_data++;
	}

	//printf("Checksum: %x\n", checksum);
	data->checksum = checksum;
	return (0);
}

to

int update_checksum(t_eeprom_data* data)
{
	char* p_data;
	int i;
	char checksum=0x00;

	p_data = (char*)data;

	for (i=0; i<sizeof(data); i++)
	{
		checksum += *p_data;
		p_data++;
	}

	//printf("Checksum: %x\n", checksum);
	data->checksum = checksum;
	return (0);
}

in update_checksum and verify_checksum fixes the issue.

@linuxianer99 linuxianer99 self-assigned this Mar 8, 2022
@linuxianer99 linuxianer99 transferred this issue from Openvario/meta-openvario Mar 8, 2022
@linuxianer99 linuxianer99 linked a pull request Mar 8, 2022 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants