u-blox / ubxlib

Portable C libraries which provide APIs to build applications with u-blox products and services. Delivered as add-on to existing microcontroller and RTOS SDKs.
Apache License 2.0
287 stars 82 forks source link

ESP-IDF with GNSS over I2C with bus already open #194

Closed synologic closed 5 months ago

synologic commented 5 months ago

Hi all,

i'm having an issue when trying to initialize a NEO9 via i2c, where my application has already initialized the I2C bus:

deviceConfig.deviceType = U_DEVICE_TYPE_GNSS;
deviceConfig.deviceCfg.cfgGnss.moduleType = U_GNSS_MODULE_TYPE_M9;
deviceConfig.deviceCfg.cfgGnss.pinDataReady = -1;
deviceConfig.deviceCfg.cfgGnss.pinEnablePower = U_CFG_APP_PIN_GNSS_ENABLE_POWER;
deviceConfig.deviceCfg.cfgGnss.i2cAddress = GPS_ADDRESS;
deviceConfig.transportType = U_DEVICE_TRANSPORT_TYPE_I2C;
deviceConfig.transportCfg.cfgI2c.alreadyOpen = true;
deviceConfig.transportCfg.cfgI2c.i2c = 1;
deviceConfig.transportCfg.cfgI2c.clockHertz = 400000;
deviceConfig.transportCfg.cfgI2c.pinScl = I2C1_SCL;
deviceConfig.transportCfg.cfgI2c.pinSda = I2C1_SDA;

uPortInit();
uPortI2cInit();
uDeviceInit();

int32_t returnCode = uDeviceOpen(&deviceConfig, &devHandle);
ESP_LOGI(LOG_TAG,"GPS device opened with code %ld", returnCode);

returnCode is U_ERROR_COMMON_PLATFORM

If i try the same but with alreadyOpen set to false, there's no problem

Any suggestions ?

Thanks

RobMeades commented 5 months ago

Hi there, and sorry you're having problems with this.

The effect of setting alreadyOpen to true is that, in the internal function uDevicePrivateI2cOpen(), uPortI2cAdopt() is called, instead of uPortI2cOpen().

The implementation of uPortI2cAdopt() for ESP-IDF just calls the static function openI2c() with adopt set to true, and in that case openI2c() does not call any of the ESP-IDF functions (i2c_param_config(), i2c_set_timeout(), or i2c_driver_install()), as you will have already called these before you called uDeviceOpen(), it just remembers the i2c and clockHertz parameters, and that the I2C port was adopted (so the ubxlib code won't try to close it), and returns.

Can you confirm that at least i2c_driver_install(), and probably i2c_param_config(), have been called before uDeviceOpen(), and what parameters you called them with?

synologic commented 5 months ago

I can confirm the i2c bus is correctly configured as GNSS shares the bus with 10 other peripherals which are working fine.

From tracing, i have managed to isolate the cause in the send() function from u_port_i2c.c, line 204, which is a bit weird (did not do bus sniffing yet).

In fact, several commands are sent over to the GNSS device via i2c_master_cmd_begin however only one returns ESP_TIMEOUT hence the write fails according to ESP-IDF

I made sure there are no other tasks competing for i2c bus, but afaik esp-idf has mutexes on i2c_master* functions and are thread safe.

In any case, my i2c init code:

conf.mode = I2C_MODE_MASTER;
conf.sda_io_num = I2C0_SDA;
conf.scl_io_num = I2C0_SCL;
conf.sda_pullup_en = GPIO_PULLUP_ENABLE;
conf.scl_pullup_en = GPIO_PULLUP_ENABLE;
conf.master.clk_speed = 400000; // 400 Khz
conf.clk_flags = 0;

with looks the same as the uPortI2cOpen

When it's not working i get from the lib:

U_GNSS: sent command b5 62 0a 06 00 00 10 3a.

But when i let ubxlib handle the idc, i get an answer to that

U_GNSS: decoded UBX response 0x0a 0x06: 0e 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 [body 120 byte(s)].

RobMeades commented 5 months ago

Hmph, that is very odd. When there's an I2C issue ESP-IDF usually spits out some log text of its own: do you see anything of that nature when this problem occurs?

EDIT: which version of ESP-IDF is this with, just for information?

RobMeades commented 5 months ago

Maybe this is just a typo, but in your I2C init code that you pasted-in above you have:

conf.sda_io_num = I2C0_SDA;
conf.scl_io_num = I2C0_SCL;

...whereas in the uDeviceCfg_t initialisation you pasted in above you have:

deviceConfig.transportCfg.cfgI2c.i2c = 1;
deviceConfig.transportCfg.cfgI2c.pinScl = I2C1_SCL;
deviceConfig.transportCfg.cfgI2c.pinSda = I2C1_SDA;
synologic commented 5 months ago

Not a typo, just wrong section of the code ... i use both i2c hardware ports with same settings but different pins, that's just the initial config object with the I2C0 pins, i have I2C1 pins later in the code ;-)

ESP-IDF is 5.1.2

RobMeades commented 5 months ago

You are on a slightly later version of ESP-IDF than we test with; we test with 5.0.1, had to stop there because something went wrong inside ESP-IDF for one of our module types, meaning that ESP-IDF no longer recognizes the flash.

But ESP-IDF is usually pretty good about backwards-compatibility and any major changes would likely have landed in v5, not in v5.1.

If you are able to, I think sniffing is the thing. Should you be able to Saleae probe it, we can read that.

synologic commented 5 months ago

Best i can do is Digital Discovery 2 :) I'll keep you posted shortly

synologic commented 5 months ago

On the DD2 trace, i see diferent behavior (device is on 0x42):

With I2C Port already initialized before:

Start, h85 [ h42 | RD ], Error! Start, h84 [ h42 | WR ], hFD, Restart, h85 [ h42 | RD ], h00, h00 NAK, Stop Start, h84 [ h42 | WR ], hFD, Restart, h85 [ h42 | RD ], h00, h00 NAK, Stop Start, h84 [ h42 | WR ], Restart, h84 [ h42 | WR ], Restart, h84 [ h42 | WR ], hFD, Restart, h85 [ h42 | RD ], h00 NAK, Error! Restart, h84 [ h42 | WR ], Restart, h84 [ h42 | WR ], hFD, Restart, h85 [ h42 | RD ], h00, Error! Start, h84 [ h42 | WR ], Error! Start, h84 [ h42 | WR ], hFD, Restart, h85 [ h42 | RD ], h00 NAK, Error! Restart, h84 [ h42 | WR ], Restart, h84 [ h42 | WR ],

WIth ubxlib handling i2c initialization: Restart, h84 [ h42 | WR ], hFD, Restart, h85 [ h42 | RD ], h00, h00 NAK, Stop Start, h84 [ h42 | WR ], hFD, Restart, h85 [ h42 | RD ], h00, h00 NAK, Stop Start, h84 [ h42 | WR ], hFD, Restart, h85 [ h42 | RD ], h00, h00 NAK, Stop Start, h84 [ h42 | WR ], hFD, Restart, h85 [ h42 | RD ], h00, h00 NAK, Stop Start, h84 [ h42 | WR ], hFD, Restart, h85 [ h42 | RD ], h00, h00 NAK, Stop Start, h84 [ h42 | WR ], hFD, Restart, h85 [ h42 | RD ], h00, h00 NAK, Stop Start, h84 [ h42 | WR ], hFD, Restart, h85 [ h42 | RD ], h00, h00 NAK, Stop Start, h84 [ h42 | WR ], hFD, Restart, h85 [ h42 | RD ], h00, h00 NAK, Stop Start, h84 [ h42 | WR ], hFD, Restart, h85 [ h42 | RD ], h00, h00 NAK, Stop Start, h84 [ h42 | WR ], hFD, Restart, h85 [ h42 | RD ], h00, h00 NAK, Stop Start, h84 [ h42 | WR ], hB5, h62, h0A, h06, h00, h00, h10, h3A, Stop Start, h84 [ h42 | WR ], hFD, Restart, h85 [ h42 | RD ], h00, h00 NAK, Stop Start, h84 [ h42 | WR ], hFD, Restart, h85 [ h42 | RD ], h00, h00 NAK, Stop Start, h84 [ h42 | WR ], hFD, Restart, h85 [ h42 | RD ], h00, h00 NAK, Stop Start, h84 [ h42 | WR ], hFD, Restart, h85 [ h42 | RD ], h00, h00 NAK, Stop Start, h84 [ h42 | WR ], hFD, Restart, h85 [ h42 | RD ], h00, h00 NAK, Stop Start, h84 [ h42 | WR ], hFD, Restart, h85 [ h42 | RD ], h00, h00 NAK, Stop Start, h84 [ h42 | WR ], hFD, Restart, h85 [ h42 | RD ], h00, h00 NAK, Stop Start, h84 [ h42 | WR ], hFD, Restart, h85 [ h42 | RD ], h00, h00 NAK, Stop Start, h84 [ h42 | WR ], hFD, Restart, h85 [ h42 | RD ], h00, h00 NAK, Stop Start, h84 [ h42 | WR ], hFD, Restart, h85 [ h42 | RD ], h00, h00 NAK, Stop Start, h84 [ h42 | WR ], hFD, Restart, h85 [ h42 | RD ], h00, h00 NAK, Stop Start, h84 [ h42 | WR ], hFD, Restart, h85 [ h42 | RD ], h00, h00 NAK, Stop Start, h84 [ h42 | WR ], hFD, Restart, h85 [ h42 | RD ], h00, h00 NAK, Stop Start, h84 [ h42 | WR ], hFD, Restart, h85 [ h42 | RD ], h00, h00 NAK, Stop Start, h84 [ h42 | WR ], hFD, Restart, h85 [ h42 | RD ], h00, h00 NAK, Stop Start, h84 [ h42 | WR ], hFD, Restart, h85 [ h42 | RD ], h00, h00 NAK, Stop Start, h84 [ h42 | WR ], hFD, Restart, h85 [ h42 | RD ], h00, h00 NAK, Stop Start, h84 [ h42 | WR ], hFD, Restart, h85 [ h42 | RD ], h00, h00 NAK, Stop Start, h84 [ h42 | WR ], hFD, Restart, h85 [ h42 | RD ], h00, h00 NAK, Stop Start, h84 [ h42 | WR ], hFD, Restart, h85 [ h42 | RD ], h00, h00 NAK, Stop Start, h84 [ h42 | WR ], hFD, Restart, h85 [ h42 | RD ], h00, h00 NAK, Stop Start, h84 [ h42 | WR ], hFD, Restart, h85 [ h42 | RD ], h00, h00 NAK, Stop Start, h84 [ h42 | WR ], hFD, Restart, h85 [ h42 | RD ], h00, h00 NAK, Stop Start, h84 [ h42 | WR ], hFD, Restart, h85 [ h42 | RD ], h00, h00 NAK, Stop Start, h84 [ h42 | WR ], hFD, Restart, h85 [ h42 | RD ], h00, h00 NAK, Stop Start, h84 [ h42 | WR ], hFD, Restart, h85 [ h42 | RD ], h00, h00 NAK, Stop Start, h84 [ h42 | WR ], hFD, Restart, h85 [ h42 | RD ], h00, h00 NAK, Stop Start, h84 [ h42 | WR ], hFD, Restart, h85 [ h42 | RD ], h00, h00 NAK, Stop Start, h84 [ h42 | WR ], hFD, Restart, h85 [ h42 | RD ], h04, hCF NAK, Stop Start, h85 [ h42 | RD ], h24, h47, h4E, h52, h4D, h43, h2C, h31, h34, h30, h36, h31, h31, h2E, h30, h30, h2C, h41, h2C, h35, h30, h32, h36, h2E, h39, h37, h32, h38, h33, h2C, h4E, h2C, h30, h30, h33, h35, h36, h2E, h35, h37, h33, h33, h38, h2C, h45, h2C, h30, h2E, h30, h36, h38, h2C, h2C, h30, h32, h30, h32, h32, h34, h2C, h2C, h2C, h44, h2C, h56, h2A, h31, h36, h0D, h0A, h24, h47, h4E, h56, h54, h47, h2C, h2C, h54, h2C, h2C, h4D, h2C, h30, h2E, h30, h36, h38, h2C, h4E, h2C, h30, h2E, h31, h32, h36, h2C, h4B, h2C, h44, h2A, h33, h33, h0D, h0A, h24, h47, h4E, h47, h47, h41, h2C, h31, h34, h30, h36, h31, h31, h2E, h30, h30, h2C, h35, h30, h32, h36, h2E, h39, h37, h32, h38, h33, h2C, h4E, h2C, h30, h30, h33, h35, h36, h2E, h35, h37, h33, h33, h38, h2C, h45, h2C, h32, h2C, h31, h32, h2C, h31, h2E, h38, h31, h2C, h34, h35, h2E, h31, h2C, h4D, h2C, h34, h36, h2E, h31, h2C, h4D, h2C, h2C, h30, h30, h30, h30, h2A, h37, h36, h0D, h0A, h24, h47, h4E, h47, h53, h41, h2C, h41, h2C, h33, h2C, h32, h38, h2C, h31, h32, h2C, h32, h30, h2C, h31, h31, h2C, h32, h35, h2C, h32, h39, h2C, h2C, h2C, h2C, h2C, h2C, h2C, h32, h2E, h36, h32, h2C, h31, h2E, h38, h31, h2C, h31, h2E, h38, h39, h2C, h31, h2A, h30, h38, h0D, h0A, h24, h47, h4E, h47, h53, h41, h2C, h41, h2C, h33, h2C, h38, h32, h2C, h37, h39, h2C NAK, Stop Start, h84 [ h42 | WR ], hFD, Restart, h85 [ h42 | RD ], h03, hCF NAK, Stop Start, h85 [ h42 | RD ], h38, h31, h2C, h2C, h2C, h2C, h2C, h2C, h2C, h2C, h2C, h2C, h32, h2E, h36, h32, h2C, h31, h2E, h38, h31, h2C, h31, h2E, h38, h39, h2C, h32, h2A, h30, h31, h0D, h0A, h24, h47, h4E, h47, h53, h41, h2C, h41, h2C, h33, h2C, h33, h33, h2C, h33, h31, h2C, h31, h30, h2C, h2C, h2C, h2C, h2C, h2C, h2C, h2C, h2C, h2C, h32, h2E, h36, h32, h2C, h31, h2E, h38, h31, h2C, h31, h2E, h38, h39, h2C, h33, h2A, h30, h45, h0D, h0A, h24, h47, h4E, h47, h53, h41, h2C, h41, h2C, h33, h2C, h30, h38, h2C, h33, h35, h2C, h31, h33, h2C, h31, h32, h2C, h32, h36, h2C, h2C, h2C, h2C, h2C, h2C, h2C, h2C, h32, h2E, h36, h32, h2C, h31, h2E, h38, h31, h2C, h31, h2E, h38, h39, h2C, h34, h2A, h30, h31, h0D, h0A, h24, h47, h50, h47, h53, h56, h2C, h34, h2C, h31, h2C, h31, h34, h2C, h30, h34, h2C, h30, h35, h2C, h33, h34, h30, h2C, h2C, h30, h36, h2C, h30, h32, h2C, h30, h32, h33, h2C, h2C, h31, h31, h2C, h32, h35, h2C, h30, h34, h37, h2C, h31, h32, h2C, h31, h32, h2C, h32, h37, h2C, h30, h39, h34, h2C, h32, h34, h2C, h31, h2A, h36, h44, h0D, h0A, h24, h47, h50, h47, h53, h56, h2C, h34, h2C, h32, h2C, h31, h34, h2C, h31, h38, h2C, h30, h38, h2C, h31, h37, h35, h2C, h2C, h32, h30, h2C, h30, h38, h2C, h30, h37, h33, h2C, h31, h35, h2C, h32, h35, h2C, h36, h32, h2C, h30, h39, h33, h2C, h33, h31, h2C NAK, Stop Start, h84 [ h42 | WR ], hFD, Restart, h85 [ h42 | RD ], h02, hCF NAK, Stop Start, h85 [ h42 | RD ], h32, h36, h2C, h31, h37, h2C, h32, h38, h35, h2C, h2C, h31, h2A, h36, h39, h0D, h0A, h24, h47, h50, h47, h53, h56, h2C, h34, h2C, h33, h2C, h31, h34, h2C, h32, h38, h2C, h36, h33, h2C, h32, h37, h30, h2C, h31, h39, h2C, h32, h39, h2C, h37, h36, h2C, h31, h39, h35, h2C, h31, h37, h2C, h33, h31, h2C, h34, h32, h2C, h33, h30, h32, h2C, h32, h30, h2C, h33, h32, h2C, h31, h32, h2C, h32, h32, h36, h2C, h2C, h31, h2A, h36, h36, h0D, h0A, h24, h47, h50, h47, h53, h56, h2C, h34, h2C, h34, h2C, h31, h34, h2C, h33, h36, h2C, h32, h39, h2C, h31, h35, h35, h2C, h33, h31, h2C, h34, h39, h2C, h33, h32, h2C, h31, h37, h39, h2C, h33, h31, h2C, h31, h2A, h36, h44, h0D, h0A, h24, h47, h4C, h47, h53, h56, h2C, h33, h2C, h31, h2C, h31, h30, h2C, h37, h30, h2C, h30, h35, h2C, h32, h36, h33, h2C, h32, h37, h2C, h37, h31, h2C, h31, h38, h2C, h33, h30, h39, h2C, h2C, h37, h32, h2C, h31, h31, h2C, h33, h35, h36, h2C, h2C, h37, h33, h2C, h31, h37, h2C, h33, h30, h37, h2C, h2C, h31, h2A, h37, h44, h0D, h0A, h24, h47, h4C, h47, h53, h56, h2C, h33, h2C, h32, h2C, h31, h30, h2C, h37, h39, h2C, h34, h36, h2C, h31, h31, h31, h2C, h33, h31, h2C, h38, h30, h2C, h37, h31, h2C, h33, h33, h34, h2C, h2C, h38, h31, h2C, h35, h38, h2C, h30, h35, h38, h2C, h32, h36, h2C, h38, h32, h2C, h35, h34, h2C NAK, Stop Start, h84 [ h42 | WR ], hFD, Restart, h85 [ h42 | RD ], h01, hCF NAK, Stop Start, h85 [ h42 | RD ], h31, h36, h36, h2C, h33, h36, h2C, h31, h2A, h37, h46, h0D, h0A, h24, h47, h4C, h47, h53, h56, h2C, h33, h2C, h33, h2C, h31, h30, h2C, h38, h33, h2C, h31, h34, h2C, h31, h38, h39, h2C, h2C, h38, h38, h2C, h31, h30, h2C, h30, h32, h38, h2C, h2C, h31, h2A, h37, h43, h0D, h0A, h24, h47, h41, h47, h53, h56, h2C, h33, h2C, h31, h2C, h31, h31, h2C, h30, h33, h2C, h32, h34, h2C, h33, h30, h30, h2C, h2C, h30, h35, h2C, h32, h32, h2C, h32, h34, h36, h2C, h2C, h30, h38, h2C, h30, h33, h2C, h33, h34, h35, h2C, h2C, h31, h30, h2C, h32, h32, h2C, h31, h36, h32, h2C, h32, h38, h2C, h37, h2A, h37, h35, h0D, h0A, h24, h47, h41, h47, h53, h56, h2C, h33, h2C, h32, h2C, h31, h31, h2C, h31, h31, h2C, h30, h32, h2C, h31, h38, h30, h2C, h2C, h31, h32, h2C, h33, h37, h2C, h31, h34, h30, h2C, h2C, h32, h34, h2C, h38, h31, h2C, h33, h31, h36, h2C, h2C, h32, h35, h2C, h32, h37, h2C, h32, h38, h33, h2C, h2C, h37, h2A, h37, h42, h0D, h0A, h24, h47, h41, h47, h53, h56, h2C, h33, h2C, h33, h2C, h31, h31, h2C, h32, h36, h2C, h30, h39, h2C, h30, h32, h37, h2C, h2C, h33, h31, h2C, h34, h33, h2C, h30, h39, h34, h2C, h32, h36, h2C, h33, h33, h2C, h34, h30, h2C, h30, h36, h36, h2C, h33, h32, h2C, h37, h2A, h34, h32, h0D, h0A, h24, h47, h42, h47, h53, h56, h2C, h33, h2C, h31, h2C, h30, h39, h2C NAK, Stop Start, h84 [ h42 | WR ], hFD, Restart, h85 [ h42 | RD ], h00, hCF NAK, Stop Start, h85 [ h42 | RD ], h30, h35, h2C, h31, h32, h2C, h31, h31, h39, h2C, h2C, h30, h38, h2C, h32, h32, h2C, h30, h36, h39, h2C, h31, h36, h2C, h31, h30, h2C, h30, h30, h2C, h30, h37, h32, h2C, h2C, h31, h32, h2C, h35, h32, h2C, h31, h38, h31, h2C, h32, h36, h2C, h31, h2A, h37, h45, h0D, h0A, h24, h47, h42, h47, h53, h56, h2C, h33, h2C, h32, h2C, h30, h39, h2C, h31, h33, h2C, h32, h30, h2C, h30, h38, h34, h2C, h31, h33, h2C, h32, h34, h2C, h37, h38, h2C, h31, h35, h39, h2C, h2C, h32, h35, h2C, h34, h31, h2C, h33, h30, h30, h2C, h2C, h32, h36, h2C, h32, h37, h2C, h31, h33, h31, h2C, h33, h30, h2C, h31, h2A, h37, h34, h0D, h0A, h24, h47, h42, h47, h53, h56, h2C, h33, h2C, h33, h2C, h30, h39, h2C, h33, h35, h2C, h34, h31, h2C, h30, h35, h37, h2C, h32, h34, h2C, h31, h2A, h34, h38, h0D, h0A, h24, h47, h4E, h47, h4C, h4C, h2C, h35, h30, h32, h36, h2E, h39, h37, h32, h38, h33, h2C, h4E, h2C, h30, h30, h33, h35, h36, h2E, h35, h37, h33, h33, h38, h2C, h45, h2C, h31, h34, h30, h36, h31, h31, h2E, h30, h30, h2C, h41, h2C, h44, h2A, h37, h44, h0D, h0A NAK, Stop Start, h84 [ h42 | WR ], hFD, Restart, h85 [ h42 | RD ], h00, h00 NAK, Stop Start, h84 [ h42 | WR ], hFD, Restart, h85 [ h42 | RD ], h00, h00 NAK, Stop Start, h84 [ h42 | WR ], hFD, Restart, h85 [ h42 | RD ], h00, h00 NAK, Stop Start, h84 [ h42 | WR ], hFD, Restart, h85 [ h42 | RD ], h00, h00 NAK, Stop Start, h84 [ h42 | WR ], hFD, Restart, h85 [ h42 | RD ], h00, h00 NAK, Stop Start, h84 [ h42 | WR ], hFD, Restart, h85 [ h42 | RD ], h00, h00 NAK, Stop Start, h84 [ h42 | WR ], hFD, Restart, h85 [ h42 | RD ], h00, h00 NAK, Stop Start, h84 [ h42 | WR ], hFD, Restart, h85 [ h42 | RD ], h00, h00 NAK, Stop Start, h84 [ h42 | WR ], hFD, Restart, h85 [ h42 | RD ], h00, h00 NAK, Stop Start, h84 [ h42 | WR ], hFD, Restart, h85 [ h42 | RD ], h00, h00 NAK, Stop Start, h84 [ h42 | WR ], hFD, Restart, h85 [ h42 | RD ], h00, h00 NAK, Stop Start, h84 [ h42 | WR ], hFD, Restart, h85 [ h42 | RD ], h00, h00 NAK, Stop Start, h84 [ h42 | WR ], hFD, Restart, h85 [ h42 | RD ], h00, h00 NAK, Stop Start, h84 [ h42 | WR ], hFD, Restart, h85 [ h42 | RD ], h00, h00 NAK, Stop Start, h84 [ h42 | WR ], hFD, Restart, h85 [ h42 | RD ], h00, h00 NAK, Stop Start, h84 [ h42 | WR ], hFD, Restart, h85 [ h42 | RD ], h00, h00 NAK, Stop Start, h84 [ h42 | WR ], hFD, Restart, h85 [ h42 | RD ], h00, h00 NAK, Stop Start, h84 [ h42 | WR ], hFD, Restart, h85 [ h42 | RD ], h00, h00 NAK, Stop Start, h84 [ h42 | WR ], hFD, Restart, h85 [ h42 | RD ], h00, h00 NAK, Stop Start, h84 [ h42 | WR ], hFD, Restart, h85 [ h42 | RD ], h00, h80 NAK, Stop Start, h85 [ h42 | RD ], hB5, h62, h0A, h06, h78, h00, h0D, h00, h00, h00, h00, h00, h00, h00, h00, h00, h00, h00, h00, h00, h00, h00, h00, h00, h00, h00, h00, h00, h00, h00, h00, h00, h00, h00, h00, h00, h00, h00, h00, h00, h00, h00, h00, h00, h00, h00, h00, h00, h00, h00, h00, h00, h00, h00, h00, h00, h00, h00, h00, h00, h00, h00, h00, h00, h00, h00, h00, h00, h00, h00, h00, h00, h00, h00, h00, h00, h00, h00, h00, h00, h00, h00, h00, h00, h00, h00, h00, h00, h00, h00, h00, h00, h00, h00, h00, h00, h00, h00, h00, h00, h00, h00, h00, h00, h00, h00, h00, h00, h00, h00, h00, h00, h00, h00, h00, h00, h00, h00, h00, h00, h00, h00, h00, h00, h00, h00, h95, h02 NAK, Stop Start, h84 [ h42 | WR ], hFD, Restart, h85 [ h42 | RD ], h00, h00 NAK, Stop Start, h84 [ h42 | WR ], hB5, h62, h06, h04, h04, h00, h00, h00, h09, h00, h17, h76, Stop Start, h84 [ h42 | WR ], hFD, Restart, h85 [ h42 | RD ], h00, h00 NAK, Stop Start, h84 [ h42 | WR ], hFD, Restart, h85 [ h42 | RD ], h00, h00 NAK, Stop Start, h84 [ h42 | WR ], hFD, Restart, h85 [ h42 | RD ], h00, h00 NAK, Stop Start, h84 [ h42 | WR ], hFD, Restart, h85 [ h42 | RD ], h00, h00 NAK, Stop Start, h84 [ h42 | WR ], hFD, Restart, h85 [ h42 | RD ], h00, h00 NAK, Stop Start, h84 [ h42 | WR ], hFD, Restart, h85 [ h42 | RD ], h00, h00 NAK, Stop Start, h84 [ h42 | WR ], hFD, Restart, h85 [ h42 | RD ], h00, h00 NAK, Stop Start, h84 [ h42 | WR ], hFD, Restart, h85 [ h42 | RD ], h00, h00 NAK, Stop Start, h84 [ h42 | WR ], hFD, Restart, h85 [ h42 | RD ], h00, h00 NAK, Stop Start, h84 [ h42 | WR ], hFD, Restart, h85 [ h42 | RD ], h00, h00 NAK, Stop Start, h84 [ h42 | WR ], hB5, h62, h0A, h06, h00, h00, h10, h3A, Stop Start, h84 [ h42 | WR ], hFD, Restart, h85 [ h42 | RD ], h00, h00 NAK, Stop Start, h84 [ h42 | WR ], hFD, Restart, h85 [ h42 | RD ], h00, h00 NAK, Stop Start, h84 [ h42 | WR ], hFD, Restart, h85 [ h42 | RD ], h00, h00 NAK, Stop Start, h84 [ h42 | WR ], hFD, Restart, h85 [ h42 | RD ], h00, h00 NAK, Stop Start, h84 [ h42 | WR ], hFD, Restart, h85 [ h42 | RD ], h00, h00 NAK, Stop Start, h84 [ h42 | WR ], hFD, Restart, h85 [ h42 | RD ], h00, h00 NAK, Stop Start, h84 [ h42 | WR ], hFD, Restart, h85 [ h42 | RD ], h00, h00 NAK, Stop Start, h84 [ h42 | WR ], hFD, Restart, h85 [ h42 | RD ], h00, h00 NAK, Stop Start, h84 [ h42 | WR ], hFD, Restart, h85 [ h42 | RD ], h00, h00 NAK, Stop Start, h84 [ h42 | WR ], hFD, Restart, h85 [ h42 | RD ], h00, h00 NAK, Stop Start, h84 [ h42 | WR ], hFD, Restart, h85 [ h42 | RD ], h00, h00 NAK, Stop Start, h84 [ h42 | WR ], hFD, Restart, h85 [ h42 | RD ], h00, h00 NAK, Stop Start, h84 [ h42 | WR ], hFD, Restart, h85 [ h42 | RD ], h00, h00 NAK, Stop Start, h84 [ h42 | WR ], hFD, Restart, h85 [ h42 | RD ], h00, h00 NAK, Stop Start, h84 [ h42 | WR ], hFD, Restart, h85 [ h42 | RD ], h00, h00 NAK, Stop Start, h84 [ h42 | WR ], hFD, Restart, h85 [ h42 | RD ], h00, h00 NAK, Stop Start, h84 [ h42 | WR ], hFD, Restart, h85 [ h42 | RD ], h00, h00 NAK, Stop Start, h84 [ h42 | WR ], hFD, Restart, h85 [ h42 | RD ], h00, h00 NAK, Stop Start, h84 [ h42 | WR ], hFD, Restart, h85 [ h42 | RD ], h00, h00 NAK, Stop Start, h84 [ h42 | WR ], hFD, Restart, h85 [ h42 | RD ], h00, h00 NAK, Stop Start, h84 [ h42 | WR ], hFD, Restart, h85 [ h42 | RD ], h00, h00 NAK, Stop Start, h84 [ h42 | WR ], hFD, Restart, h85 [ h42 | RD ], h00, h00 NAK, Stop Start, h84 [ h42 | WR ], hFD, Restart, h85 [ h42 | RD ], h00, h00 NAK, Stop Start, h84 [ h42 | WR ], hFD, Restart, h85 [ h42 | RD ], h00, h00 NAK, Stop Start, h84 [ h42 | WR ], hFD, Restart, h85 [ h42 | RD ], h00, h00 NAK, Stop Start, h84 [ h42 | WR ], hFD, Restart, h85 [ h42 | RD ], h00, h00 NAK, Stop Start, h84 [ h42 | WR ], hFD, Restart, h85 [ h42 | RD ], h00, h00 NAK, Stop Start, h84 [ h42 | WR ], hFD, Restart, h85 [ h42 | RD ], h00, h00 NAK, Stop Start, h84 [ h42 | WR ], hFD, Restart, h85 [ h42 | RD ], h00, h00 NAK, Stop Start, h84 [ h42 | WR ], hFD, Restart, h85 [ h42 | RD ], h00, h00 NAK, Stop Start, h84 [ h42 | WR ], hFD, Restart, h85 [ h42 | RD ], h00, h00 NAK, Stop Start, h84 [ h42 | WR ], hFD, Restart, h85 [ h42 | RD ], h00, h00 NAK, Stop Start, h84 [ h42 | WR ], hFD, Restart, h85 [ h42 | RD ], h00, h00 NAK, Stop Start, h84 [ h42 | WR ], hFD, Restart, h85 [ h42 | RD ], h00, h00 NAK, Stop Start, h84 [ h42 | WR ], hFD, Restart, h85 [ h42 | RD ], h00, h00 NAK, Stop Start, h84 [ h42 | WR ], hFD, Restart, h85 [ h42 | RD ], h00, h00 NAK, Stop Start, h84 [ h42 | WR ], hFD, Restart, h85 [ h42 | RD ], h00, h00 NAK, Stop Start, h84 [ h42 | WR ], hFD, Restart, h85 [ h42 | RD ], h00, h00 NAK, Stop Start, h84 [ h42 | WR ], hFD, Restart, h85 [ h42 | RD ], h00, h00 NAK, Stop Start, h84 [ h42 | WR ], hFD, Restart, h85 [ h42 | RD ], h00, h00 NAK, Stop Start, h84 [ h42 | WR ], hFD, Restart, h85 [ h42 | RD ], h00, h00 NAK, Stop Start, h84 [ h42 | WR ], hFD, Restart, h85 [ h42 | RD ], h00, h00 NAK, Stop Start, h84 [ h42 | WR ], hFD, Restart, h85 [ h42 | RD ], h00, h00 NAK, Stop Start, h84 [ h42 | WR ], hFD, Restart, h85 [ h42 | RD ], h00, h00 NAK, Stop Start, h84 [ h42 | WR ], hFD, Restart, h85 [ h42 | RD ], h00, h00 NAK, Stop Start, h84 [ h42 | WR ], hFD, Restart, h85 [ h42 | RD ], h00, h00 NAK, Stop Start, h84 [ h42 | WR ], hFD, Restart, h85 [ h42 | RD ], h00, h00 NAK, Stop Start, h84 [ h42 | WR ], hFD, Restart, h85 [ h42 | RD ], h00, h00 NAK, Stop Start, h84 [ h42 | WR ], hFD, Restart, h85 [ h42 | RD ], h00, h00 NAK, Stop Start, h84 [ h42 | WR ], hFD, Restart, h85 [ h42 | RD ], h00, h00 NAK, Stop Start, h84 [ h42 | WR ], hFD, Restart, h85 [ h42 | RD ], h00, h00 NAK, Stop Start, h84 [ h42 | WR ], hFD, Restart, h85 [ h42 | RD ], h00, h00 NAK, Stop Start, h84 [ h42 | WR ], hFD, Restart, h85 [ h42 | RD ], h00, h00 NAK, Stop Start, h84 [ h42 | WR ], hFD, Restart, h85 [ h42 | RD ], h00, h00 NAK, Stop Start, h84 [ h42 | WR ], hFD, Restart, h85 [ h42 | RD ], h00, h00 NAK, Stop Start, h84 [ h42 | WR ], hFD, Restart, h85 [ h42 | RD ], h04, hCF NAK, Stop Start, h85 [ h42 | RD ], h24, h47, h4E, h52, h4D, h43, h2C, h31, h34, h30, h36, h31, h32, h2E, h30, h30, h2C, h41, h2C, h35, h30, h32, h36, h2E, h39, h37, h32, h38, h33, h2C, h4E, h2C, h30, h30, h33, h35, h36, h2E, h35, h37, h33, h34, h31, h2C, h45, h2C, h30, h2E, h30, h38, h33, h2C, h2C, h30, h32, h30, h32, h32, h34, h2C, h2C, h2C, h44, h2C, h56, h2A, h31, h45, h0D, h0A, h24, h47, h4E, h56, h54, h47, h2C, h2C, h54, h2C, h2C, h4D, h2C, h30, h2E, h30, h38, h33, h2C, h4E, h2C, h30, h2E, h31, h35, h34, h2C, h4B, h2C, h44, h2A, h33, h33, h0D, h0A, h24, h47, h4E, h47, h47, h41, h2C, h31, h34, h30, h36, h31, h32, h2E, h30, h30, h2C, h35, h30, h32, h36, h2E, h39, h37, h32, h38, h33, h2C, h4E, h2C, h30, h30, h33, h35, h36, h2E, h35, h37, h33, h34, h31, h2C, h45, h2C, h32, h2C, h31, h32, h2C, h31, h2E, h38, h31, h2C, h34, h35, h2E, h31, h2C, h4D, h2C, h34, h36, h2E, h31, h2C, h4D, h2C, h2C, h30, h30, h30, h30, h2A, h37, h42, h0D, h0A, h24, h47, h4E, h47, h53, h41, h2C, h41, h2C, h33, h2C, h32, h38, h2C, h31, h32, h2C, h32, h30, h2C, h31, h31, h2C, h32, h35, h2C, h32, h39, h2C, h2C, h2C, h2C, h2C, h2C, h2C, h32, h2E, h36, h32, h2C, h31, h2E, h38, h31, h2C, h31, h2E, h38, h39, h2C, h31, h2A, h30, h38, h0D, h0A, h24, h47, h4E, h47, h53, h41, h2C, h41, h2C, h33, h2C, h38, h32, h2C, h37, h39, h2C NAK, Stop Start, h84 [ h42 | WR ], hFD, Restart, h85 [ h42 | RD ], h03, hCF NAK, Stop Start, h85 [ h42 | RD ], h38, h31, h2C, h2C, h2C, h2C, h2C, h2C, h2C, h2C, h2C, h2C, h32, h2E, h36, h32, h2C, h31, h2E, h38, h31, h2C, h31, h2E, h38, h39, h2C, h32, h2A, h30, h31, h0D, h0A, h24, h47, h4E, h47, h53, h41, h2C, h41, h2C, h33, h2C, h33, h33, h2C, h33, h31, h2C, h31, h30, h2C, h2C, h2C, h2C, h2C, h2C, h2C, h2C, h2C, h2C, h32, h2E, h36, h32, h2C, h31, h2E, h38, h31, h2C, h31, h2E, h38, h39, h2C, h33, h2A, h30, h45, h0D, h0A, h24, h47, h4E, h47, h53, h41, h2C, h41, h2C, h33, h2C, h30, h38, h2C, h33, h35, h2C, h31, h33, h2C, h31, h32, h2C, h32, h36, h2C, h2C, h2C, h2C, h2C, h2C, h2C, h2C, h32, h2E, h36, h32, h2C, h31, h2E, h38, h31, h2C, h31, h2E, h38, h39, h2C, h34, h2A, h30, h31, h0D, h0A, h24, h47, h50, h47, h53, h56, h2C, h34, h2C, h31, h2C, h31, h34, h2C, h30, h34, h2C, h30, h35, h2C, h33, h34, h30, h2C, h2C, h30, h36, h2C, h30, h32, h2C, h30, h32, h33, h2C, h2C, h31, h31, h2C, h32, h35, h2C, h30, h34, h37, h2C, h31, h31, h2C, h31, h32, h2C, h32, h37, h2C, h30, h39, h34, h2C, h32, h33, h2C, h31, h2A, h36, h39, h0D, h0A, h24, h47, h50, h47, h53, h56, h2C, h34, h2C, h32, h2C, h31, h34, h2C, h31, h38, h2C, h30, h38, h2C, h31, h37, h35, h2C, h2C, h32, h30, h2C, h30, h38, h2C, h30, h37, h33, h2C, h31, h34, h2C, h32, h35, h2C, h36, h32, h2C, h30, h39, h33, h2C, h33, h31, h2C NAK, Stop Start, h84 [ h42 | WR ], hFD, Restart, h85 [ h42 | RD ], h02, hCF NAK, Stop Start, h85 [ h42 | RD ], h32, h36, h2C, h31, h37, h2C, h32, h38, h35, h2C, h2C, h31, h2A, h36, h38, h0D, h0A, h24, h47, h50, h47, h53, h56, h2C, h34, h2C, h33, h2C, h31, h34, h2C, h32, h38, h2C, h36, h33, h2C, h32, h37, h30, h2C, h31, h39, h2C, h32, h39, h2C, h37, h36, h2C, h31, h39, h35, h2C, h31, h36, h2C, h33, h31, h2C, h34, h32, h2C, h33, h30, h32, h2C, h31, h39, h2C, h33, h32, h2C, h31, h32, h2C, h32, h32, h36, h2C, h2C, h31, h2A, h36, h44, h0D, h0A, h24, h47, h50, h47, h53, h56, h2C, h34, h2C, h34, h2C, h31, h34, h2C, h33, h36, h2C, h32, h39, h2C, h31, h35, h35, h2C, h33, h30, h2C, h34, h39, h2C, h33, h32, h2C, h31, h37, h39, h2C, h33, h30, h2C, h31, h2A, h36, h44, h0D, h0A, h24, h47, h4C, h47, h53, h56, h2C, h33, h2C, h31, h2C, h31, h30, h2C, h37, h30, h2C, h30, h35, h2C, h32, h36, h33, h2C, h32, h36, h2C, h37, h31, h2C, h31, h38, h2C, h33, h30, h39, h2C, h2C, h37, h32, h2C, h31, h31, h2C, h33, h35, h36, h2C, h2C, h37, h33, h2C, h31, h37, h2C, h33, h30, h37, h2C, h2C, h31, h2A, h37, h43, h0D, h0A, h24, h47, h4C, h47, h53, h56, h2C, h33, h2C, h32, h2C, h31, h30, h2C, h37, h39, h2C, h34, h36, h2C, h31, h31, h31, h2C, h33, h30, h2C, h38, h30, h2C, h37, h31, h2C, h33, h33, h34, h2C, h2C, h38, h31, h2C, h35, h38, h2C, h30, h35, h38, h2C, h32, h35, h2C, h38, h32, h2C, h35, h34, h2C NAK, Stop Start, h84 [ h42 | WR ], hFD, Restart, h85 [ h42 | RD ], h01, hCF NAK, Stop Start, h85 [ h42 | RD ], h31, h36, h36, h2C, h33, h33, h2C, h31, h2A, h37, h38, h0D, h0A, h24, h47, h4C, h47, h53, h56, h2C, h33, h2C, h33, h2C, h31, h30, h2C, h38, h33, h2C, h31, h34, h2C, h31, h38, h39, h2C, h2C, h38, h38, h2C, h31, h30, h2C, h30, h32, h38, h2C, h2C, h31, h2A, h37, h43, h0D, h0A, h24, h47, h41, h47, h53, h56, h2C, h33, h2C, h31, h2C, h31, h31, h2C, h30, h33, h2C, h32, h34, h2C, h33, h30, h30, h2C, h2C, h30, h35, h2C, h32, h32, h2C, h32, h34, h36, h2C, h2C, h30, h38, h2C, h30, h33, h2C, h33, h34, h35, h2C, h2C, h31, h30, h2C, h32, h32, h2C, h31, h36, h32, h2C, h32, h38, h2C, h37, h2A, h37, h35, h0D, h0A, h24, h47, h41, h47, h53, h56, h2C, h33, h2C, h32, h2C, h31, h31, h2C, h31, h31, h2C, h30, h32, h2C, h31, h38, h30, h2C, h2C, h31, h32, h2C, h33, h37, h2C, h31, h34, h30, h2C, h2C, h32, h34, h2C, h38, h31, h2C, h33, h31, h36, h2C, h2C, h32, h35, h2C, h32, h37, h2C, h32, h38, h33, h2C, h2C, h37, h2A, h37, h42, h0D, h0A, h24, h47, h41, h47, h53, h56, h2C, h33, h2C, h33, h2C, h31, h31, h2C, h32, h36, h2C, h30, h39, h2C, h30, h32, h37, h2C, h2C, h33, h31, h2C, h34, h33, h2C, h30, h39, h34, h2C, h32, h37, h2C, h33, h33, h2C, h34, h30, h2C, h30, h36, h36, h2C, h33, h32, h2C, h37, h2A, h34, h33, h0D, h0A, h24, h47, h42, h47, h53, h56, h2C, h33, h2C, h31, h2C, h30, h39, h2C NAK, Stop Start, h84 [ h42 | WR ], hFD, Restart, h85 [ h42 | RD ], h00, hCF NAK, Stop Start, h85 [ h42 | RD ], h30, h35, h2C, h31, h32, h2C, h31, h31, h39, h2C, h2C, h30, h38, h2C, h32, h32, h2C, h30, h36, h39, h2C, h31, h37, h2C, h31, h30, h2C, h30, h30, h2C, h30, h37, h32, h2C, h2C, h31, h32, h2C, h35, h32, h2C, h31, h38, h31, h2C, h32, h37, h2C, h31, h2A, h37, h45, h0D, h0A, h24, h47, h42, h47, h53, h56, h2C, h33, h2C, h32, h2C, h30, h39, h2C, h31, h33, h2C, h32, h30, h2C, h30, h38, h34, h2C, h31, h34, h2C, h32, h34, h2C, h37, h38, h2C, h31, h35, h39, h2C, h2C, h32, h35, h2C, h34, h31, h2C, h33, h30, h30, h2C, h2C, h32, h36, h2C, h32, h37, h2C, h31, h33, h31, h2C, h33, h31, h2C, h31, h2A, h37, h32, h0D, h0A, h24, h47, h42, h47, h53, h56, h2C, h33, h2C, h33, h2C, h30, h39, h2C, h33, h35, h2C, h34, h31, h2C, h30, h35, h37, h2C, h32, h34, h2C, h31, h2A, h34, h38, h0D, h0A, h24, h47, h4E, h47, h4C, h4C, h2C, h35, h30, h32, h36, h2E, h39, h37, h32, h38, h33, h2C, h4E, h2C, h30, h30, h33, h35, h36, h2E, h35, h37, h33, h34, h31, h2C, h45, h2C, h31, h34, h30, h36, h31, h32, h2E, h30, h30, h2C, h41, h2C, h44, h2A, h37, h30, h0D, h0A NAK, Stop Start, h84 [ h42 | WR ], hFD, Restart, h85 [ h42 | RD ], h00, h00 NAK, Stop Start, h84 [ h42 | WR ], hFD, Restart, h85 [ h42 | RD ], h00, h00 NAK, Stop Start, h84 [ h42 | WR ], hFD, Restart, h85 [ h42 | RD ], h00, h00 NAK, Stop Start, h84 [ h42 | WR ], hFD, Restart, h85 [ h42 | RD ], h00, h00 NAK, Stop Start, h84 [ h42 | WR ], hFD, Restart, h85 [ h42 | RD ], h00, h00 NAK, Stop Start, h84 [ h42 | WR ], hFD, Restart, h85 [ h42 | RD ], h00, h00 NAK, Stop Start, h84 [ h42 | WR ], hFD, Restart, h85 [ h42 | RD ], h00, h00 NAK, Stop Start, h84 [ h42 | WR ], hFD, Restart, h85 [ h42 | RD ], h00, h00 NAK, Stop Start, h84 [ h42 | WR ], hFD, Restart, h85 [ h42 | RD ], h00, h00 NAK, Stop Start, h84 [ h42 | WR ], hFD, Restart, h85 [ h42 | RD ], h00, h00 NAK, Stop Start, h84 [ h42 | WR ], hFD, Restart, h85 [ h42 | RD ], h00, h00 NAK, Stop Start, h84 [ h42 | WR ], hFD, Restart, h85 [ h42 | RD ], h00, h00 NAK, Stop Start, h84 [ h42 | WR ], hFD, Restart, h85 [ h42 | RD ], h00, h00 NAK, Stop Start, h84 [ h42 | WR ], hFD, Restart, h85 [ h42 | RD ], h00, h00 NAK, Stop Start, h84 [ h42 | WR ], hFD, Restart, h85 [ h42 | RD ], h00, h00 NAK, Stop Start, h84 [ h42 | WR ], hFD, Restart, h85 [ h42 | RD ], h00, h00 NAK, Stop Start, h84 [ h42 | WR ], hFD, Restart, h85 [ h42 | RD ], h00, h00 NAK, Stop Start, h84 [ h42 | WR ], hFD, Restart, h85 [ h42 | RD ], h00, h00 NAK, Stop Start, h84 [ h42 | WR ], hFD, Restart, h85 [ h42 | RD ], h00, h00 NAK, Stop Start, h84 [ h42 | WR ], hFD, Restart, h85 [ h42 | RD ], h00, h80 NAK, Stop Start, h85 [ h42 | RD ], hB5, h62, h0A, h06, h78, h00, h0F, h00, h00, h00, h00, h00, h00, h00, h00, h00, h00, h00, h00, h00, h00, h00, h00, h00, h00, h00, h00, h00, h00, h00, h00, h00, h00, h00, h00, h00, h00, h00, h00, h00, h00, h00, h00, h00, h00, h00, h00, h00, h00, h00, h00, h00, h00, h00, h00, h00, h00, h00, h00, h00, h00, h00, h00, h00, h00, h00, h00, h00, h00, h00, h00, h00, h00, h00, h00, h00, h00, h00, h00, h00, h00, h00, h00, h00, h00, h00, h00, h00, h00, h00, h00, h00, h00, h00, h00, h00, h00, h00, h00, h00, h00, h00, h00, h00, h00, h00, h00, h00, h00, h00, h00, h00, h00, h00, h00, h00, h00, h00, h00, h00, h00, h00, h00, h00, h00, h00, h97, hF2 NAK, Stop Start, h84 [ h42 | WR ], hFD, Restart, h85 [ h42 | RD ], h00, h00 NAK, Stop

synologic commented 5 months ago

Looks like my calculation of the i2c_set_timeout value was wrong and not enough. It works perfectly after setting it to your value of 10 * 80000

Sorry for the confusion :)

RobMeades commented 5 months ago

Ah, is this the ESP32S? If so Espressif changed the way timing works on that chip but didn't document it...?

EDIT: this was the Github issue that resolved it: https://github.com/espressif/esp-idf/issues/11397#issuecomment-1551178754.

synologic commented 5 months ago

It's not an S but looks like 5ms timeout was not enough, i did not look at the NEO9 datasheet in depth, perhaps this is not enough, as my other peripherals work fine, hence the confusion :)

RobMeades commented 5 months ago

Got it, glad it is working for you now.

synologic commented 5 months ago

Thanks for your time, closing issue

synologic commented 5 months ago

@RobMeades Looking at this issue further, but I cannot seem to find any useful info in any of the M9 datasheets, whith the higher timeout set, is it normal that M9 responds in about 1 second ? This long response happens when there's no position solution - i simulate this with no antenna connected I see this on the I2C Analyser: image

Thanks

RobMeades commented 5 months ago

Section 5.3 of the NEO-M9N data-sheet would seem to be the reference for I2C timing, where the longest time value is the maximum of 20 ms clock stretching that the GNSS device might apply, so I wouldn't expect an I2C transaction to ever be longer than about that long.

Maybe it depends which timeout we are talking of? Not sure I follow the picture, but the default "epoch" of the GNSS device, i.e. the interval at which it will try to make a navigation solution, emitting, say, a UBX-NAV-PVT message, is 1 second, so you wouldn't normally get a position more frequently than that?

synologic commented 5 months ago

No need for faster location retrieval, however, the M9 shares the I2C bus with other devices which are read more often.

Put aside the fact that uGnssPosGet has a timeout of 240 seconds waiting for a proper nav solution from the device, i did bypass the timeout mechanism.

Long story short, out of cold start it takes some time for a proper solution, same happens when there's no sky visibility, antenna is disconnected, whatever.

Let's take UBX-NAV-STATUS for example, i send that with uGnssMsgSend and it takes 1s for the device to respond and uGnssMsgReceive to actually return from the call.

So it looks to me that at least both UBX-NAV-STATUS and UBX-NAV-PVT takes 1s, which makes sharing the bus a pain if i need other faster reads.

Either i'm doing something wrong (config, whateaver) or that's how the device works, it's my first time with these devices and i have no spare pins on the CPU to have the M9 on it's own bus.

What you're seeing in the picture above is exactly that, the command is sent:

Start, h84 [ h42 | WR ], hB5, h62, h01, h07, h00, h00, h04, h0D, Stop

and then it takes almost a second for the answer to be sent by the M9

Thanks

RobMeades commented 5 months ago

Usually the times when you are polling with a command and awaiting a response would be the exception rather than the rule; e.g. for configuration-type transactions. Once done, the device would be set up to emit something, e.g. the location, periodically.

Since you are using I2C the master still needs to pull the data, of course; if you're concerned about bus occupancy you could configure the GNSS device to set a TX_READY pin when there is stuff to read (see section 3.8.5 of the integration manual). We've not had a use case where such signals are required before, so their use is not integrated into the operation of ubxlib, but we could do that if it would help? Would need to think about how it would work.

synologic commented 5 months ago

How would this work ? Send a 0x1 0x03 message and don't read anything until TX_READY is asserted, and then send 0x01 0x03 message again and read back the answer immediately ?

RobMeades commented 5 months ago

I started to write a reply to this but realised that I still don't fully understand the core of the problem. I will set some HW up and have a sniff of the I2C lines myself but, how it is meant to work, is that, when this code is expecting to receive something it calls uGnssPrivateStreamFillRingBuffer() which calls uGnssPrivateStreamGetReceiveSize() which, for I2C, reads the two bytes from address 0xFD of the GNSS chip that indicate how much data the chip has to send, then reads that data.

So first there will be an I2C transaction which reads the amount of data that the GNSS chip already has in its output buffer, waiting to be sent, then there will be an I2C transaction to read that data. There should be no I2C transactions that take a whole second unless, for some reason the GNSS chip is indicating that it has data to send in its output buffer and then is not actually sending that data for some reason, or this code is somehow misinterpreting the length of the data.

We need to bear in mind that the GNSS chip will, by default, also be emitting data in NMEA format, so this code will be reading that and throwing it away (it has to because the data it wants is behind it); if you care about bus occupancy and your application has no interest in NMEA-format data (this code doesn't use it) then you may switch it off with:

uGnssCfgSetProtocolOut(devHandle, U_GNSS_PROTOCOL_NMEA, false);

I'll go find the right HW and my probe...

RobMeades commented 5 months ago

OK, I now have a MAX-M10S connected over I2C to an ESP32 and I'm calling uGnssPosGet() with no antenna connected.

The debug output from ubxlib looks like this forever:

2024-02-05 11:06:41 u_monitor_27 - U_GNSS: decoded UBX response 0x01 0x07: e8 c7 09 00 e5 07 03 07 00 0a 29 f0 ff ff ff ff 00 00 00 00 00 00 24 00 00 00 00 00 00 00 00 00 00 00 00 00 98 bd ff ff ff ff ff ff 00 cb 84 df 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 20 4e 00 00 80 a8 12 01 0f 27 00 00 5c 40 56 2f 00 00 00 00 00 00 00 00 [body 92 byte(s)].
2024-02-05 11:06:41 u_monitor_27 - U_GNSS: sent command b5 62 01 07 00 00 08 19.
2024-02-05 11:06:42 u_monitor_27 - U_GNSS: decoded UBX response 0x01 0x07: d0 cb 09 00 e5 07 03 07 00 0a 2a f0 ff ff ff ff 00 00 00 00 00 00 24 00 00 00 00 00 00 00 00 00 00 00 00 00 98 bd ff ff ff ff ff ff 00 cb 84 df 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 20 4e 00 00 80 a8 12 01 0f 27 00 00 5c 40 56 2f 00 00 00 00 00 00 00 00 [body 92 byte(s)].
2024-02-05 11:06:42 u_monitor_27 - U_GNSS: sent command b5 62 01 07 00 00 08 19.
2024-02-05 11:06:43 u_monitor_27 - U_GNSS: decoded UBX response 0x01 0x07: b8 cf 09 00 e5 07 03 07 00 0a 2b f0 ff ff ff ff 00 00 00 00 00 00 24 00 00 00 00 00 00 00 00 00 00 00 00 00 98 bd ff ff ff ff ff ff 00 cb 8
...

I've attached the Saleae capture (which you can read by downloading and installing their application if you wish). What you will see is patterns like this:

image

...i.e., since this is a blocking call and the underlying transport is I2C, there are polls to ask the GNSS device if it has any data to send and, about once a second, it does, hence the thicker parts in this zoomed-out trace. Zooming in to one of the polls, this is a "have you got any data to send? No I haven't" exchange:

image

...and this is a "have you got any data to send? Yes I have" exchange, i.e. at the start of one of the thicker blobs in the zoomed-out picture:

image

Between the polls, the I2C bus is not occupied, you should be able to do other stuff, provided i2c_master_cmd_begin() is thread-safe, which it says it is...?

EDIT: could the issue be that, when the GNSS code is trying to receive something, it tries really hard, resting for only 10ms between tries, which may be too short for another task of yours to get in? If this is the problem then a quick fix would be to make the duration of the wait a conditional compilation value that you could override? Or perhaps we could have two values (both as overridable conditional compilation flags), one for use when the I2C port is adopted and another for use when it is not, which would allow the former to be longer than the latter.

synologic commented 5 months ago

Your trace and my trace look similar, i just wonder if the polling actually holds the bus mutex or not, as esp-idf i2c_master* are thread safe and mutex enabled.

I did a bit of testing with having EXTINT pin assert when data is ready, i just can't figure out how to properly read that data over i2c, as if i send a receive message with 0x0107 it just polls the device for one second again before receiving the data (it's either that or i really screwed something up while testing this).

Long story short during that second needed for the polling, it's pretty much stopping my task.

Disabling NMEA and just sticking to UBX helps a very little, during data read, but the second it takes to actually receive the data is something i can't seem to find a good solution (yet) to get around.

RobMeades commented 5 months ago

Understood: as an experiment, could you try hacking the 10 ms here to be, say 50 ms or 100 ms and see if that helps?

If it does, we know that it is the I2C "do you have any data" poll rate that is getting in your way and I will make it properly configurable.

synologic commented 5 months ago

I'll try just to confirm, maybe in th is case, the workaround would be to have a separate task read the GNSS while another task holds the mutex and does all the dirty i2c jobs ... in the end, if it works, it works, just a matter of propagating a variable delay based on what's expected from the device, since not all messages take ~1s to get an answer

Keep you posted