Skip to content
Snippets Groups Projects
Commit 30553f8a authored by Rob Swindell's avatar Rob Swindell :speech_balloon:
Browse files

Better log messages and yielding upon ReadFile(mailslot) error.

parent 715a2f16
No related branches found
No related tags found
1 merge request!463MRC mods by Codefenix (2024-10-20)
Pipeline #3082 passed
...@@ -245,29 +245,32 @@ void _cdecl interrupt_thread(void *arg) ...@@ -245,29 +245,32 @@ void _cdecl interrupt_thread(void *arg)
void _cdecl input_thread(void* arg) void _cdecl input_thread(void* arg)
{ {
char buf[LINEAR_RX_BUFLEN]; char buf[LINEAR_RX_BUFLEN];
int space;
int count; int count;
lputs(LOG_DEBUG,"input_thread: started"); lputs(LOG_DEBUG,"input_thread: started");
while(1) { while(1) {
count=RingBufFree(&rdbuf); space=RingBufFree(&rdbuf);
if(count<1) { if(space<1) {
lputs(LOG_WARNING,"input_thread: input buffer full!"); lputs(LOG_WARNING,"input_thread: input buffer full!");
YIELD(); YIELD();
continue; continue;
} }
if(count>sizeof(buf)) if(space>sizeof(buf))
count=sizeof(buf); space=sizeof(buf);
if(!ReadFile(rdslot,buf,count,&count,NULL)) { if(!ReadFile(rdslot,buf,space,&count,NULL)) {
if(GetLastError()==ERROR_HANDLE_EOF) { /* closed by VDD_CLOSE */ if(GetLastError()==ERROR_HANDLE_EOF) { /* closed by VDD_CLOSE */
lputs(LOG_INFO,"input_thread: ReadFile returned EOF"); lputs(LOG_INFO,"input_thread: ReadFile returned EOF");
break; break;
} }
lprintf(LOG_ERR,"!input_thread: ReadFile Error %d (size=%d)" lprintf(LOG_ERR,"!input_thread: ReadFile Error %d (space=%d, count=%d)"
,GetLastError(),count); ,GetLastError(), space, count);
YIELD();
continue; continue;
} }
if(count==0) { if(count==0) {
lputs(LOG_ERR,"!input_thread: ReadFile read 0"); lputs(LOG_ERR,"!input_thread: ReadFile read 0");
YIELD();
continue; continue;
} }
RingBufWrite(&rdbuf,buf,count); RingBufWrite(&rdbuf,buf,count);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment