-
SerWrite Problem ASURO
Hallo zusammen,
ich würde gern meinen Asuro zum Spaß als Taschenrechner umfunktionieren, ersteinmal wollte ic hnur die Addition angehen, doch dann begegnete mir folgendes Problemm hoffe ihr könnt mir weiterhelfen:
Code:
#include "asuro.h"
#include <stdio.h>
int main(void)
{
//1. Summand
unsigned char data_1[10];
//2.summand
unsigned char data_2[10];
//Summe
int summe;
Init();
SerWrite("1. Summand",11);
SerRead(data_1,10,0);
SerWrite("\n2.Summand",11);
SerRead(data_2,10,0);
summe=atoi(data_1)+atoi(data_2);
SerWrite("\nSumme: %i",summe,15);
while(1);
return 0;
}
mein compiler meldet folgndes Fehler:
C:\asuro_libv271\examples\FirstTry>make all
set -e; avr-gcc -MM -mmcu=atmega8 -I. -g -Os -I../../lib/inc -funsigned-char -funsigned-bitfields -fpack-struct -fshort-enums -Wall -Wstrict-prototypes -Wa,-ahlms=test.lst test.c \
| sed 's,\(.*\)\.o[ :]*,\1.o \1.d : ,g' > test.d; \
[ -s test.d ] || rm -f test.d
-------- begin --------
avr-gcc --version
avr-gcc (GCC) 3.3.1
Copyright (C) 2003 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.
Size before:
test.elf :
section size addr
.text 1098 0
.data 26 8388704
.bss 18 8388730
.noinit 0 8388748
.eeprom 0 8454144
.stab 2196 0
.stabstr 1940 0
.debug_aranges 128 0
.debug_pubnames 283 0
.debug_info 1190 0
.debug_abbrev 735 0
.debug_line 1408 0
.debug_frame 224 0
.debug_str 387 0
.debug_loc 439 0
Total 10072
avr-gcc -c -mmcu=atmega8 -I. -g -Os -I../../lib/inc -funsigned-char -funsigned-bitfields -fpack-struct -fshort-enums -Wall -Wstrict-prototypes -Wa,-ahlms=test.lst test.c -o test.o
test.c: In function `main':
test.c:19: error: invalid operands to binary +
test.c:20: error: too many arguments to function `SerWrite'
make: *** [test.o] Error 1
> Process Exit Code: 2
es liegt anscheinend an der Funktion SerWrite, hier benutze ich einen Platzhalter, für den int-wert, jetzt frage ich mich, wie kann ich das umgehen, gibt es alternativen?
habe gesucht, allerdings nichjts richtiges gefunden....
mfg hans
-
PS: Den Compiler-Fehler in Zeile 19 konnte ich durch eine C-Funktion beheben (atoi), nur den anderen eben nicht...
-
hallo Hansi41
so viel ich weiß gibt es dafür in der AsuroLib_v271 eine eigene Funktion
-
aha, und wie heißt die?
ich kenne mich mit der neuen version noch nicht so richtig aus...
-
hallo Hansi41
PrintInt()
in deinem Fall: PrintInt(summe);
ich hoffe es funktioniert (habe es noch nicht ausprobiert)
mfg hai1991
-
aha, also müsste das programm dann wie folgt aussehen:
Code:
#include "asuro.h"
#include <stdio.h>
int main(void)
{
//1. Summand
unsigned char data_1[10];
//2.summand
unsigned char data_2[10];
//Summe
int summe;
Init();
SerWrite("1. Summand",11);
SerRead(data_1,10,0);
SerWrite("\n2.Summand",11);
SerRead(data_2,10,0);
summe=atoi(data_1)+atoi(data_2);
PrintInt(summe);
while(1);
return 0;
}
oder?
EDIT: code-tags korrigiert; damaltor @ 2.4.08;18:00h