hi guys, anyone help me in my project i am using three uarts one for thermal printer , another bluetooth, and general uart. the following port allocation
#include <SoftwareSerial.h>
SoftwareSerial Thermal(10,11);
SoftwareSerial mySerial(5,6);
my problem is when ever i disable thermal printer from the bluetooth i am able to recieve that data ( approximately 300bytes) if i activated thermal printer i can able the then i am receiving partial information (approximately 40 bytes). i am sending the following code
intheatTime = 120;
intheatInterval = 50;
charprintDensity = 15;
charprintBreakTime = 15;
String Data = "";
void setup()
{
Serial.begin(57600); // for debug info to serial monitor
Thermal.begin(9600); // to write to our new printer
mySerial.begin(9600);// bluetoothintializing
initPrinter();
}
voidinitPrinter()
{
//Modify the print speed and heat
Thermal.write(27);
Thermal.write(55);
Thermal.write(7); //Default 64 dots = 8*('7'+1)
Thermal.write(heatTime); //Default 80 or 800us
Thermal.write(heatInterval); //Default 2 or 20us
//Modify the print density and timeout
Thermal.write(18);
Thermal.write(35);
intprintSetting = (printDensity<<4) | printBreakTime;
Thermal.write(printSetting); //Combination of printDensity and printBreakTime
Serial.println();
Serial.println("Printer ready");
Thermal.write("WEL");
Serial.println();
Serial.println("Parameters set");
}
void loop()
{
while(mySerial.available()>0) {
char character = mySerial.read(); // Receive a single character from the software serial port
Data.concat(character); // Add the received character to the receive buffer
if (character == '\n')
{
//flag=1;
Serial.print(" ");
Serial.println(Data);
// delay(500);
Thermal.println(Data);
delay(5000);
// Add your code to parse the received line here....
// Clear receive buffer so we're ready to receive the next line
Data = "";
}
}
}
if i disable Thermal.println(Data); then fine i am getting total data on my communication port (uart on pc) . when ever i enable Thermal.println(Data); then i able to receive only partial data. so, how i can clear the buffer on uart so any suggestions so please help me. thank you very much