void Synth1::get() // recieving synth lock detects from RC
{
for(long int i=0;i<=10000000;i++);
port
->write
(QString::number(7).
toAscii());
for(long int i=0;i<=10000000;i++);
for(long int i=0;i<=10000000;i++);
port
->write
(QString::number(0).
toAscii());
for(long int i=0;i<=100000000;i++);
for(long int i=0;i<=100000000;i++);
for(long int i=0;i<=100000000;i++);
for(long int i=0;i<=100000000;i++);
for(long int i=0;i<=100000000;i++);
for(long int i=0;i<=100000000;i++);
for(long int i=0;i<=100000000;i++);
for(long int i=0;i<=100000000;i++);
char buff[2048];
int numBytes;
numBytes = port->bytesAvailable();
if(numBytes > 0)
{
if(numBytes > 2048)
numBytes = 2048;
int i = port->read(buff, numBytes);
buff[i] = '\0';
int j=msg.indexOf(y,0);
msg.remove(0,j);
ui.lineEdit_13->clear();
ui.lineEdit_13->insert(msg);
if(fields.size()==16)
{
QString str,id2,sum2,sy1,sy2,sy3,sy4,sy5,sy6,sy7,sy8,sy9,sy10,sy11,sy12;
str=fields[0];
id2=fields[1];
sum2=fields[2];
sy1=fields[3];
sy2=fields[4];
sy3=fields[5];
sy4=fields[6];
sy5=fields[7];
sy6=fields[8];
sy7=fields[9];
sy8=fields[10];
sy9=fields[11];
sy10=fields[12];
sy11=fields[13];
sy12=fields[14];
if(id2=="7")
{
ui.lineEdit->clear();
ui.lineEdit_2->clear();
ui.lineEdit_3->clear();
ui.lineEdit_4->clear();
ui.lineEdit_5->clear();
ui.lineEdit_6->clear();
ui.lineEdit_7->clear();
ui.lineEdit_8->clear();
ui.lineEdit_9->clear();
ui.lineEdit_10->clear();
ui.lineEdit_11->clear();
ui.lineEdit_12->clear();
ui.lineEdit->insert(sy1);
ui.lineEdit_2->insert(sy2);
ui.lineEdit_3->insert(sy3);
ui.lineEdit_4->insert(sy4);
ui.lineEdit_5->insert(sy5);
ui.lineEdit_6->insert(sy6);
ui.lineEdit_7->insert(sy7);
ui.lineEdit_8->insert(sy8);
ui.lineEdit_9->insert(sy9);
ui.lineEdit_10->insert(sy10);
ui.lineEdit_11->insert(sy11);
ui.lineEdit_12->insert(sy12);
}
else
{
tr("<b>NOT VALID PACKET</b> recieved..."));
}
}
else
{
tr("<b>DATA</b> NOT recieved properly."));
}
}
}
void Synth1::get() // recieving synth lock detects from RC
{
port->open(QIODevice::ReadWrite);
port->write(QString::QString(":").toAscii());
for(long int i=0;i<=10000000;i++);
port->write(QString::QString(" ").toAscii());
port->write(QString::number(7).toAscii());
port->write(QString::QString(" ").toAscii());
for(long int i=0;i<=10000000;i++);
for(long int i=0;i<=10000000;i++);
port->write(QString::number(0).toAscii());
port->write(QString::QString(" ").toAscii());
for(long int i=0;i<=100000000;i++);
for(long int i=0;i<=100000000;i++);
for(long int i=0;i<=100000000;i++);
for(long int i=0;i<=100000000;i++);
for(long int i=0;i<=100000000;i++);
for(long int i=0;i<=100000000;i++);
for(long int i=0;i<=100000000;i++);
for(long int i=0;i<=100000000;i++);
char buff[2048];
int numBytes;
numBytes = port->bytesAvailable();
if(numBytes > 0)
{
if(numBytes > 2048)
numBytes = 2048;
int i = port->read(buff, numBytes);
buff[i] = '\0';
QString msg = buff;
QString y = ": 7 ";
int j=msg.indexOf(y,0);
msg.remove(0,j);
ui.lineEdit_13->clear();
ui.lineEdit_13->insert(msg);
QStringList fields =msg.split(" ");
if(fields.size()==16)
{
QString str,id2,sum2,sy1,sy2,sy3,sy4,sy5,sy6,sy7,sy8,sy9,sy10,sy11,sy12;
str=fields[0];
id2=fields[1];
sum2=fields[2];
sy1=fields[3];
sy2=fields[4];
sy3=fields[5];
sy4=fields[6];
sy5=fields[7];
sy6=fields[8];
sy7=fields[9];
sy8=fields[10];
sy9=fields[11];
sy10=fields[12];
sy11=fields[13];
sy12=fields[14];
if(id2=="7")
{
ui.lineEdit->clear();
ui.lineEdit_2->clear();
ui.lineEdit_3->clear();
ui.lineEdit_4->clear();
ui.lineEdit_5->clear();
ui.lineEdit_6->clear();
ui.lineEdit_7->clear();
ui.lineEdit_8->clear();
ui.lineEdit_9->clear();
ui.lineEdit_10->clear();
ui.lineEdit_11->clear();
ui.lineEdit_12->clear();
ui.lineEdit->insert(sy1);
ui.lineEdit_2->insert(sy2);
ui.lineEdit_3->insert(sy3);
ui.lineEdit_4->insert(sy4);
ui.lineEdit_5->insert(sy5);
ui.lineEdit_6->insert(sy6);
ui.lineEdit_7->insert(sy7);
ui.lineEdit_8->insert(sy8);
ui.lineEdit_9->insert(sy9);
ui.lineEdit_10->insert(sy10);
ui.lineEdit_11->insert(sy11);
ui.lineEdit_12->insert(sy12);
}
else
{
QMessageBox:: about(this,tr("PORT"),
tr("<b>NOT VALID PACKET</b> recieved..."));
}
}
else
{
QMessageBox:: about(this,tr("PORT"),
tr("<b>DATA</b> NOT recieved properly."));
}
}
}
To copy to clipboard, switch view to plain text mode
Bookmarks