This is a part of my test code.
Cheers.
Alberto.
int count = 0;
int largo_cadena = 0;
char* msg = "Detected the character 't'.\n";
FILE* fp;
IOWR(RTS_BASE,0,1); //
DEMO_PRINTF("In UART.\n");
fp = fopen ("/dev/serial", "r+"); //Open file for reading and writing
if (fp)
{
cursorX=0;
cursorY=-1;
DEMO_PRINTF("UART in ready.\n");
IOWR(RTS_BASE,0,0); //
largo_cadena = getc(fp); // Get string size
IOWR(RTS_BASE,0,1); //
int prompt;
while (1){
for(i=0;i<largo_cadena;i++){
prompt=32;
}
i=-1;
while (1) //
{ // Loop until we receive a 'v'.
IOWR(RTS_BASE,0,0); //
prompt = getc(fp); // Get a character from the UART.
IOWR(RTS_BASE,0,1); //
if (prompt == 13) {
cursorY++;
DEMO_PRINTF("Find a Enter.\n");
}
if (prompt == 255) {
break;
}
i++;
DEMO_PRINTF("%c", prompt);
}
i=i-1;
DEMO_PRINTF("Largo cadena: %d\n", largo_cadena);
TMostrar_String(cursorX, cursorY, 0, 0, 0xFFFE, 0, prompt, largo_cadena-1, Fuente);
usleep(500000);
}
DEMO_PRINTF("Out UART.\n");
fprintf(fp, "Closing the UART file.\n");
fclose (fp);
}