-
Notifications
You must be signed in to change notification settings - Fork 85
checkUbloxI2C() should return 0xFF #26
Comments
I'm sorry, I don't understand this statement. I agree with you that we could make the function return if LSB is 0xFF but it makes me nervous. There are many instances where LSB might be 0xFF. I trust Ublox and their documentation but I'm not confident checking LSB is the right thing to do unless you're experiencing an error in a reading, What issue are you having? Can you provide code that demonstrates the issue? |
you can check it yourself. try to change rate to 5 hertz at ublox providing 5 messages per second and count messages with arduino per second |
You are not being a very helpful community member. I've implemented your 'fix' and there are still problems. I appreciate code. I appreciate working PRs most of all. The changes you recommend don't do much. I see a mixture of zero bytes and no byte returns from checkUbloxI2C(). It's curious but not very helpful. I can verify that the per second update is not happening on example 14 DebugOutput. I've pushed my changes so far (no release of library, just changes to master). I see less frequent I2C hangs when the I2C_POLLING_WAIT_MS is increased to 100ms. I need to dig deeper into the I2C packet traffic. There is very much something that is blocking the regular message updates. |
Ex 14 DebugOutput is still freezing at odd times. The increase of time between I2C checks to 100ms helps a little but doesn't fix the random freeze-for-a-few-seconds problem.
sorry when i am not be very helpful. i can only report what i see. i am not a big c++ coder. i did turn all other ubx messges and I have taken your code and used in arduino to parse 2-3 different ubx messages as below.. i use blackboard an f9 via i2c. i am able to parse all messages at the full rate of f9 (5/8 hertz). //Get the number of bytes available from the module
|
Got it. No worries. Thanks for looking into the problem. I agree there is an issue. I need to dig deeper and find out where the code is hanging. We should be able to hit 5Hz+ without glitches or timeouts. |
I am learning many things. First, it looks like we are reading I2C bytes when the module is not ready. For example, in the packets below there is a block of 7F FF FF bytes Here is the full packet in text:
Here is the start of the scan showing 92 bytes (0x64) available: Below is the read of a 32 byte chunk. The module clock stretches then presents 0x7F followed by 0xFFs. I assumed the following process:
The problem is the reading of blocks of 32. The module seems to be 'not ready' at certain times. The module seems to report 0x7F followed by 0xFF if it doesn't have data ready (even tho it said it did earlier). Later, on the same I2C transaction, the 'lost' bytes are made available. We're just asking for them when the module is not ready/available. The solution is to bail on a read if we come across a read of 0xFF. The datasheet alludes to this. But also in my logic scans I'm seeing a 0x7F in front of 0xFFs. I plan to bail on 0x7F as well. In the image above image the module was pinged for a final 4 byte read but responded with 0x7F 0xFF 0xFF 0xFF (two bytes are shown, the other two bytes went to CRCA and CRCB). Again, the module presented the correct four bytes later, but because it was not ready at this point in time the packet failed CRC. |
It's very interesting that the module is clock stretching just to then respond with 'I am not ready with data' in the form of 0x7F 0xFFs. Unfortunately it looks like there are legitimate 0x7Fs:
And singleton 0xFFs:
So we can't simply bail on a reading of 0x7F. But it does look like the problem is when 0x7F is the first byte in the read. If we incorrectly 'throw out' part of a valid packet the CRC will fail and we'll throw out the entire (valid) packet. This should be rare and acceptable. Definitely something I'll bring up with Ublox. |
We now throw out incoming transfers that start with 0x7F. This commit also increases the RAM footprint by 64 bytes so that we can correctly deal with the 92 byte response of the PVT inquiry.
After much work I think I've fixed the underlying problem, thanks in part to your recommendation. We now read successfully, and without CRC error at 10Hz with large PVT packets. Please see example 16 for a demo. Please test this new code and let me know if you still have issues. Thanks for bringing this issue to my attention. It was a big one, but I think the library is much better because of this fix. |
From the Ublox Manual:
If there is no data awaiting transmission from the receiver, then this register will deliver the value 0xFF.
line 205:
_i2cPort->requestFrom((uint8_t)_gpsI2Caddress, (uint8_t)2);
if (_i2cPort->available())
{
uint8_t msb = _i2cPort->read();
uint8_t lsb = _i2cPort->read();
bytesAvailable = (uint16_t)msb << 8 | lsb;
}
should we better check for 0xFF ??
if(lsb == 0xFF) return(false);
i think that removes the massive stocks of the lib..
The text was updated successfully, but these errors were encountered: