LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 04-19-2012, 11:46 PM   #16
navya
LQ Newbie
 
Registered: Apr 2012
Posts: 15

Original Poster
Rep: Reputation: Disabled

hello,
Code:
 for mainwindow.cpp
#include "mainwindow.h"
#include "serial.h"
#include "ui_form1.h"
#include "ui_form2.h"
#include "ui_form3.h"
#include "ui_form4.h"
#include "iostream"

#include <QByteArray>

#include <QTimer>
#include <QDebug>

using std::cout;
using std::endl;

MainWindow::MainWindow(QWidget *parent) :
    QWidget(parent)
{
    resize(346,202);
    this->setFixedSize(this->width(),this->height());
    this->setGeometry(10,30,this->width(),this->height());

    Ui_Form1 *ui1= new Ui_Form1();
    window1 = new QWidget(this);
    ui1->setupUi(window1);
    window1->show();
    window2 = new QWidget(this);
    window2->hide();

    connect(ui1->next,SIGNAL(clicked()),this,SLOT(on_next_clicked()));
    //connect(ui1->btn1,SIGNAL(released()),this,SLOT(on_btn1_released()));
    //timer = new QTimer(this);
    connect(ui1->btn1,SIGNAL(pressed()),this,SLOT(on_btn1_pressed()));
    connect(ui1->btn1,SIGNAL(released()),this,SLOT(on_btn1_released()));

    connect(ui1->btn2,SIGNAL(pressed()),this,SLOT(on_btn2_pressed()));
    connect(ui1->btn2,SIGNAL(released()),this,SLOT(on_btn2_released()));

    connect(ui1->btn3,SIGNAL(pressed()),this,SLOT(on_btn3_pressed()));
    connect(ui1->btn3,SIGNAL(released()),this,SLOT(on_btn3_released()));

    connect(ui1->btn4,SIGNAL(pressed()),this,SLOT(on_btn4_pressed()));
    connect(ui1->btn4,SIGNAL(released()),this,SLOT(on_btn4_released()));

    timer = new QTimer(this);
    timer1 = new QTimer(this);
    timer2 = new QTimer(this);
    timer3 = new QTimer(this);


    serialPortObj = new SerialPort();
    serialPortObj->setPort();
   // window1->show();
}

MainWindow::~MainWindow()
{
    //delete ui;
}
void MainWindow::on_next_clicked()
{
    window1->hide();
    Ui_Form2 *ui2 = new Ui_Form2();
    window2 = new QWidget(this);
    ui2->setupUi(window2);
    connect(ui2->next,SIGNAL(clicked()),this,SLOT(on_next1_clicked()));
    connect(ui2->btn5,SIGNAL(pressed()),this,SLOT(on_btn5_pressed()));
    connect(ui2->btn5,SIGNAL(released()),this,SLOT(on_btn5_released()));

    connect(ui2->btn6,SIGNAL(pressed()),this,SLOT(on_btn6_pressed()));
    connect(ui2->btn6,SIGNAL(released()),this,SLOT(on_btn6_released()));

    connect(ui2->btn7,SIGNAL(pressed()),this,SLOT(on_btn7_pressed()));
    connect(ui2->btn7,SIGNAL(released()),this,SLOT(on_btn7_released()));

    connect(ui2->btn8,SIGNAL(pressed()),this,SLOT(on_btn8_pressed()));
    connect(ui2->btn8,SIGNAL(released()),this,SLOT(on_btn8_released()));

    connect(ui2->back2,SIGNAL(clicked()),this,SLOT(on_back2_clicked()));

    timer4 = new QTimer(this);
    timer5 = new QTimer(this);
    timer6 = new QTimer(this);
    timer7 = new QTimer(this);

    window2 -> show();
}
void MainWindow::on_back2_clicked()
{
    Ui_Form1 *ui1= new Ui_Form1();
    window1 = new QWidget(this);
    ui1->setupUi(window1);
    window1->show();

    Ui_Form2 *ui2 = new Ui_Form2();
    window2 = new QWidget(this);
    ui2->setupUi(window2);
    window2->hide();

}

void MainWindow::on_next1_clicked()
{
    window2->hide();
    Ui_Form3 *ui3 = new Ui_Form3();
    window3 = new QWidget(this);
    ui3->setupUi(window3);
   connect(ui3->next2,SIGNAL(clicked()),this,SLOT(on_next2_clicked()));

    connect(ui3->btn9,SIGNAL(pressed()),this,SLOT(on_btn9_pressed()));
    connect(ui3->btn9,SIGNAL(released()),this,SLOT(on_btn9_released()));

    connect(ui3->btn10,SIGNAL(pressed()),this,SLOT(on_btn10_pressed()));
    connect(ui3->btn10,SIGNAL(released()),this,SLOT(on_btn10_released()));

    connect(ui3->btn11,SIGNAL(pressed()),this,SLOT(on_btn11_pressed()));
    connect(ui3->btn11,SIGNAL(released()),this,SLOT(on_btn11_released()));

    connect(ui3->btn12,SIGNAL(pressed()),this,SLOT(on_btn12_pressed()));
    connect(ui3->btn12,SIGNAL(released()),this,SLOT(on_btn12_released()));

    connect(ui3->back1,SIGNAL(clicked()),this,SLOT(on_next_clicked()));

    timer8 = new QTimer(this);
    timer9 = new QTimer(this);
    timer10 = new QTimer(this);
    timer11 = new QTimer(this);
    timer12 = new QTimer(this);
    window3->show();
}

void MainWindow::on_next2_clicked()
{
    window3->hide();
    Ui_Form4 *ui4 = new Ui_Form4();
    window4 = new QWidget(this);
    ui4->setupUi(window4);
    //connect(ui4->next3,SIGNAL(clicked()),this,SLOT(on_next3_clicked()));
    connect(ui4->btn13,SIGNAL(pressed()),this,SLOT(on_btn13_pressed()));
    connect(ui4->btn13,SIGNAL(released()),this,SLOT(on_btn13_released()));

    connect(ui4->btn14,SIGNAL(pressed()),this,SLOT(on_btn14_pressed()));
    connect(ui4->btn14,SIGNAL(released()),this,SLOT(on_btn14_released()));

    connect(ui4->btn15,SIGNAL(pressed()),this,SLOT(on_btn15_pressed()));
    connect(ui4->btn15,SIGNAL(released()),this,SLOT(on_btn15_released()));

    connect(ui4->btn16,SIGNAL(pressed()),this,SLOT(on_btn16_pressed()));
    connect(ui4->btn16,SIGNAL(released()),this,SLOT(on_btn16_released()));

    connect(ui4->back,SIGNAL(clicked()),this,SLOT(on_next1_clicked()));

    timer13 = new QTimer(this);
    timer14 = new QTimer(this);
    timer15 = new QTimer(this);

    window4->show();
}

void MainWindow::on_btn1_pressed()
{
    QByteArray sendFrame = generateFrame();
    serialPortObj->clearPort();
    serialPortObj->writePort(sendFrame.data(),sendFrame.length());
    connect(timer,SIGNAL(timeout()),this,SLOT(on_btn1_pressed()));
    timer->start(500);
    std::cout << sendFrame.data() << std::endl;
    sendFrame = sentFrame;
}

void MainWindow::on_btn1_released()
{
    QByteArray sendFrame1 = generateFrame4();
    serialPortObj->clearPort();
    serialPortObj->writePort(sendFrame1.data(),sendFrame1.length());
    connect(timer,SIGNAL(timeout()),this,SLOT(on_btn1_released()));
    timer->start(500);
    std::cout << sendFrame1.data() << std::endl;
    timer->stop();
}

void MainWindow::on_btn2_pressed()
{
    QByteArray sendFrame2 = generateFrame1();
    serialPortObj->clearPort();
    serialPortObj->writePort(sendFrame2.data(),sendFrame2.length());
    connect(timer1,SIGNAL(timeout()),this,SLOT(on_btn2_pressed()));
    timer1->start(500);
    std::cout << sendFrame2.data() << std::endl;
    sendFrame2 = sentFrame;
}

void MainWindow::on_btn2_released()
{
    QByteArray sendFrame3 = generateFrame5();
    serialPortObj->clearPort();
    serialPortObj->writePort(sendFrame3.data(),sendFrame3.length());
    connect(timer1,SIGNAL(timeout()),this,SLOT(on_btn2_released()));
    timer1->start(500);
    std::cout << sendFrame3.data() << std::endl;
    timer1->stop();
}

void MainWindow::on_btn3_pressed()
{
    QByteArray sendFrame4 = generateFrame2();
    serialPortObj->clearPort();
    serialPortObj->writePort(sendFrame4.data(),sendFrame4.length());
    connect(timer2,SIGNAL(timeout()),this,SLOT(on_btn3_pressed()));
    timer2->start(500);
    std::cout << sendFrame4.data() << std::endl;
    sendFrame4 = sentFrame;
}

void MainWindow::on_btn3_released()
{
    QByteArray sendFrame5 = generateFrame6();
    serialPortObj->clearPort();
    serialPortObj->writePort(sendFrame5.data(),sendFrame5.length());
    connect(timer2,SIGNAL(timeout()),this,SLOT(on_btn3_released()));
    timer2->start(500);
    std::cout << sendFrame5.data() << std::endl;
    timer2->stop();
}

void MainWindow::on_btn4_pressed()
{
    QByteArray sendFrame6 = generateFrame3();
    serialPortObj->clearPort();
    serialPortObj->writePort(sendFrame6.data(),sendFrame6.length());
    connect(timer3,SIGNAL(timeout()),this,SLOT(on_btn4_pressed()));
    timer3->start(500);
    std::cout << sendFrame6.data() << std::endl;
    sendFrame6 = sentFrame;
}

void MainWindow::on_btn4_released()
{
    QByteArray sendFrame7 = generateFrame7();
    serialPortObj->clearPort();
    serialPortObj->writePort(sendFrame7.data(),sendFrame7.length());
    connect(timer3,SIGNAL(timeout()),this,SLOT(on_btn4_released()));
    timer3->start(500);
    std::cout<< sendFrame7.data() << std::endl;
    timer3->stop();
}

void MainWindow::on_btn5_pressed()
{
    QByteArray sendFrame8 = generateFrame8();
    serialPortObj->clearPort();
    serialPortObj->writePort(sendFrame8.data(),sendFrame8.length());
    connect(timer4,SIGNAL(timeout()),this,SLOT(on_btn5_pressed()));
    timer4->start(500);
    std::cout << sendFrame8.data() << std::endl;
    sendFrame8 = sentFrame;
}

void MainWindow::on_btn5_released()
{
    QByteArray sendFrame9 = generateFrame9();
    serialPortObj->clearPort();
    serialPortObj->writePort(sendFrame9.data(),sendFrame9.length());
    connect(timer4,SIGNAL(timeout()),this,SLOT(on_btn5_released()));
    timer4->start(500);
    std::cout << sendFrame9.data() << std::endl;
    timer4->stop();
}
void MainWindow::on_btn6_pressed()
{
    QByteArray sendFrame10 = generateFrame10();
    serialPortObj->clearPort();
    serialPortObj->writePort(sendFrame10.data(),sendFrame10.length());
    connect(timer5,SIGNAL(timeout()),this,SLOT(on_btn6_pressed()));
    timer5->start(500);
    std::cout << sendFrame10.data() << std::endl;
    sendFrame10 = sentFrame;
}
void MainWindow::on_btn6_released()
{
    QByteArray sendFrame11 = generateFrame11();
    serialPortObj->clearPort();
    serialPortObj->writePort(sendFrame11.data(),sendFrame11.length());
    connect(timer5,SIGNAL(timeout()),this,SLOT(on_btn6_released()));
    timer5->start(500);
    std::cout << sendFrame11.data() << std::endl;
    timer5->stop();
}
void MainWindow::on_btn7_pressed()
{
    QByteArray sendFrame12 = generateFrame12();
    serialPortObj->clearPort();
    serialPortObj->writePort(sendFrame12.data(),sendFrame12.length());
    connect(timer6,SIGNAL(timeout()),this,SLOT(on_btn7_pressed()));
    timer6->start(500);
    std::cout << sendFrame12.data() << std::endl;
    sendFrame12 = sentFrame;
}
void MainWindow::on_btn7_released()
{
    QByteArray sendFrame13 = generateFrame13();
    serialPortObj->clearPort();
    serialPortObj->writePort(sendFrame13.data(),sendFrame13.length());
    connect(timer6,SIGNAL(timeout()),this,SLOT(on_btn7_released()));
    timer6->start(500);
    std::cout << sendFrame13.data() << std::endl;
    timer6->stop();
}
void MainWindow::on_btn8_pressed()
{
    QByteArray sendFrame14 = generateFrame14();
    serialPortObj->clearPort();
    serialPortObj->writePort(sendFrame14.data(),sendFrame14.length());
    connect(timer7,SIGNAL(timeout()),this,SLOT(on_btn8_pressed()));
    timer7->start(500);
    std::cout << sendFrame14.data() << std::endl;
    sendFrame14 = sentFrame;
}
void MainWindow::on_btn8_released()
{
    QByteArray sendFrame15 = generateFrame15();
    serialPortObj->clearPort();
    serialPortObj->writePort(sendFrame15.data(),sendFrame15.length());
    connect(timer7,SIGNAL(timeout()),this,SLOT(on_btn8_released()));
    timer7->start(500);
    std::cout << sendFrame15.data() << std::endl;
    timer7->stop();
}
void MainWindow::on_btn9_pressed()
{
    QByteArray sendFrame16 = generateFrame16();
    serialPortObj->clearPort();
    serialPortObj->writePort(sendFrame16.data(),sendFrame16.length());
    connect(timer8,SIGNAL(timeout()),this,SLOT(on_btn9_pressed()));
    timer8->start(500);
    std::cout << sendFrame16.data() << std::endl;
   sendFrame16 = sentFrame;
}
void MainWindow::on_btn9_released()
{
    QByteArray sendFrame17 = generateFrame17();
    serialPortObj->clearPort();
    serialPortObj->writePort(sendFrame17.data(),sendFrame17.length());
    connect(timer8,SIGNAL(timeout()),this,SLOT(on_btn9_released()));
    timer8->start(500);
    std::cout << sendFrame17.data() << std::endl;
    timer8->stop();
}
void MainWindow::on_btn10_pressed()
{
    QByteArray sendFrame18 = generateFrame18();
    serialPortObj->clearPort();
    serialPortObj->writePort(sendFrame18.data(),sendFrame18.length());
    connect(timer9,SIGNAL(timeout()),this,SLOT(on_btn10_pressed()));
    timer9->start(500);
    std::cout << sendFrame18.data() << std::endl;
    sendFrame18 = sentFrame;
}
void MainWindow::on_btn10_released()
{
    QByteArray sendFrame19 = generateFrame19();
    serialPortObj->clearPort();
    serialPortObj->writePort(sendFrame19.data(),sendFrame19.length());
    connect(timer9,SIGNAL(timeout()),this,SLOT(on_btn10_released()));
    timer9->start(500);
    std::cout << sendFrame19.data() << std::endl;
    timer9->stop();
}
void MainWindow::on_btn11_pressed()
{
    QByteArray sendFrame20 = generateFrame20();
    serialPortObj->clearPort();
    serialPortObj->writePort(sendFrame20.data(),sendFrame20.length());
    connect(timer10,SIGNAL(timeout()),this,SLOT(on_btn11_pressed()));
    timer10->start(500);
    std::cout << sendFrame20.data() << std::endl;
    sendFrame20 = sentFrame;
}
void MainWindow::on_btn11_released()
{
    QByteArray sendFrame21 = generateFrame21();
    serialPortObj->clearPort();
    serialPortObj->writePort(sendFrame21.data(),sendFrame21.length());
    connect(timer10,SIGNAL(timeout()),this,SLOT(on_btn11_released()));
    timer10->start(500);
    std::cout << sendFrame21.data() << std::endl;
    timer10->stop();
}
void MainWindow::on_btn12_pressed()
{
    QByteArray sendFrame22 = generateFrame22();
    serialPortObj->clearPort();
    serialPortObj->writePort(sendFrame22.data(),sendFrame22.length());
    connect(timer11,SIGNAL(timeout()),this,SLOT(on_btn12_pressed()));
    timer11->start(500);
    std::cout << sendFrame22.data() << std::endl;
    sendFrame22 = sentFrame;
}
void MainWindow::on_btn12_released()
{
    QByteArray sendFrame23 = generateFrame23();
    serialPortObj->clearPort();
    serialPortObj->writePort(sendFrame23.data(),sendFrame23.length());
    connect(timer11,SIGNAL(timeout()),this,SLOT(on_btn12_released()));
    timer11->start(500);
    std::cout << sendFrame23.data() << std::endl;
    timer11->stop();
}
void MainWindow::on_btn13_pressed()
{
    QByteArray sendFrame24 = generateFrame24();
    serialPortObj->clearPort();
    serialPortObj->writePort(sendFrame24.data(),sendFrame24.length());
    connect(timer12,SIGNAL(timeout()),this,SLOT(on_btn13_pressed()));
    timer12->start(500);
    std::cout << sendFrame24.data() << std::endl;
    sendFrame24 = sentFrame;
}
void MainWindow::on_btn13_released()
{
    QByteArray sendFrame25 = generateFrame25();
   serialPortObj->clearPort();
   serialPortObj->writePort(sendFrame25.data(),sendFrame25.length());
   connect(timer12,SIGNAL(timeout()),this,SLOT(on_btn13_released()));
   timer12->start(500);
   std::cout << sendFrame25.data() << std::endl;
   timer12->stop();
}
void MainWindow::on_btn14_pressed()
{
    QByteArray sendFrame26 = generateFrame26();
    serialPortObj->clearPort();
    serialPortObj->writePort(sendFrame26.data(),sendFrame26.length());
    connect(timer13,SIGNAL(timeout()),this,SLOT(on_btn14_pressed()));
    timer13->start(500);
    std::cout << sendFrame26.data() << std::endl;
   sendFrame26 = sentFrame;
}
void MainWindow::on_btn14_released()
{
    QByteArray sendFrame27 = generateFrame27();
    serialPortObj->clearPort();
    serialPortObj->writePort(sendFrame27.data(),sendFrame27.length());
    connect(timer13,SIGNAL(timeout()),this,SLOT(on_btn14_released()));
    timer13->start(500);
    std::cout << sendFrame27.data() << std::endl;
    timer13->stop();
}
void MainWindow::on_btn15_pressed()
{
    QByteArray sendFrame28 = generateFrame28();
    serialPortObj->clearPort();
    serialPortObj->writePort(sendFrame28.data(),sendFrame28.length());
    connect(timer14,SIGNAL(timeout()),this,SLOT(on_btn15_pressed()));
    timer14->start(500);
    std::cout << sendFrame28.data() << std::endl;
    sendFrame28 = sentFrame;
}
void MainWindow::on_btn15_released()
{
    QByteArray sendFrame29 = generateFrame29();
    serialPortObj->clearPort();
    serialPortObj->writePort(sendFrame29.data(),sendFrame29.length());
    connect(timer14,SIGNAL(timeout()),this,SLOT(on_btn15_released()));
    timer14->start(500);
    std::cout << sendFrame29.data() << std::endl;
     timer14->stop();
}
void MainWindow::on_btn16_pressed()
{
    QByteArray sendFrame30 = generateFrame30();
    serialPortObj->clearPort();
    serialPortObj->writePort(sendFrame30.data(),sendFrame30.length());
    connect(timer15,SIGNAL(timeout()),this,SLOT(on_btn16_pressed()));
    timer15->start(500);
    std::cout << sendFrame30.data() <<std::endl;
    sendFrame30 = sentFrame;
}
void MainWindow::on_btn16_released()
{
    QByteArray sendFrame31 = generateFrame31();
    serialPortObj->clearPort();
    serialPortObj->writePort(sendFrame31.data(),sendFrame31.length());
    connect(timer15,SIGNAL(timeout()),this,SLOT(on_btn16_released()));
    timer15->start(500);
    std::cout << sendFrame31.data() << std::endl;
    timer15->stop();
}

QByteArray MainWindow::generateFrame()
{
    req.resize(10);req[0]='@';req[1]='0';req[2]='A';req[3]='0';req[4]='0';req[5]='1';req[6]='1';req[7]='1';req[8]='1';req[9]='*';
    return req;
}

QByteArray MainWindow::generateFrame1()
{
    req.resize(10);req[0]='@';req[1]='0';req[2]='B';req[3]='0';req[4]='1';req[5]='1';req[6]='1';req[7]='1';req[8]='2';req[9]='*';
    return req;
}

QByteArray MainWindow::generateFrame2()
{
    req.resize(10);req[0]='@';req[1]='0';req[2]='C';req[3]='0';req[4]='1';req[5]='1';req[6]='1';req[7]='1';req[8]='3';req[9]='*';
    return req;
}

QByteArray MainWindow::generateFrame3()
{
    req.resize(10);req[0]='@';req[1]='0';req[2]='D';req[3]='0';req[4]='1';req[5]='1';req[6]='1';req[7]='1';req[8]='4';req[9]='*';
    return req;
}

QByteArray MainWindow::generateFrame4()
{
    req.resize(10);req[0]='@';req[1]='0';req[2]='A';req[3]='0';req[4]='0';req[5]='0';req[6]='0';req[7]='0';req[8]='0';req[9]='*';
    return req;
}

QByteArray MainWindow::generateFrame5()
{
    req.resize(10);req[0]='@';req[1]='0';req[2]='B';req[3]='0';req[4]='0';req[5]='0';req[6]='0';req[7]='0';req[8]='0';req[9]='*';
    return req;
}

QByteArray MainWindow::generateFrame6()
{
    req.resize(10);req[0]='@';req[1]='0';req[2]='C';req[3]='0';req[4]='0';req[5]='0';req[6]='0';req[7]='0';req[8]='0';req[9]='*';
    return req;
}

QByteArray MainWindow::generateFrame7()
{
    req.resize(10);req[0]='@';req[1]='0';req[2]='D';req[3]='0';req[4]='0';req[5]='0';req[6]='0';req[7]='0';req[8]='0';req[9]='*';
    return req;
}

QByteArray MainWindow::generateFrame8()
{
    req.resize(10);req[0]='@';req[1]='0';req[2]='E';req[3]='0';req[4]='1';req[5]='1';req[6]='1';req[7]='1';req[8]='1';req[9]='*';
    return req;
}
QByteArray MainWindow::generateFrame9()
{
    req.resize(10);req[0]='@';req[1]='0';req[2]='E';req[3]='0';req[4]='0';req[5]='0';req[6]='0';req[7]='0';req[8]='0';req[9]='*';
    return req;
}
QByteArray MainWindow::generateFrame10()
{
    req.resize(10);req[0]='@';req[1]='0';req[2]='F';req[3]='1';req[4]='1';req[5]='1';req[6]='1';req[7]='1';req[8]='1';req[9]='*';
    return req;
}
QByteArray MainWindow::generateFrame11()
{
    req.resize(10);req[0]='@';req[1]='0';req[2]='F';req[3]='0';req[4]='0';req[5]='0';req[6]='0';req[7]='0';req[8]='0';req[9]='*';
    return req;
}

QByteArray MainWindow::generateFrame12()
{
    req.resize(10);req[0]='@';req[1]='0';req[2]='G';req[3]='1';req[4]='1';req[5]='1';req[6]='1';req[7]='1';req[8]='1';req[9]='*';
    return req;
}

QByteArray MainWindow::generateFrame13()
{
    req.resize(10);req[0]='@';req[1]='0';req[2]='G';req[3]='0';req[4]='0';req[5]='0';req[6]='0';req[7]='0';req[8]='0';req[9]='*';
    return req;
}

QByteArray MainWindow::generateFrame14()
{
    req.resize(10);req[0]='@';req[1]='0';req[2]='H';req[3]='1';req[4]='1';req[5]='1';req[6]='1';req[7]='1';req[8]='1';req[9]='*';
    return req;
}
QByteArray MainWindow::generateFrame15()
{
    req.resize(10);req[0]='@';req[1]='0';req[2]='H';req[3]='0';req[4]='0';req[5]='0';req[6]='0';req[7]='0';req[8]='0';req[9]='*';
    return req;
}
QByteArray MainWindow::generateFrame16()
{
    req.resize(10);req[0]='@';req[1]='0';req[2]='I';req[3]='1';req[4]='1';req[5]='1';req[6]='1';req[7]='1';req[8]='1';req[9]='*';
    return req;
}
QByteArray MainWindow::generateFrame17()
{
    req.resize(10);req[0]='@';req[1]='0';req[2]='I';req[3]='0';req[4]='0';req[5]='0';req[6]='0';req[7]='0';req[8]='0';req[9]='*';
    return req;
}
QByteArray MainWindow::generateFrame18()
{
    req.resize(10);req[0]='@';req[1]='0';req[2]='J';req[3]='1';req[4]='1';req[5]='1';req[6]='1';req[7]='1';req[8]='1';req[9]='*';
    return req;
}
QByteArray MainWindow::generateFrame19()
{
    req.resize(10);req[0]='@';req[1]='0';req[2]='J';req[3]='0';req[4]='0';req[5]='0';req[6]='0';req[7]='0';req[8]='0';req[9]='*';
    return req;
}
QByteArray MainWindow::generateFrame20()
{
    req.resize(10);req[0]='@';req[1]='0';req[2]='K';req[3]='1';req[4]='1';req[5]='1';req[6]='1';req[7]='1';req[8]='1';req[9]='*';
    return req;
}
QByteArray MainWindow::generateFrame21()
{
    req.resize(10);req[0]='@';req[1]='0';req[2]='K';req[3]='0';req[4]='0';req[5]='0';req[6]='0';req[7]='0';req[8]='0';req[9]='*';
    return req;
}
QByteArray MainWindow::generateFrame22()
{
    req.resize(10);req[0]='@';req[1]='0';req[2]='L';req[3]='1';req[4]='1';req[5]='1';req[6]='1';req[7]='1';req[8]='1';req[9]='*';
    return req;
}
QByteArray MainWindow::generateFrame23()
{
    req.resize(10);req[0]='@';req[1]='0';req[2]='L';req[3]='0';req[4]='0';req[5]='0';req[6]='0';req[7]='0';req[8]='0';req[9]='*';
    return req;
}
QByteArray MainWindow::generateFrame24()
{
    req.resize(10);req[0]='@';req[1]='0';req[2]='M';req[3]='1';req[4]='1';req[5]='1';req[6]='1';req[7]='1';req[8]='1';req[9]='*';
    return req;
}
QByteArray MainWindow::generateFrame25()
{
    req.resize(10);req[0]='@';req[1]='0';req[2]='M';req[3]='0';req[4]='0';req[5]='0';req[6]='0';req[7]='0';req[8]='0';req[9]='*';
    return req;
}
QByteArray MainWindow::generateFrame26()
{
    req.resize(10);req[0]='@';req[1]='0';req[2]='N';req[3]='1';req[4]='1';req[5]='1';req[6]='1';req[7]='1';req[8]='1';req[9]='*';
    return req;
}
QByteArray MainWindow::generateFrame27()
{
    req.resize(10);req[0]='@';req[1]='0';req[2]='N';req[3]='0';req[4]='0';req[5]='0';req[6]='0';req[7]='0';req[8]='1';req[9]='*';
    return req;
}
QByteArray MainWindow::generateFrame28()
{
    req.resize(10);req[0]='@';req[1]='0';req[2]='O';req[3]='0';req[4]='0';req[5]='0';req[6]='0';req[7]='0';req[8]='1';req[9]='*';
            return req;
}
QByteArray MainWindow::generateFrame29()
{
    req.resize(10);req[0]='@';req[1]='0';req[2]='O';req[3]='0';req[4]='0';req[5]='0';req[6]='0';req[7]='0';req[8]='0';req[9]='*';
    return req;
}
QByteArray MainWindow::generateFrame30()
{
    req.resize(10);req[0]='@';req[1]='0';req[2]='P';req[3]='1';req[4]='1';req[5]='1';req[6]='1';req[7]='1';req[8]='1';req[9]='*';
    return req;
}
QByteArray MainWindow::generateFrame31()
{
    req.resize(10);req[0]='@';req[1]='0';req[2]='P';req[3]='0';req[4]='0';req[5]='0';req[6]='0';req[8]='0';req[8]='0';req[9]='*';
    return req;
}
and for serial.cpp
Code:
#include <stdio.h>
#include "serial.h"
#include "iostream"
#include "QDebug"

using std::cout;
using std::endl;

SerialPort::SerialPort()
{
     fd = -1;
     byteswrite = 0;
     bytesread = 0;
}

 SerialPort::~SerialPort()
 {

 }

 int SerialPort::openPort()
 {
     int fd;
     fd = open("/dev/ttyUSB0",O_RDWR | O_NOCTTY | O_NDELAY);
     if(fd > 0)
     {
         qDebug() << "open success";
     }
     else
         fcntl(fd,F_SETFL,FNDELAY);
     return fd;
 }
 void SerialPort::readPort(char *rbuf, int length)
 {
     int fd;
     bytesread = read(fd,rbuf,10);
 }
 void SerialPort::writePort(char *tbuf, int length)
 {
     int fd;
     byteswrite = write(fd,tbuf,10);
 }
 void SerialPort::setPort(void)
 {
     int fd = openPort();
     tcgetattr(fd, &options);
     if(cfsetispeed(&options,B19200) == -1)
     {
         std::cout << "error input baud rate" << endl;
     }
     if(cfsetospeed(&options,B19200) == -1)
     {
         std::cout << "error output baud rate" << endl;
     }
     cfsetispeed(&options, B19200);
     cfsetospeed(&options, B19200);
     options.c_cflag |= (CLOCAL | CREAD);
     options.c_cflag &= ~CSIZE;
     options.c_cflag |= CS8;
     options.c_cflag &= ~PARENB;
     options.c_cflag &= ~CSTOPB;
     options.c_iflag &= ~INPCK;
     options.c_iflag &= ~(ICANON | ECHO | ECHOE | ISIG);
     options.c_oflag &= ~OPOST;
     tcsetattr(fd, TCSANOW, &options);
     fcntl(fd,F_SETFL,FNDELAY);
 }
 void SerialPort::clearPort()
 {
     int fd;
     tcflush(fd,TCIOFLUSH);
     fflush(NULL);
 }
 
Old 04-20-2012, 12:13 AM   #17
ukiuki
Senior Member
 
Registered: May 2010
Location: Planet Earth
Distribution: Debian
Posts: 1,030

Rep: Reputation: 385Reputation: 385Reputation: 385Reputation: 385
Quote:
Originally Posted by navya View Post
./project line1 : Syntax error : unexpected word (expecting ")")...
I'm not 100% sure but doesn't the parameters for for need the parentheses ( ) ?

here your 1st line:
Code:
for mainwindow.cpp
have you tried this?:
Code:
for (mainwindow.cpp)
Regards
 
Old 04-20-2012, 01:02 AM   #18
pan64
LQ Addict
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 22,781

Rep: Reputation: 7567Reputation: 7567Reputation: 7567Reputation: 7567Reputation: 7567Reputation: 7567Reputation: 7567Reputation: 7567Reputation: 7567Reputation: 7567Reputation: 7567
navya: please post the file named project. Do not post other files! why don't you post it?
 
Old 04-20-2012, 04:59 AM   #19
navya
LQ Newbie
 
Registered: Apr 2012
Posts: 15

Original Poster
Rep: Reputation: Disabled
Code:
#-------------------------------------------------
#
# Project created by QtCreator 2011-10-18T13:39:54
#
#-------------------------------------------------
QT      += core gui
TARGET = project
TEMPLATE = app
DEPENDPATH += .
INCLUDEPATH += .

# Input
HEADERS += mainwindow.h serial.h
FORMS += form1.ui form2.ui form3.ui form4.ui
SOURCES += main.cpp mainwindow.cpp serial.cpp
RESOURCES += resource.qrc
this is the code for project.pro

in qt project,we will get .pro file,.header files,and .cpp files and .qrc files,,which all coding you need..i have posted u all codings...

Last edited by navya; 04-20-2012 at 05:04 AM.
 
Old 04-27-2012, 01:23 AM   #20
navya
LQ Newbie
 
Registered: Apr 2012
Posts: 15

Original Poster
Rep: Reputation: Disabled
request to check it out and reply me..

Code:
computer-cs-2@computer-cs-2-desktop:~$ su
Password: 
root@computer-cs-2-desktop:/home/computer-cs-2# cp -R /home/computer-cs-2/QtSDK/project/ /home/farm
root@computer-cs-2-desktop:/home/computer-cs-2# cd /home/farm
root@computer-cs-2-desktop:/home/farm# ls
buttons  computer-cs-2  examples.desktop  Genx1  project  QtSDK  timer
root@computer-cs-2-desktop:/home/farm# cat .bashrc
export PATH=$PATH:/usr/local/arm/4.3.2/bin
export PATH=$PATH:/opt/FriendlyARM/mini2440/x86-qtopia/qtopia-2.2.0-FriendlyARM/qtopia/bin
qmake="/usr/local/arm/4.3.2/bin/qmake"

root@computer-cs-2-desktop:/home/farm# cd project\
> 
root@computer-cs-2-desktop:/home/farm/project# ls
a1.png    form2.h   form3.ui  main.cpp        mainwindow.h  moc_mainwindow.cpp  project.pro       qrc_resource.o  serial.h    ui_form2.h
form1.h   form2.ui  form4.h   main.o          mainwindow.o  moc_mainwindow.o    project.pro.user  resource.qrc    serial.o    ui_form3.h
form1.ui  form3.h   form4.ui  mainwindow.cpp  Makefile      project             qrc_resource.cpp  serial.cpp      ui_form1.h  ui_form4.h
root@computer-cs-2-desktop:/home/farm/project# rm -r project
root@computer-cs-2-desktop:/home/farm/project# rm -r project.pro
root@computer-cs-2-desktop:/home/farm/project# rm -r project.pro.user 
root@computer-cs-2-desktop:/home/farm/project# rm Makefile 
root@computer-cs-2-desktop:/home/farm/project# rm moc_mainwindow.o
root@computer-cs-2-desktop:/home/farm/project# rm moc_mainwindow.cpp 
root@computer-cs-2-desktop:/home/farm/project# ls
a1.png   form1.ui  form2.ui  form3.ui  form4.ui  main.o          mainwindow.h  qrc_resource.cpp  resource.qrc  serial.h  ui_form1.h  ui_form3.h
form1.h  form2.h   form3.h   form4.h   main.cpp  mainwindow.cpp  mainwindow.o  qrc_resource.o    serial.cpp    serial.o  ui_form2.h  ui_form4.h
root@computer-cs-2-desktop:/home/farm/project# rm main.o
root@computer-cs-2-desktop:/home/farm/project# rm qrc_resource.o
root@computer-cs-2-desktop:/home/farm/project# rm qrc_resource.cpp 
root@computer-cs-2-desktop:/home/farm/project# ls
a1.png   form1.ui  form2.ui  form3.ui  form4.ui  mainwindow.cpp  mainwindow.o  serial.cpp  serial.o    ui_form2.h  ui_form4.h
form1.h  form2.h   form3.h   form4.h   main.cpp  mainwindow.h    resource.qrc  serial.h    ui_form1.h  ui_form3.h
root@computer-cs-2-desktop:/home/farm/project# rm serial.o
root@computer-cs-2-desktop:/home/farm/project# rm mainwindow.o
root@computer-cs-2-desktop:/home/farm/project# ls
a1.png   form1.ui  form2.ui  form3.ui  form4.ui  mainwindow.cpp  resource.qrc  serial.h    ui_form2.h  ui_form4.h
form1.h  form2.h   form3.h   form4.h   main.cpp  mainwindow.h    serial.cpp    ui_form1.h  ui_form3.h
root@computer-cs-2-desktop:/home/farm/project# qmake -project
root@computer-cs-2-desktop:/home/farm/project# qmake project.pro 
root@computer-cs-2-desktop:/home/farm/project# make
/usr/bin/uic-qt4 form2.ui -o ui_form2.h
/usr/bin/uic-qt4 form4.ui -o ui_form4.h
g++ -c -pipe -O2 -Wall -W -D_REENTRANT -DQT_NO_DEBUG -DQT_GUI_LIB -DQT_CORE_LIB -DQT_SHARED -I/usr/share/qt4/mkspecs/linux-g++ -I. -I/usr/include/qt4/QtCore -I/usr/include/qt4/QtGui -I/usr/include/qt4 -I. -I. -I. -o main.o main.cpp
g++ -c -pipe -O2 -Wall -W -D_REENTRANT -DQT_NO_DEBUG -DQT_GUI_LIB -DQT_CORE_LIB -DQT_SHARED -I/usr/share/qt4/mkspecs/linux-g++ -I. -I/usr/include/qt4/QtCore -I/usr/include/qt4/QtGui -I/usr/include/qt4 -I. -I. -I. -o mainwindow.o mainwindow.cpp
g++ -c -pipe -O2 -Wall -W -D_REENTRANT -DQT_NO_DEBUG -DQT_GUI_LIB -DQT_CORE_LIB -DQT_SHARED -I/usr/share/qt4/mkspecs/linux-g++ -I. -I/usr/include/qt4/QtCore -I/usr/include/qt4/QtGui -I/usr/include/qt4 -I. -I. -I. -o serial.o serial.cpp
serial.cpp:33: warning: unused parameter ‘length’
serial.cpp:38: warning: unused parameter ‘length’
serial.cpp: In member function ‘void SerialPort::clearPort()’:
serial.cpp:71: warning: ‘fd’ is used uninitialized in this function
serial.cpp: In member function ‘void SerialPort::writePort(char*, int)’:
serial.cpp:41: warning: ‘fd’ is used uninitialized in this function
serial.cpp: In member function ‘void SerialPort::readPort(char*, int)’:
serial.cpp:36: warning: ‘fd’ is used uninitialized in this function
/usr/bin/moc-qt4 -DQT_NO_DEBUG -DQT_GUI_LIB -DQT_CORE_LIB -DQT_SHARED -I/usr/share/qt4/mkspecs/linux-g++ -I. -I/usr/include/qt4/QtCore -I/usr/include/qt4/QtGui -I/usr/include/qt4 -I. -I. -I. mainwindow.h -o moc_mainwindow.cpp
g++ -c -pipe -O2 -Wall -W -D_REENTRANT -DQT_NO_DEBUG -DQT_GUI_LIB -DQT_CORE_LIB -DQT_SHARED -I/usr/share/qt4/mkspecs/linux-g++ -I. -I/usr/include/qt4/QtCore -I/usr/include/qt4/QtGui -I/usr/include/qt4 -I. -I. -I. -o moc_mainwindow.o moc_mainwindow.cpp
/usr/bin/rcc -name resource resource.qrc -o qrc_resource.cpp
g++ -c -pipe -O2 -Wall -W -D_REENTRANT -DQT_NO_DEBUG -DQT_GUI_LIB -DQT_CORE_LIB -DQT_SHARED -I/usr/share/qt4/mkspecs/linux-g++ -I. -I/usr/include/qt4/QtCore -I/usr/include/qt4/QtGui -I/usr/include/qt4 -I. -I. -I. -o qrc_resource.o qrc_resource.cpp
g++ -Wl,-O1 -o project main.o mainwindow.o serial.o moc_mainwindow.o qrc_resource.o    -L/usr/lib -lQtGui -lQtCore -lpthread 
root@computer-cs-2-desktop:/home/farm/project# ping 192.168.1.230
PING 192.168.1.230 (192.168.1.230) 56(84) bytes of data.
64 bytes from 192.168.1.230: icmp_seq=1 ttl=241 time=66.1 ms
64 bytes from 192.168.1.230: icmp_seq=2 ttl=241 time=76.2 ms
64 bytes from 192.168.1.230: icmp_seq=3 ttl=241 time=72.7 ms
^C
--- 192.168.1.230 ping statistics ---
3 packets transmitted, 3 received, 0% packet loss, time 2002ms
rtt min/avg/max/mdev = 66.160/71.702/76.208/4.178 ms
root@computer-cs-2-desktop:/home/farm/project# ftp 192.168.1.230
^Croot@computer-cs-2-desktop:/home/farm/project# ifconfig eth0 192.168.1.1 netmask 255.255.255.0
root@computer-cs-2-desktop:/home/farm/project# ftp 192.168.1.230
Connected to 192.168.1.230.
220 FriendlyARM FTP server (Version 6.4/OpenBSD/Linux-ftpd-0.17) ready.
Name (192.168.1.230:computer-cs-2): root
331 Password required for root.
Password:
230 User root logged in.
Remote system type is UNIX.
Using binary mode to transfer files.
ftp> ls
200 PORT command successful.
150 Opening ASCII mode data connection for '/bin/ls'.
-rw-r--r--    1 root     root          436 Jan  1  1970 .ash_history
-rw-r--r--    1 root     root            0 Jan  1 08:00 1?[=1?[
-rw-r--r--    1 root     root            0 Jan  1 08:00 4[4
drwxr-xr-x    1 root     root         2048 Mar  4  2011 bin
drwxr-xr-x    7 root     root            0 Jan  1 08:00 dev
drwxr-xr-x    1 root     root         2048 Jan  1 08:14 etc
drwxr-xr-x    1 root     root         2048 Jul  5  2007 home
drwxr-xr-x    1 root     root         2048 Mar  4  2011 lib
lrwxrwxrwx    1 root     root           11 Mar  4  2011 linuxrc -> bin/busybox
drwx------    1 root     root         2048 Jan  1 08:00 lost+found
drwxr-xr-x    1 root     root         2048 Jan  5  2010 mnt
drwxr-xr-x    1 root     root         2048 Mar  4  2011 opt
dr-xr-xr-x   39 root     root            0 Jan  1 08:00 proc
-rw-r-----    1 root     root       105243 Jan  1 08:11 project
drwxr-xr-x    1 root     root         2048 Jan  1 08:28 root
drwxr-xr-x    1 root     root         2048 Mar  4  2011 sbin
drwxr-xr-x   11 root     root            0 Jan  1 08:00 sys
drwxr-xr-x    2 root     root            0 Jan  1 08:00 tmp
drwxr-xr-x    1 root     root         2048 Mar  4  2011 usr
drwxr-xr-x    7 root     root            0 Jan  1 08:00 var
drwx------    1 root     root         2048 Apr  1  2009 www
226 Transfer complete.
ftp> cd /root
250 CWD command successful.
ftp> ls
200 PORT command successful.
150 Opening ASCII mode data connection for '/bin/ls'.
drwx------    1 root     root         2048 Mar 26  2009 .kde
drwxr-xr-x    1 root     root         2048 Feb 11  2024 Applications
drwxr-x---    1 root     root         2048 Jan  1 08:28 CEPLapps
drwxr-xr-x    1 root     root         2048 Jan  6  2010 Documents
-rwxr-x--x    1 root     root       546567 Jan  1  1970 Genx1
drwxr-xr-x    1 root     root         2048 Jan  1 08:00 Settings
-rw-r--r--    1 root     root            1 Jan  1 08:28 etc
-rwxr-x--x    1 root     root       105243 Jan  1  1970 project
drwxr-xr-x    1 root     root         2048 Jan  1 08:00 tmp
226 Transfer complete.
ftp> send project
local: project remote: project
200 PORT command successful.
150 Opening BINARY mode data connection for 'project'.
226 Transfer complete.
105243 bytes sent in 0.02 secs (4202.7 kB/s)
ftp> bye
221 Goodbye.
root@computer-cs-2-desktop:/home/farm/project# telnet 192.168.1.230
Trying 192.168.1.230...
Connected to 192.168.1.230.
Escape character is '^]'.

Kernel 2.6.32.2-FriendlyARM on (/dev/pts/0)
FriendlyARM login: root
Password: 
[root@FriendlyARM /]# ls
1?[=1?[     bin         etc         lib         lost+found  opt         project     sbin        tmp         var
4[4         dev         home        linuxrc     mnt         proc        root        sys         usr         www
[root@FriendlyARM /]# cd /root
[root@FriendlyARM /root]# ls
Applications  CEPLapps      Documents     Genx1         Settings      etc           project       tmp
[root@FriendlyARM /root]# chmod +x project
[root@FriendlyARM /root]# ls
Applications  CEPLapps      Documents     Genx1         Settings      etc           project       tmp
[root@FriendlyARM /root]# export TSLIB_TSEVENTTYPE=INPUT
[root@FriendlyARM /root]# 
[root@FriendlyARM /root]# export TSLIB_CONSOLEDEVICE=none
[root@FriendlyARM /root]# 
[root@FriendlyARM /root]# export TSLIB_FBDEVICE=/dev/fb0
[root@FriendlyARM /root]# 
[root@FriendlyARM /root]# export TSLIB_TSDEVICE=/dev/touchscreen-1wire
[root@FriendlyARM /root]#                                             
[root@FriendlyARM /root]# export TSLIB_CALIBFILE=/etc/pointercal
[root@FriendlyARM /root]#                                       
[root@FriendlyARM /root]# export TSLIB_CONFFILE=/etc/ts.conf
[root@FriendlyARM /root]#                                   
[root@FriendlyARM /root]# export TSLIB_PLUGINDIR=/usr/lib/ts
[root@FriendlyARM /root]#                                   
[root@FriendlyARM /root]# export LD_LIBRARY_PATH=/usr/local/Trolltech/QtEmbedded-4.7.0-arm/lib
[root@FriendlyARM /root]#                                                                     
[root@FriendlyARM /root]# export QTDIR=/usr/local/Trolltech/QtEmbedded-4.7.0-arm
[root@FriendlyARM /root]#                                                       
[root@FriendlyARM /root]# export QWS_MOUSE_PROTO=tslib:/dev/touchscreen-1wire
[root@FriendlyARM /root]#                                                    
[root@FriendlyARM /root]# export QWS_SIZE='480x272'
[root@FriendlyARM /root]# cd
[root@FriendlyARM /]# ls
1?[=1?[     bin         etc         lib         lost+found  opt         project     sbin        tmp         var
4[4         dev         home        linuxrc     mnt         proc        root        sys         usr         www
[root@FriendlyARM /]# cd /root
[root@FriendlyARM /root]# ls
Applications  CEPLapps      Documents     Genx1         Settings      etc           project       tmp
[root@FriendlyARM /root]# ./project -qws
./project: line 1: syntax error: "(" unexpected
[root@FriendlyARM /root]# ls
Applications  CEPLapps      Documents     Genx1         Settings      etc           project       tmp
[root@FriendlyARM /root]# exit
Connection closed by foreign host.
root@computer-cs-2-desktop:/home/farm/project# telnet 192.168.1.230
Trying 192.168.1.230...
Connected to 192.168.1.230.
Escape character is '^]'.

Kernel 2.6.32.2-FriendlyARM on (/dev/pts/0)
FriendlyARM login: root
Password: 
[root@FriendlyARM /]# ls
1?[=1?[     bin         etc         lib         lost+found  opt         project     sbin        tmp         var
4[4         dev         home        linuxrc     mnt         proc        root        sys         usr         www
[root@FriendlyARM /]# cd /root
[root@FriendlyARM /root]# ls
Applications  CEPLapps      Documents     Genx1         Settings      etc           project       tmp
[root@FriendlyARM /root]# cd CEPLapps
[root@FriendlyARM CEPLapps]# ls
project
[root@FriendlyARM CEPLapps]# export TSLIB_TSEVENTTYPE=INPUT
[root@FriendlyARM CEPLapps]# 
[root@FriendlyARM CEPLapps]# export TSLIB_CONSOLEDEVICE=none
[root@FriendlyARM CEPLapps]# 
[root@FriendlyARM CEPLapps]# export TSLIB_FBDEVICE=/dev/fb0
[root@FriendlyARM CEPLapps]# 
[root@FriendlyARM CEPLapps]# export TSLIB_TSDEVICE=/dev/touchscreen-1wire
[root@FriendlyARM CEPLapps]#                                             
[root@FriendlyARM CEPLapps]# export TSLIB_CALIBFILE=/etc/pointercal
[root@FriendlyARM CEPLapps]#                                       
[root@FriendlyARM CEPLapps]# export TSLIB_CONFFILE=/etc/ts.conf
[root@FriendlyARM CEPLapps]#                                   
[root@FriendlyARM CEPLapps]# export TSLIB_PLUGINDIR=/usr/lib/ts
[root@FriendlyARM CEPLapps]#                                   
[root@FriendlyARM CEPLapps]# export LD_LIBRARY_PATH=/usr/local/Trolltech/QtEmbedded-4.7.0-arm/lib
[root@FriendlyARM CEPLapps]#                                                                     
[root@FriendlyARM CEPLapps]# export QTDIR=/usr/local/Trolltech/QtEmbedded-4.7.0-arm
[root@FriendlyARM CEPLapps]#                                                       
[root@FriendlyARM CEPLapps]# export QWS_MOUSE_PROTO=tslib:/dev/touchscreen-1wire
[root@FriendlyARM CEPLapps]#                                                    
[root@FriendlyARM CEPLapps]# export QWS_SIZE='480x272'
[root@FriendlyARM CEPLapps]# ls
project
[root@FriendlyARM CEPLapps]# rm project
[root@FriendlyARM CEPLapps]# ls
[root@FriendlyARM CEPLapps]# cd .root
-sh: cd: can't cd to .root
[root@FriendlyARM CEPLapps]# cd /root
[root@FriendlyARM /root]# ls
Applications  CEPLapps      Documents     Genx1         Settings      etc           project       tmp
[root@FriendlyARM /root]# cd CEPLapps
[root@FriendlyARM CEPLapps]# export TSLIB_TSEVENTTYPE=INPUT
[root@FriendlyARM CEPLapps]# 
[root@FriendlyARM CEPLapps]# export TSLIB_CONSOLEDEVICE=none
[root@FriendlyARM CEPLapps]# 
[root@FriendlyARM CEPLapps]# export TSLIB_FBDEVICE=/dev/fb0
[root@FriendlyARM CEPLapps]# 
[root@FriendlyARM CEPLapps]# export TSLIB_TSDEVICE=/dev/touchscreen-1wire
[root@FriendlyARM CEPLapps]#                                             
[root@FriendlyARM CEPLapps]# export TSLIB_CALIBFILE=/etc/pointercal
[root@FriendlyARM CEPLapps]#                                       
[root@FriendlyARM CEPLapps]# export TSLIB_CONFFILE=/etc/ts.conf
[root@FriendlyARM CEPLapps]#                                   
[root@FriendlyARM CEPLapps]# export TSLIB_PLUGINDIR=/usr/lib/ts
[root@FriendlyARM CEPLapps]#                                   
[root@FriendlyARM CEPLapps]# export LD_LIBRARY_PATH=/usr/local/Trolltech/QtEmbedded-4.7.0-arm/lib
[root@FriendlyARM CEPLapps]#                                                                     
[root@FriendlyARM CEPLapps]# export QTDIR=/usr/local/Trolltech/QtEmbedded-4.7.0-arm
[root@FriendlyARM CEPLapps]#                                                       
[root@FriendlyARM CEPLapps]# export QWS_MOUSE_PROTO=tslib:/dev/touchscreen-1wire
[root@FriendlyARM CEPLapps]#                                                    
[root@FriendlyARM CEPLapps]# export QWS_SIZE='480x272'
[root@FriendlyARM CEPLapps]# cd  
[root@FriendlyARM /]# cd /root
[root@FriendlyARM /root]# ls
Applications  CEPLapps      Documents     Genx1         Settings      etc           project       tmp
[root@FriendlyARM /root]# chmod +x project
[root@FriendlyARM /root]# ./project -qws
./project: line 1: syntax error: "(" unexpected
[root@FriendlyARM /root]# exit
Connection closed by foreign host.
root@computer-cs-2-desktop:/home/farm/project# ./project
QGtkStyle was unable to detect the current GTK+ theme.
Qt: Session management error: None of the authentication protocols specified are supported
root@computer-cs-2-desktop:/home/farm/project# telnet 192.168.1.230
Trying 192.168.1.230...
Connected to 192.168.1.230.
Escape character is '^]'.

Kernel 2.6.32.2-FriendlyARM on (/dev/pts/0)
FriendlyARM login: root
Password: 
[root@FriendlyARM /]# ls
1?[=1?[     bin         etc         lib         lost+found  opt         project     sbin        tmp         var
4[4         dev         home        linuxrc     mnt         proc        root        sys         usr         www
[root@FriendlyARM /]# cd /root
[root@FriendlyARM /root]# ls
Applications  CEPLapps      Documents     Genx1         Settings      etc           project       tmp
[root@FriendlyARM /root]# chmod +x project
[root@FriendlyARM /root]# ls
Applications  CEPLapps      Documents     Genx1         Settings      etc           project       tmp
[root@FriendlyARM /root]# cd CEPLapps
[root@FriendlyARM CEPLapps]# export TSLIB_TSEVENTTYPE=INPUT
[root@FriendlyARM CEPLapps]# 
[root@FriendlyARM CEPLapps]# export TSLIB_CONSOLEDEVICE=none
[root@FriendlyARM CEPLapps]# 
[root@FriendlyARM CEPLapps]# export TSLIB_FBDEVICE=/dev/fb0
[root@FriendlyARM CEPLapps]# 
[root@FriendlyARM CEPLapps]# export TSLIB_TSDEVICE=/dev/touchscreen-1wire
[root@FriendlyARM CEPLapps]#                                             
[root@FriendlyARM CEPLapps]# export TSLIB_CALIBFILE=/etc/pointercal
[root@FriendlyARM CEPLapps]#                                       
[root@FriendlyARM CEPLapps]# export TSLIB_CONFFILE=/etc/ts.conf
[root@FriendlyARM CEPLapps]#                                   
[root@FriendlyARM CEPLapps]# export TSLIB_PLUGINDIR=/usr/lib/ts
[root@FriendlyARM CEPLapps]#                                   
[root@FriendlyARM CEPLapps]# export LD_LIBRARY_PATH=/usr/local/Trolltech/QtEmbedded-4.7.0-arm/lib
[root@FriendlyARM CEPLapps]#                                                                     
[root@FriendlyARM CEPLapps]# export QTDIR=/usr/local/Trolltech/QtEmbedded-4.7.0-arm
[root@FriendlyARM CEPLapps]#                                                       
[root@FriendlyARM CEPLapps]# export QWS_MOUSE_PROTO=tslib:/dev/touchscreen-1wire
[root@FriendlyARM CEPLapps]#                                                    
[root@FriendlyARM CEPLapps]# export QWS_SIZE='480x272'
[root@FriendlyARM CEPLapps]# ls
[root@FriendlyARM CEPLapps]# cd
[root@FriendlyARM /]# cd /root
[root@FriendlyARM /root]# ls
Applications  CEPLapps      Documents     Genx1         Settings      etc           project       tmp
[root@FriendlyARM /root]# ./project -qws
./project: line 1: syntax error: "(" unexpected

hello everyone,the above post is my code for deploying applications from pc to mini 2440,,here everything is working fine....but at end in -qws command its showing syntax error...i googled so much from past 10 days..but is it of no use...can anyone help me to come out of this error..thanks in advance

Regards,
Navya
 
Old 04-27-2012, 01:28 AM   #21
pan64
LQ Addict
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 22,781

Rep: Reputation: 7567Reputation: 7567Reputation: 7567Reputation: 7567Reputation: 7567Reputation: 7567Reputation: 7567Reputation: 7567Reputation: 7567Reputation: 7567Reputation: 7567
why can't you understand you need to post the file named project. Nothing else. project.pro or any other file will not help.
As I see the file is located in /root, so please show us the file /root/project (without any extension).
 
Old 04-27-2012, 02:14 AM   #22
navya
LQ Newbie
 
Registered: Apr 2012
Posts: 15

Original Poster
Rep: Reputation: Disabled
the file project is inside the root of friendly arm,how can i post u....
Code:
root@computer-cs-2-desktop:/home/computer-cs-2# telnet 192.168.1.230Trying 192.168.1.230...
Connected to 192.168.1.230.
Escape character is '^]'.

Kernel 2.6.32.2-FriendlyARM on (/dev/pts/3)
FriendlyARM login: root
Password: 
[root@FriendlyARM /]# ls
1?[=1?[     etc         lost+found  project     tmp
4[4         home        mnt         root        usr
bin         lib         opt         sbin        var
dev         linuxrc     proc        sys         www
[root@FriendlyARM /]# cd project
-sh: cd: can't cd to project
[root@FriendlyARM /]# chmod +x project
[root@FriendlyARM /]# cd /root
[root@FriendlyARM /root]# ls
Applications  Documents     Settings      project
CEPLapps      Genx1         etc           tmp
[root@FriendlyARM /root]#



in case,if i give command as :[root@FriendlyARM /]# vi project
you can see only this ^?ELF^A^A^A^@^@^@^@^@^@^@^@^@^B^@^C^@^A^@^@^@ .^D^H4^@^@^@ c^A^@^@^@^@^@4^@ ^@ ^@(^@ ^@^]^@^F^@^@^@4^@^@^@4.^D^H4.^D^H ^A^@^@ ^A^@^@^E^@^@^@^D^@^@^@^C^@^@^@T^A^@^@T.^D
^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@u^@^@^@^@^@^@^@^@^@^@^@^@^@^@^ @^@^@^@^@v^@^@^@T^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@O^@^@
^AU^AI^A^M.^U^E^PAh.^M.^B(a`* .^@^A!...E^@^@^@^@^@^@^@^@<^@^@^@=^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@>^@^@^@^@^@^@^@^@^@^@^@^@^@^ @^@^@^@^@^@^@^@^@^@?^@^@^@^@
..os.W!..^@i...[.3.^M..i.qG^Tu.9[CE..yIk.e..%.........^_..^GBTD .."...,;......,.^]k....|T.3.)E.L.[6^F.^K..^Q1J?.c.....MI......^N. {..!.7K_..^Fge....^..^Z....^N..^Xo.*.L
^@^@^@^@^@^@^@^@^@^@^R^@^@^@q^N^@^@^@^@^@^@^@^@^@^@^R^@^@^@.^A^@^@^@^@^@^@^@^@^@^@^R^@^@^@f^@^@^@^@^ @^@^@^@^@^@^@^R^@^@^@M^K^@^@^@^@^@^@^@^@^@^@^R^@^@^@.^M^@^@^@^@^@^@^
^@^@^@^@^@^@^@^@^@^@^R^@^@^@.^K^@^@^@^@^@^@^@^@^@^@^R^@^@^@.^L^@^@^@^@^@^@^@^@^@^@^R^@^@^@x^N^@^@^@^ @^@^@^@^@^@^@^R^@^@^@,^M^@^@^@^@^@^@^@^@^@^@^R^@^@^@. ^@^@^@^@
^A^@^@^@^@^@^@^@^@^@^@ ^@^@^@.^F^@^@^@^@^@^@^@^@^@^@^R^@^@^@&^@^@^@^@^@^@^@^@^@^@^@^R^@^@^@.^B^@^@^@^@^@^@^@^@^@^@^R^@^@^@9 ^B^@^@^@^@^@^@^@^@^@^@^R^@^@^@^^ ^@^@..^D
^@^@..^D^H^@^@^@^@^R^@^@^@^D
^@^@..^D^H^@^@^@^@^R^@^@^@^_^F^@^@(.^D^H^@^@^@^@^R^@^@^@.^K^@^@^X.^D^H^@^@^@^@^R^@^@^@b^N^@^@..^E^H^ D^@^@^@^Q^@^P^@U^B^@^@H.^D^H^@^@^@^@^R^@^@^@.^D^@^@..^D^H^@^@^@^@^R^
^@^@X.^D^H^@^@^@^@^R^@^@^@1^L^@^@..^D^H^@^@^@^@^R^@^@^@.^C^@^@8.^D^H^@^@^@^@^R^@^@^@.^E^@^@8.^D^H^@^ @^@^@^R^@^@^@.^K^@^@..^D^H^@^@^@^@^R^@^@^@.^A^@^@..^E^H^T^@^@^@^Q^@^
^@^@(.^D^H^@^@^@^@^R^@^@^@^D^N^@^@^H.^D^H^@^@^@^@^R^@^@^@.^@^@^@..^D^H^@^@^@^@^R^@^@^@.^D^@^@..^D^H^ @^@^@^@^R^@^@^@.^H^@^@..^D^H^@^@^@^@^R^@^@^@.^L^@^@..^E^H,^@^@^@!^@^
^@^@H.^D^H^@^@^@^@^R^@^@^@"^M^@^@ .^E^H.^@^@^@^Q^@^[^@= ^@^@..^D^H^@^@^@^@^R^@^@^@. ^@^@..^D^H^@^@^@^@^R^@^@^@.^F^@^@^X.^D^H^@^@^@^@^R^@^@^@.^E^@^@..^D^H^@^@^@^@^R^
^@^@^X.^D^H^@^@^@^@^R^@^@^@P^C^@^@X.^D^H^@^@^@^@^R^@^@^@.^K^@^@h.^D^H^@^@^@^@^R^@^@^@.^@^@^@..^D^H^@ ^@^@^@^R^@^@^@.^H^@^@8.^D^H^@^@^@^@^R^@^@^@^@libQtGui.so.4^@_ZN10QBy
^@^@d.^E^H^G@^@^@h.^E^H^GA^@^@l.^E^H^G=^@^@p.^E^H^Gp^@^@t.^E^H^G^K^@^@x.^E^H^G^L^@^@|.^E^H^G^M^@^@.. ^E^H^GC^@^@..^E^H^G^N^@^@..^E^H^Gw^@^@..^E^H^G^O^@^@..^E^H^GJ^@^@..^
^@^@^@._l.^\$......E..]..E.^@^@^@^@.D$^D@^@^@^@.^D$.1.^@^@.E..]..E.^A^@^@^@.D$^D0^@^@^@.^D$.^T.^@^@.E..]..E.^B^@^@^@.D$^DK^@^@^@.^D$...^@^@.E..]..E.^C^@^@^@.D$^D1^@^@^@
^@^@^@._l.^\$......E..]..E.^@^@^@^@.D$^D@^@^@^@.^D$...^@^@.E..]..E.^A^@^@^@.D$^D0^@^@^@.^D$...^@^@.E..]..E.^B^@^@^@.D$^DJ^@^@^@.^D$...^@^@.E..]..E.^C^@^@^@.D$^D0^@^@^@.
^@^@^@._l.^\$.&....E..]..E.^@^@^@^@.D$^D@^@^@^@.^D$.q.^@^@.E..]..E.^A^@^@^@.D$^D0^@^@^@.^D$.T.^@^@.E..]..E.^B^@^@^@.D$^DJ^@^@^@.^D$.7.^@^@.E..]..E.^C^@^@^@.D$^D1^@^@^@.
^@^@^@._l.^\$......E..]..E.^@^@^@^@.D$^D@^@^@^@.^D$.^Q.^@^@.E..]..E.^A^@^@^@.D$^D0^@^@^@.^D$...^@^@.E..]..E.^B^@^@^@.D$^DI^@^@^@.^D$...^@^@.E..]..E.^C^@^@^@.D$^D0^@^@^@
^@^@^@._l.^\$.f....E..]..E.^@^@^@^@.D$^D@^@^@^@.^D$...^@^@.E..]..E.^A^@^@^@.D$^D0^@^@^@.^D$...^@^@.E..]..E.^B^@^@^@.D$^DI^@^@^@.^D$.w.^@^@.E..]..E.^C^@^@^@.D$^D1^@^@^@.
^@^@^@._l.^\$.^F....E..]..E.^@^@^@^@.D$^D@^@^@^@.^D$.Q.^@^@.E..]..E.^A^@^@^@.D$^D0^@^@^@.^D$.4.^@^@.E..]..E.^B^@^@^@.D$^DH^@^@^@.^D$.^W.^@^@.E..]..E.^C^@^@^@.D$^D0^@^@^
^@^@^@._l.^\$......E..]..E.^@^@^@^@.D$^D@^@^@^@.^D$...^@^@.E..]..E.^A^@^@^@.D$^D0^@^@^@.^D$...^@^@.E..]..E.^B^@^@^@.D$^DH^@^@^@.^D$...^@^@.E..]..E.^C^@^@^@.D$^D1^@^@^@.
^@^@^@._l.^\$.F....E..]..E.^@^@^@^@.D$^D@^@^@^@.^D$...^@^@.E..]..E.^A^@^@^@.D$^D0^@^@^@.^D$.t.^@^@.E..]..E.^B^@^@^@.D$^DG^@^@^@.^D$.W.^@^@.E..]..E.^C^@^@^@.D$^D0^@^@^@.
^@^@^@._l.^\$......E..]..E.^@^@^@^@.D$^D@^@^@^@.^D$.1.^@^@.E..]..E.^A^@^@^@.D$^D0^@^@^@.^D$.^T.^@^@.E..]..E.^B^@^@^@.D$^DG^@^@^@.^D$...^@^@.E..]..E.^C^@^@^@.D$^D1^@^@^@
^@^@^@._l.^\$......E..]..E.^@^@^@^@.D$^D@^@^@^@.^D$...^@^@.E..]..E.^A^@^@^@.D$^D0^@^@^@.^D$...^@^@.E..]..E.^B^@^@^@.D$^DF^@^@^@.^D$...^@^@.E..]..E.^C^@^@^@.D$^D0^@^@^@.
^@^@^@._l.^\$.&....E..]..E.^@^@^@^@.D$^D@^@^@^@.^D$.q.^@^@.E..]..E.^A^@^@^@.D$^D0^@^@^@.^D$.T.^@^@.E..]..E.^B^@^@^@.D$^DF^@^@^@.^D$.7.^@^@.E..]..E.^C^@^@^@.D$^D1^@^@^@.
^@^@^@._l.^\$......E..]..E.^@^@^@^@.D$^D@^@^@^@.^D$.^Q.^@^@.E..]..E.^A^@^@^@.D$^D0^@^@^@.^D$...^@^@.E..]..E.^B^@^@^@.D$^DE^@^@^@.^D$...^@^@.E..]..E.^C^@^@^@.D$^D0^@^@^@
^@^@^@._l.^\$.f....E..]..E.^@^@^@^@.D$^D@^@^@^@.^D$...^@^@.E..]..E.^A^@^@^@.D$^D0^@^@^@.^D$...^@^@.E..]..E.^B^@^@^@.D$^DE^@^@^@.^D$.w.^@^@.E..]..E.^C^@^@^@.D$^D0^@^@^@.


what to do? please help me..
 
Old 04-27-2012, 02:29 AM   #23
pan64
LQ Addict
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 22,781

Rep: Reputation: 7567Reputation: 7567Reputation: 7567Reputation: 7567Reputation: 7567Reputation: 7567Reputation: 7567Reputation: 7567Reputation: 7567Reputation: 7567Reputation: 7567
so the project file is a binary executable.
ih this case please execute strace -o /tmp/tmpfile ./project -qws
you will get a new file /tmp/tmpfile
you can grep open /tmp/tmpfile for searching files opened by this app. I do not know which one contains ( in the first line.

Last edited by pan64; 04-27-2012 at 02:38 AM. Reason: highlight command
 
Old 04-27-2012, 02:33 AM   #24
navya
LQ Newbie
 
Registered: Apr 2012
Posts: 15

Original Poster
Rep: Reputation: Disabled
ok i will try it out and post u wait

Regards,
Navya
 
Old 04-27-2012, 02:40 AM   #25
navya
LQ Newbie
 
Registered: Apr 2012
Posts: 15

Original Poster
Rep: Reputation: Disabled
Code:
[root@FriendlyARM CEPLapps]# cd
[root@FriendlyARM /]# cd /root
[root@FriendlyARM /root]# ls
Applications  CEPLapps      Documents     Genx1         Settings      etc           project       tmp
[root@FriendlyARM /root]# strace -o /tmp/tmpfile
-sh: strace: not found
[root@FriendlyARM /root]# trace -o /tmp/tmpfile 
-sh: trace: not found
[root@FriendlyARM /root]#
strace or trace command is not found in ubuntu,,wat to do?


Regards,
Navya
 
Old 04-27-2012, 03:04 AM   #26
pan64
LQ Addict
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 22,781

Rep: Reputation: 7567Reputation: 7567Reputation: 7567Reputation: 7567Reputation: 7567Reputation: 7567Reputation: 7567Reputation: 7567Reputation: 7567Reputation: 7567Reputation: 7567
I think strace is available for FriendlyARM, you need to install it first.
the command you need to execute is:
strace -o /tmp/tmpfile ./project -qws
 
Old 04-27-2012, 04:34 AM   #27
navya
LQ Newbie
 
Registered: Apr 2012
Posts: 15

Original Poster
Rep: Reputation: Disabled
hello pan64,
thank you so much for replying me....I am installing that strace file....after that i will try to execute that command,,,let me see that file and post you...
Pls u keep in touch...



Regards,
Navya
 
Old 04-27-2012, 05:11 AM   #28
navya
LQ Newbie
 
Registered: Apr 2012
Posts: 15

Original Poster
Rep: Reputation: Disabled
hello pan64,
i have downloaded and installed the strace in ubuntu...but how to do for mini 2440....without installing strace for mini 2440,i cant run that command in friendly arm ..how to do this



Regards,
Navya
 
Old 04-30-2012, 02:20 PM   #29
carlo_tamtam
LQ Newbie
 
Registered: Apr 2012
Posts: 1

Rep: Reputation: Disabled
Hi Navya,

I had the same problem today, but with hello.c example and arm-linux-gnueabi-gcc-4.5.2,
after I install new virtual machine with Debian and I install arm-linux-gcc-4.4.3.tgz (toolchain of mini2440).

I compile with arm-none-linux-gnueabi-gcc and I send the exe by FTP in transfer type : binary.

If I send the file in transfer type : auto I had a Segmentation fault.

Best Regards
Carlo
 
Old 05-01-2012, 09:58 AM   #30
pan64
LQ Addict
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 22,781

Rep: Reputation: 7567Reputation: 7567Reputation: 7567Reputation: 7567Reputation: 7567Reputation: 7567Reputation: 7567Reputation: 7567Reputation: 7567Reputation: 7567Reputation: 7567
maybe the /root/project file is not an executable for arm
can you check file project and file /bin/bash (or some other available executable) on your mini (not PC)
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
i2c4: line1 : syntax error: unexpected word (expecting " )" ) pillisrikanth Linux - Software 1 12-07-2011 06:18 AM
[SOLVED] line 1: syntax error: word unexpected (expecting ")") me011089 Linux - Embedded & Single-board computer 5 08-23-2011 08:34 AM
Busybox Syntax error: word unexpected (expecting ")") asprakash Linux - Embedded & Single-board computer 6 10-13-2010 02:22 AM
Backup Script error "line 31: syntax error: unexpected end of file" eswanepoel General 7 12-07-2007 09:28 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 03:01 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration