Results 1 to 5 of 5

Thread: Modem communication example

  1. #1
    Join Date
    Sep 2009
    Posts
    4
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Question

    Could someone indicate me which classs should i use for it? And provide me a code example ussing it to communicate with a modem using AT commands?

    I'm trying to send a SMS using a Siemens MC35 GSM modem attached to the
    COM port. I'm able to send an SMS using the hyperterminal using the AT
    commands.

    Thanks

    Sorry, the modem model is:

    DIAMOND SupraExpress56e PRO

    And the platform is windows.

    Thanks
    Last edited by wysota; 3rd September 2009 at 15:22.

  2. #2
    Join Date
    Dec 2008
    Location
    France
    Posts
    93
    Thanked 23 Times in 22 Posts
    Qt products
    Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android

    Default Re: Modem communication example

    Hi,

    Take a look to QextSerialPort at http://qextserialport.sourceforge.net/.
    With that you should be able to send/receive data via a serial port. You have to configure the connexion (same parameters hypeterminal used) and then you can send AT commands, check for response from the modem...

  3. #3
    Join Date
    Sep 2009
    Posts
    4
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Unhappy Re: Modem communication example

    Thank you for the suggested class.
    I am using it, but I am having some problems. This is the code:

    port = new QextSerialPort("COM1");
    port->setBaudRate(BAUD9600);
    port->setFlowControl(FLOW_XONXOFF);
    port->setParity(PAR_NONE);
    port->setDataBits(DATA_8);
    if_error=port->open(QIODevice::ReadWrite);
    if (if_error)
    cout<<"port opened\n";
    else
    {
    cout<<"Error opening the port";
    return a.exec();
    }


    QString command ="AT\r\n"; //sample command - this returns OK
    QByteArray byte;
    byte.clear();
    byte.append(command);
    qDebug()<< byte;
    error_num= port->write(byte);
    cout<<"Number of bytes that were actually written: " << error_num <<"\n";
    if_error=port->waitForBytesWritten (5000);
    if (if_error)
    cout<<"Data Sent\n";
    {
    cout<<"Error sending data: ";
    port_error=port->lastError();
    cout<< port_error <<"\n";
    return a.exec();
    }


    waitForBytesWritten always returns me an Error 0

    Please, any help?

    Thanks

  4. #4
    Join Date
    Dec 2008
    Location
    France
    Posts
    93
    Thanked 23 Times in 22 Posts
    Qt products
    Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android

    Default Re: Modem communication example

    First, try to use [CODE] tags please, your code will be so more readable.

    Then I think you make a mistake with the pasted code, you would probably do this :
    Qt Code:
    1. error_num= port->write(byte);
    2. cout<<"Number of bytes that were actually written: " << error_num <<"\n";
    3. if_error=port->waitForBytesWritten (5000);
    4. if (if_error)
    5. cout<<"Data Sent\n";
    6. else
    7. {
    8. cout<<"Error sending data: ";
    9. port_error=port->lastError();
    10. cout<< port_error <<"\n";
    11. return a.exec();
    12. }
    To copy to clipboard, switch view to plain text mode 

    What string error do you have?

    What is the result of the write(byte) call? If it is equal to your command length just call the waitForReadyRead(5000) in order to wait for the response "OK".

  5. #5
    Join Date
    Dec 2008
    Location
    France
    Posts
    93
    Thanked 23 Times in 22 Posts
    Qt products
    Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android

    Default Re: Modem communication example

    I've just seen on this (good) forum readyFor*() functions are not implemented correctly for this device. http://www.qtcentre.org/forum/f-qt-p...blem-9144.html

    Maybe you have to do some polling?

    Did you try the example in the package, it works fine for me (the last time I tried it). It is a very basic example but if you add a QTimer for polling responses from the modem you will have a "usable" terminal example.

Similar Threads

  1. Problem with QExtSerialPort and a usb modem
    By Althor in forum Qt Programming
    Replies: 4
    Last Post: 31st October 2008, 12:02
  2. serial communication problem
    By Tavit in forum Qt Programming
    Replies: 3
    Last Post: 31st May 2008, 12:56
  3. accessing the GSM modem using serialport in windows OS
    By jjbabu in forum Qt Programming
    Replies: 11
    Last Post: 31st December 2007, 11:38
  4. Data communication between multiple computers
    By AlbertGoodwill in forum Newbie
    Replies: 2
    Last Post: 8th October 2007, 13:44
  5. How to transfer file through serial communication
    By shamik in forum Qt Programming
    Replies: 29
    Last Post: 29th May 2007, 10:22

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.