Möglicherweise habe ich etwas übersehen (wer schaut mal drüber?), aber so gefällt es besser:
PS: es fehlt immernoch die Abfrage, ob die Anzahl der Empfangenen Zeichen länger als 18 sind. Das 19. ist das "0" Byte.Code:int index=0; char ch[19]; while (1) { c = uart_getc(); if ( c & UART_NO_DATA ) { /* * no data available from UART */ } else { /* * new data available from UART * check for Frame or Overrun error */ if ( c & UART_FRAME_ERROR ) { /* Framing Error detected, i.e no stop bit detected */ uart_puts_P("UART Frame Error: "); ch[0]=0; index=0; } else if ( c & UART_OVERRUN_ERROR ) { /* * Overrun, a character already present in the UART UDR register was * not read by the interrupt handler before the next character arrived, * one or more received characters have been dropped */ uart_puts_P("UART Overrun Error: "); ch[0]=0; index=0; } else if ( c & UART_BUFFER_OVERFLOW ) { /* * We are not reading the receive buffer fast enough, * one or more received character have been dropped */ uart_puts_P("Buffer overflow error: "); ch[0]=0; index=0; } else { /* * send received character back */ uart_putc( (unsigned char)c ); if((unsigned char)c!=13) { ch[index]=c; index++; } else { ch[index]=0; index = 0; if (strcmp (ch,"TEMP1")==0) { // Temperatur soll angefragt werden uart_puts("Temperatur1=..........\n"); } else if (strcmp (ch,"TEMP2")==0) { // Temperatur soll angefragt werden uart_puts("Temperatur2=..........\n"); } else if (strcmp (ch,"PH")==0) { // Temperatur soll angefragt werden uart_puts("PH=..........\n"); } else if (strcmp (ch,"HUMIDITY")==0) { // Temperatur soll angefragt werden uart_puts("Humidityr=..........\n"); } ch[0]=0; } } } }







Zitieren


Lesezeichen