Skip to content
Snippets Groups Projects
Commit ecb1da7c authored by Jedian's avatar Jedian
Browse files

Lindo e funcionando, mas instavel como sempre


Signed-off-by: default avatarJedian <jmb15@c3sl.ufpr.br>
parent d1782a3d
No related branches found
No related tags found
No related merge requests found
......@@ -128,39 +128,29 @@ int int2hex (char *c, int i) {
return j-1;
}
int main(void) { // receive a string through the UART serial interface
int i, j; // and responds with the i-eth hex-based fibonacci sequence number
volatile int state = 0;
volatile Tstatus status;
char filona[145], c;
int hdona = 0;
int tlona = 0;
int filonx = 0;
int valfib, qt, rxz, q;
int fim = 0;
int hdona = 0; // head of the big queue
int tlona = 0; // tail of the big queue
int filonx = 0; // store the number of received integers to be processed
int valfib, qt, rxz, q; // auxiliar variables
char p[15];
Tcontrol ctrl;
uart = (void *)IO_UART_ADDR; // bottom of UART address range
i = -1;
Ud.ntx = 16;
Ud.ntx = 16; // initializing number of empty spaces in tx queue
ioctl(ctrl_util(2, 1, 1, 1)); // Speed = 2, intRX = 1, intTX = 1, rts = 1
do {
state++;
// se tirar fode (b520 vira 15)
while(!proberx()) to_stdout('-');//i = 1 - i;
//to_stdout('\0');
// es
while((c=Getc()) != -1){
state++; // state is a volatile variable just for optimize blocking
while(!proberx()) to_stdout('-'); // wait until first reception
while((c=Getc()) != -1){ // dump the reception queue to the big queue
filona[tlona] = c;
// se tirar fode (b520 vira 15)
//to_stdout('*');
// cmips_delay(1);
//to_stdout('\0');
// es
tlona++;
tlona%=145;
if(c=='\n'){
......@@ -168,11 +158,12 @@ int main(void) { // receive a string through the UART serial interface
filona[tlona] = 10;
}
}
while(filonx > 0){
qt = Strlen(filona+hdona);
valfib = hex2int(qt, (filona+hdona));
if(valfib != -1)
valfib = buf[valfib];
if(valfib != -1) // if is a valid value (lower than 2c and bigger or equal to 0)
valfib = buf[valfib]; // if not valid, UART receives and prints ffffffff
hdona += qt+1;
hdona %= 145;
qt = int2hex(p, valfib);
......@@ -180,6 +171,7 @@ int main(void) { // receive a string through the UART serial interface
do {
j++;
while(((rxz = proberx())<10) && !(q=Putc(p[j])));
while((c=Getc()) != -1){
filona[tlona] = c;
tlona++;
......@@ -189,15 +181,17 @@ int main(void) { // receive a string through the UART serial interface
filona[tlona] = 10;
}
}
if(!q)
j--;
} while (p[j] != 0);
filonx--;
if(!filonx)
return state;
}
} while (state);
} while (state < 200);
return state;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment