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
|
@ -401,9 +401,17 @@ void flashfsWrite(const 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()) {
|
||||
// Truncate their request
|
||||
len = flashfsGetSize() - tailAddress;
|
||||
}
|
||||
|
||||
return result;
|
||||
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 };
|
||||
|
||||
uint8_t buffer[DATAFLASH_READ_REPLY_CHUNK_SIZE];
|
||||
int bytesRead;
|
||||
|
||||
if (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);
|
||||
|
||||
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]);
|
||||
}
|
||||
}
|
||||
|
@ -1203,9 +1205,8 @@ static bool processOutCommand(uint8_t cmdMSP)
|
|||
case MSP_DATAFLASH_READ:
|
||||
{
|
||||
uint32_t readAddress = read32();
|
||||
uint8_t readSize = read8();
|
||||
|
||||
serializeDataflashReadReply(readAddress, readSize);
|
||||
serializeDataflashReadReply(readAddress, 128);
|
||||
}
|
||||
break;
|
||||
#endif
|
||||
|
|
Loading…
Reference in New Issue