mirror of
https://github.com/betaflight/betaflight.git
synced 2025-07-17 21:35:44 +03:00
Successfully blackbox logged 46kB of flawless log data on the bench
Data read back using MSP
This commit is contained in:
parent
ebff1bdcd7
commit
f7d227a208
2 changed files with 16 additions and 7 deletions
|
@ -401,9 +401,17 @@ void flashfsWrite(const uint8_t *data, unsigned int len)
|
||||||
*/
|
*/
|
||||||
int flashfsRead(uint8_t *data, unsigned int len)
|
int flashfsRead(uint8_t *data, unsigned int len)
|
||||||
{
|
{
|
||||||
int result = m25p16_readBytes(tailAddress, data, len);
|
int bytesRead;
|
||||||
|
|
||||||
flashfsSetTailAddress(tailAddress + result);
|
// Did caller try to read past the end of the volume?
|
||||||
|
if (tailAddress + len > flashfsGetSize()) {
|
||||||
return result;
|
// Truncate their request
|
||||||
|
len = flashfsGetSize() - tailAddress;
|
||||||
|
}
|
||||||
|
|
||||||
|
bytesRead = m25p16_readBytes(tailAddress, data, len);
|
||||||
|
|
||||||
|
flashfsSetTailAddress(tailAddress + bytesRead);
|
||||||
|
|
||||||
|
return bytesRead;
|
||||||
}
|
}
|
||||||
|
|
|
@ -551,6 +551,7 @@ static void serializeDataflashReadReply(uint32_t address, uint8_t size)
|
||||||
enum { DATAFLASH_READ_REPLY_CHUNK_SIZE = 128 };
|
enum { DATAFLASH_READ_REPLY_CHUNK_SIZE = 128 };
|
||||||
|
|
||||||
uint8_t buffer[DATAFLASH_READ_REPLY_CHUNK_SIZE];
|
uint8_t buffer[DATAFLASH_READ_REPLY_CHUNK_SIZE];
|
||||||
|
int bytesRead;
|
||||||
|
|
||||||
if (size > DATAFLASH_READ_REPLY_CHUNK_SIZE) {
|
if (size > DATAFLASH_READ_REPLY_CHUNK_SIZE) {
|
||||||
size = DATAFLASH_READ_REPLY_CHUNK_SIZE;
|
size = DATAFLASH_READ_REPLY_CHUNK_SIZE;
|
||||||
|
@ -561,9 +562,10 @@ static void serializeDataflashReadReply(uint32_t address, uint8_t size)
|
||||||
serialize32(address);
|
serialize32(address);
|
||||||
|
|
||||||
flashfsSeekAbs(address);
|
flashfsSeekAbs(address);
|
||||||
flashfsRead(buffer, size);
|
// bytesRead will be lower than that requested if we reach end of volume
|
||||||
|
bytesRead = flashfsRead(buffer, size);
|
||||||
|
|
||||||
for (int i = 0; i < size; i++) {
|
for (int i = 0; i < bytesRead; i++) {
|
||||||
serialize8(buffer[i]);
|
serialize8(buffer[i]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1203,9 +1205,8 @@ static bool processOutCommand(uint8_t cmdMSP)
|
||||||
case MSP_DATAFLASH_READ:
|
case MSP_DATAFLASH_READ:
|
||||||
{
|
{
|
||||||
uint32_t readAddress = read32();
|
uint32_t readAddress = read32();
|
||||||
uint8_t readSize = read8();
|
|
||||||
|
|
||||||
serializeDataflashReadReply(readAddress, readSize);
|
serializeDataflashReadReply(readAddress, 128);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue