From 6b83af622cc3646e4724f2fd13d6bc54115f46f2 Mon Sep 17 00:00:00 2001 From: vk7js <58905135+vk7js@users.noreply.github.com> Date: Mon, 4 Jul 2022 22:54:16 +1000 Subject: [PATCH] Corrected vpDataOffset, now use ftell to obtain file offset after reading in header and toc. Added better verification that the TOC was actually read. --- openrtx/src/core/voicePrompts.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/openrtx/src/core/voicePrompts.c b/openrtx/src/core/voicePrompts.c index 38a0db3c..19bd071b 100644 --- a/openrtx/src/core/voicePrompts.c +++ b/openrtx/src/core/voicePrompts.c @@ -114,13 +114,14 @@ void vpCacheInit(void) return; fseek(voice_prompt_file, 0L, SEEK_SET); - vpDataOffset += fread((void*)&header, sizeof(header), 1, voice_prompt_file); + fread((void*)&header, sizeof(header), 1, voice_prompt_file); if (vpCheckHeader((uint32_t*)&header)) { // read in the TOC. - vpDataOffset += fread((void*)&tableOfContents, sizeof(tableOfContents), 1, voice_prompt_file); - - vpDataIsLoaded = true; + fread((void*)&tableOfContents, sizeof(tableOfContents), 1, voice_prompt_file); + vpDataOffset = ftell(voice_prompt_file); + if(vpDataOffset == (sizeof(voicePromptsDataHeader_t) + sizeof(tableOfContents))) + vpDataIsLoaded = true; } if (vpDataIsLoaded) { // if the hash key is down, set vpLevel to high, if beep or less.