Hallo,
ich habe nun auf die Lösung von SlyD zurückgegriffen und das Programm wie folgt gestaltet:
Code:
#include "RP6RobotBaseLib.h"
char receiveBuffer[UART_RECEIVE_BUFFER_SIZE+1];
uint8_t getInputLine(void)
{
static uint8_t buffer_pos = 0;
if(getBufferLength())
{
receiveBuffer[buffer_pos] = readChar();
if(receiveBuffer[buffer_pos]=='\n')
{
receiveBuffer[buffer_pos]='\0';
buffer_pos = 0;
return 1;
}
else if(buffer_pos >= 32)
{
receiveBuffer[32]='\0';
buffer_pos = 0;
return 2;
}
buffer_pos++;
}
return 0;
}
int main(void)
{
initRobotBase();
powerON();
while(1)
{
if(getInputLine())
{
if(strcmp(receiveBuffer, "Ein")==0)
{
setLEDs(0b111111);
}
if(strcmp(receiveBuffer, "Aus")==0)
{
setLEDs(0b000000);
}
}
}
return 0;
}
Allerdings mag das der Compiler nicht:
Code:
> "E:\RP6\Programme\Eigene Programme\Einlesen2\\make_all.bat"
E:\RP6\Programme\Eigene Programme\Einlesen2>set LANG=C
E:\RP6\Programme\Eigene Programme\Einlesen2>make all
-------- begin --------
avr-gcc (GCC) 4.1.2 (WinAVR 20070525)
Copyright (C) 2006 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
Compiling: Einlesen2.c
avr-gcc -c -mmcu=atmega32 -I. -gdwarf-2 -Os -funsigned-char -funsigned-bitfields -fpack-struct -fshort-enums -Wall -Wstrict-prototypes -Wa,-adhlns=Einlesen2.lst -I../RP6lib -I../RP6lib/RP6base -I../RP6lib/RP6common -std=gnu99 -MD -MP -MF .dep/Einlesen2.o.d Einlesen2.c -o Einlesen2.o
Einlesen2.c: In function 'getInputLine':
Einlesen2.c:8: warning: implicit declaration of function 'getBufferLength'
Einlesen2.c:10: warning: implicit declaration of function 'readChar'
Linking: Einlesen2.elf
avr-gcc -mmcu=atmega32 -I. -gdwarf-2 -Os -funsigned-char -funsigned-bitfields -fpack-struct -fshort-enums -Wall -Wstrict-prototypes -Wa,-adhlns=Einlesen2.o -I../RP6lib -I../RP6lib/RP6base -I../RP6lib/RP6common -std=gnu99 -MD -MP -MF .dep/Einlesen2.elf.d Einlesen2.o ../RP6lib/RP6base/RP6RobotBaseLib.o ../RP6lib/RP6common/RP6uart.o --output Einlesen2.elf -Wl,-Map=Einlesen2.map,--cref -lm
Einlesen2.o: In function `getInputLine':
E:\RP6\Programme\Eigene Programme\Einlesen2/Einlesen2.c:8: undefined reference to `getBufferLength'
E:\RP6\Programme\Eigene Programme\Einlesen2/Einlesen2.c:10: undefined reference to `readChar'
make: *** [Einlesen2.elf] Error 1
Er hat also was gegen getBufferLength und readChar.
Was bezwecken eigentlich return 1 und return 2??
Ich würde mich wirklich freuen, wenn ich die "Aufgabe", den RP6 auf Tastatureingaben reagieren zu lassen bald erfolgreich abschließen könnte.
Gruß
Michi
Lesezeichen