2023-10-11 05:00 AM
fgets ignores my limit and is trying to read 1024 characters.
char *fgets( char *str, int numChars, FILE *stream );
as I understand fgets it is supposed to read up to numCHars characters from stream into str. It should also stop on a newline
The behavior I see is that changes the numChars in __srefill_r to 1024. I also see no code in the disassembly to deal with \n. By the time _read is called the len argument is 1024. Is stdin a block mode device?
Do I misunderstand fgets or what might be happening here.
I overrode __io_getchar as follows. It is being hit and does return the chars I type.
int __io_getchar(void)
{
uint8_t ch = '\n';
HAL_StatusTypeDef eStatus;
eStatus = HAL_UART_Receive(&huart3, &ch, 1, HAL_MAX_DELAY);
return ch;
}
2023-10-11 05:16 AM
I am using this in its place
2023-10-11 05:17 AM
I wrote my own getline since I didnt find it in the libraries