- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
I've been writing some demo programs
for FM0-64L-S6E1C3 with PDL 2.1.0 and PSoC Creator 4.0.
So far, I could manage SPI(CSIO) and I2C to work.
Using utilities/printf_scanf by setting following in pdl_user.h
===========
// Printf/Scanf via UART function
#define PDL_UTILITY_ENABLE_UART_PRINTF PDL_ON
#define PDL_UTILITY_ENABLE_UART_SCANF PDL_ON
===========
Although printf seems reasonably working,
scanf does not come back.
So I spent a few days and found that
int _read(int file, char *ptr, int len) in uart_io.c
does not return until it reads "len" number of letters.
In my debugger, the len was 1024, when I was trying to read a few letters.
So I replaced following lines
==============
int i;
file = file;
for(i = 0; i < len; i++)
{
while (TRUE != Mfs_Uart_GetStatus(UartCh, UartRxFull))
{
/* Wait until there is a character in the Rx FIFO */
}
*ptr++ = (char)Mfs_Uart_ReceiveData(UartCh);
}
return len;
==============
with following lines
==============
int i = 0 ;
char c ;
file = file ;
while(i < len) {
while (TRUE != Mfs_Uart_GetStatus(UartCh, UartRxFull)) {
/* Wait until there is a characer in the Rx FIFO */
}
c = (char)Mfs_Uart_ReceiveData(UartCh);
Mfs_Uart_ClrStatus(UartCh, UartRxFull) ;
ptr[i++] = c ;
if (!isprint(c)) {
break ;
}
}
ptr = 0 ;
return i ;
==============
now scanf can read "%d", "%x", "%s".
But I wonder if my correction is correct,
or if there is/(will be) a better fix of PDL.
moto
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Yes, this seems to be a problem with scanf implementation. The work-around you added seems to be fine. We will check this with our software team.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Yes, this seems to be a problem with scanf implementation. The work-around you added seems to be fine. We will check this with our software team.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Dear BMAH-san,
Thank you for your respose!
Then I assume that my fix is usable and go forward for the time being.
Best Regards,
24-Nov-2016
Motoo Tanaka