Hi to everyone,
In a gps/gprs project, I'm trying to implement the xon/xoff flow control to increase the speed at which a file is transferred to a ftp server. I'm using an atmega 644p at 8mhz and with a serial speed of 38400. At 9600 the file uploads without problems (no flow control required).
My code is:
boolean send_data(){
boolean end_file = false;
char buffer;
if (sd.begin(chipSelect, SPI_HALF_SPEED)){
if (myfile.open(filename, O_READ)){
altsoft.println ("sending data");
buffer = myfile.read ();
do{
Serial1.print (buffer); //Starts to send data
if (Serial1.available ()){
byte inchar = Serial1.read ();
altsoft.println (inchar); //debug print
if (inchar == XOFF){
altsoft.println ("off"); //debug print
do {
inchar = Serial1.read ();
} while (inchar != XON);
delay (10);
}
}
buffer = myfile.read();
} while(buffer >= 0);
myfile.close ();
Serial1.println ("+++");
}
}
return (end_file);
}
Although it's appears to detect xoff character there are missed characters (almost one line in each xoff) in the upload file. I attach part of the file where the characters are missing.
3898911,-692374,121001,202528,194,15,0,0
3898911,-692374,121001,202528,194,15,0,0
3898911,-692374,121001,202529,194,15,0,0
3898911,-692374,121001,202529,194,15,0,0
3898911,-692374,121001,202530,194,15,0,0
3898911,-692374,121001,202530,194,10,0 missing characters (one complete line)
3898911,-692374,121001,202531,194,15,0,0
3898910,-692374,121001,202532,194,15,0,0
3898910,-692374,121001,202532,194,15,0,0
3898910,-692374,121001,202533,194,15,0,0
3898910,-692374,121001,202533,194,15,0,0
3898910,-692374,121001,202534,194,15,0,0
3898910,-692374,121001,202534,194,15,0,0
3898910,-692374,121001,202535,194,15,0,0
3898910,-692374,121001,202535,194,15,0,0
3898910,-692374,121001,202536,194,15,0,0
3898910,-692374,121001,202536,194,15,0,0
3898910,-692375,121001,202537,194,15,0,0
3898910,-692375,121001,202537,194,15,0,0
3898910,-692375,121001,202538,194,15,0,0
3898910,-692375,121001,202538,194,15,0,0
3898910,-692375,121001,202539,194,15,0,0
3898910,-692375,121001,202539,194,15,0,0
I'm crazy trying to realize which could be the error but I cant detect it, I'll appreciate any help in this topic.
Thanks in advance