This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

what means errno -16 for nrf52832?

Hello,

I am using an I2C sensor with my nrf52832 board and if I do the sensor_sample_fetch(dev), I get an error code of -16.

What does that mean?

Is there a table to look up the error codes?

My code looks as follows:

void main(void)
{
	const char *const devname = DT_LABEL(DT_INST(0, microchip_mcp9808));
	const struct device *dev = device_get_binding(devname);
	int rc;

	if (dev == NULL) {
		printf("Device %s not found.\n", devname);
		return;
	}
	
	while (1) {
		struct sensor_value temp;

		rc = sensor_sample_fetch(dev);
		if (rc != 0) {
			printf("sensor_sample_fetch error: %d\n", rc);
			break;
		}

		rc = sensor_channel_get(dev, SENSOR_CHAN_AMBIENT_TEMP, &temp);
		if (rc != 0) {
			printf("sensor_channel_get error: %d\n", rc);
			break;
		}

		printf("%s: %g C\n", now_str(),
		       sensor_value_to_double(&temp));

		k_sleep(K_SECONDS(2));
	}
}

Thank you for your help!

Parents
  • Hello Hans,

    By looking at your code, I assume you are developing with NCS, instead of NRF5 SDK.

    Depending on your project configuration, your errors will be retrieved either from your toolchain "CONFIG_NEWLIB_LIBC=y" or from the Zephyr SDK version itself "CONFIG_NEWLIB_LIBC=n".

    In my case, I have gnuarmemb 9 2019 q4 installed, and I find the error-codes in <toolchain_root>/arm-none-eabi/include/sys/errno.h
    I think the other route is <ncs_root>/zephyr/lib/minimal/include/errno.h

    Having said that, It seems errno -16 states EBUSY, which I'm not 100% sure what it means by the MCP9808.

    There might be an easier path, but unless you have seen it working before with your setup, I would suggest confirming the connections with the sensor and/or scoping the I2C lines through a Logic Analyzer and making sure the device ACKs the I2C frames.

    There also seems to be an example for that IC in <ncs_root>/zephyr/samples/sensor/mcp9808, It could help to build it and bless the setup before diving into the custom-code route.

    I hope this helps somehow.

    Best regards,

    LuisF

Reply
  • Hello Hans,

    By looking at your code, I assume you are developing with NCS, instead of NRF5 SDK.

    Depending on your project configuration, your errors will be retrieved either from your toolchain "CONFIG_NEWLIB_LIBC=y" or from the Zephyr SDK version itself "CONFIG_NEWLIB_LIBC=n".

    In my case, I have gnuarmemb 9 2019 q4 installed, and I find the error-codes in <toolchain_root>/arm-none-eabi/include/sys/errno.h
    I think the other route is <ncs_root>/zephyr/lib/minimal/include/errno.h

    Having said that, It seems errno -16 states EBUSY, which I'm not 100% sure what it means by the MCP9808.

    There might be an easier path, but unless you have seen it working before with your setup, I would suggest confirming the connections with the sensor and/or scoping the I2C lines through a Logic Analyzer and making sure the device ACKs the I2C frames.

    There also seems to be an example for that IC in <ncs_root>/zephyr/samples/sensor/mcp9808, It could help to build it and bless the setup before diving into the custom-code route.

    I hope this helps somehow.

    Best regards,

    LuisF

Children
No Data
Related