10-28-2020 04:24 AM - edited 10-28-2020 04:29 AM
I'm using the PS uart (Zynq MPSoC) to receive commands I type on a terminal.
The function to receive is called regularly and uses XUartPs_IsReceiveData to determine if there is any new character.
Input characters are copied into a buffer array. If CR (0xD) was received, a flag is set and the whole buffer is copied to another array for another function to process it.
What I observe is:
- I need to hit enter twice to get the command executed, obviously I get the command processed and an 'empty command' error after.
I added a print to return each character typed and read. I expected an echo but what I get is:
- Nothing is printed until I press the first return, then it prints the first character typed. At the second return pressed the whole line is printed out.
The debug print above ends with '\r\n' to force printing.
I'm using Teraterm set up to send CR as a new line, I checked is CR and not CR+LF or LF.
Even funnier: this used to work well but I did some change and I didn't commit the previous code so now it takes longer for not spending a minute.
10-28-2020 04:43 AM
Well, I found a solution, maybe there are others but this made my day:
I replaced getchar() by XUartPs_RecvByte and it does the job perfectly. It even echoes each character as I type them.
10-28-2020 04:43 AM
Well, I found a solution, maybe there are others but this made my day:
I replaced getchar() by XUartPs_RecvByte and it does the job perfectly. It even echoes each character as I type them.