Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Unicode character to readable format
Forum Updated to NodeBB v4.3 + New Features

Unicode character to readable format

Scheduled Pinned Locked Moved Solved General and Desktop
24 Posts 6 Posters 5.9k Views 3 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • E eswar

    Hi

    Check the sample code for receiving data in the serial port.

    connect(port,&QSerialPort::readyRead,this,&WeighingMachine::readData);

    buffer is QByteArray datatype.

    void WeighingMachine::readData()
    {
    QString Time = QTime::currentTime().toString("hh:mm:ss.zzz");

    while(!(port->atEnd()))
    {
        buffer.append(port->readAll());
    
        int i =0;
        QByteArray temp;
        int len = buffer.length();
    

    #ifdef QT_DEBUG
    qDebug()<<"Buffer: "<< QString::fromUtf8(buffer);;
    #endif

        while(i<len)
        {
    
            if ((buffer.at(i)== '\r') && (temp.length() > 0))
            {
                QString str(temp);
                QString Find = "\n";
                QString replace = "";
                str.replace(str.indexOf(Find),Find.size(),replace);
                weighingMachineData = Time +"," +str;
    

    #ifdef QT_DEBUG
    // qDebug()<<"Weighing Data: "<<weighingMachineData;
    #endif

                temp.clear();
            }
            else
            {
                temp.append(buffer.at(i));
            }
    
            i++;
        }
        buffer.clear();
        buffer.append(temp);
        temp.clear();
    }
    

    }

    For your information, I also receive the same data in cutecom terminal also.

    aha_1980A Offline
    aha_1980A Offline
    aha_1980
    Lifetime Qt Champion
    wrote on last edited by
    #14

    @eswar said in Unicode character to readable format:

    #ifdef QT_DEBUG
    qDebug()<<"Buffer: "<< QString::fromUtf8(buffer);;
    #endif

    Please change that to: qDebug() << "Buffer:" << buffer << "hex:" << buffer.toHex(); and post the output here.

    Thanks.

    Qt has to stay free or it will die.

    1 Reply Last reply
    1
    • E Offline
      E Offline
      eswar
      wrote on last edited by
      #15

      @aha_1980

      Please refer the following image
      0_1548234468992_linux1.png

      aha_1980A 1 Reply Last reply
      0
      • E eswar

        @aha_1980

        Please refer the following image
        0_1548234468992_linux1.png

        aha_1980A Offline
        aha_1980A Offline
        aha_1980
        Lifetime Qt Champion
        wrote on last edited by
        #16

        @eswar That is really strange - all these characters are outside the visible ASCII range.

        • Do you have a documentation for the command set of the device you are talking with?
        • Can you repeat the last qDebug() tests in Windows?
        • Are you sure the serial parameters (baudrate, start, stop bits, parity) are correct in Linux?

        Qt has to stay free or it will die.

        1 Reply Last reply
        0
        • E Offline
          E Offline
          eswar
          wrote on last edited by
          #17

          Hi @aha_1980

          Please refer below images for windows output
          0_1548239849949_Windows.JPG

          serial parameters are same for both linux and windows.
          In device documentation, transmission data format is mentioned as 8 bit ASCII format.

          aha_1980A 1 Reply Last reply
          0
          • E eswar

            Hi @aha_1980

            Please refer below images for windows output
            0_1548239849949_Windows.JPG

            serial parameters are same for both linux and windows.
            In device documentation, transmission data format is mentioned as 8 bit ASCII format.

            aha_1980A Offline
            aha_1980A Offline
            aha_1980
            Lifetime Qt Champion
            wrote on last edited by
            #18

            @eswar Something is terribly wrong in Linux - I'd blame the serial parameters.

            You need to find the culprit before you can continue.

            Best start with a terminal program in Linux and see if you can receive the data correctly there.

            Qt has to stay free or it will die.

            1 Reply Last reply
            0
            • E Offline
              E Offline
              eswar
              wrote on last edited by
              #19

              @aha_1980

              Thanks for the support.

              Cutecom was also receive the same thing. So only i am not able to find the problem. Find below,
              0_1548240335682_cutecom.JPG

              aha_1980A 1 Reply Last reply
              0
              • E eswar

                @aha_1980

                Thanks for the support.

                Cutecom was also receive the same thing. So only i am not able to find the problem. Find below,
                0_1548240335682_cutecom.JPG

                aha_1980A Offline
                aha_1980A Offline
                aha_1980
                Lifetime Qt Champion
                wrote on last edited by
                #20

                @eswar

                Ok, so some more questions:

                • Is this Linux system a regular PC? Is it the same running Windows?
                • How do you connect the device to the PC? True RS-232, or USB (like FTDI?)
                • Is the external device properly powered?

                Qt has to stay free or it will die.

                E 1 Reply Last reply
                1
                • SGaistS Offline
                  SGaistS Offline
                  SGaist
                  Lifetime Qt Champion
                  wrote on last edited by
                  #21

                  To add to @aha_1980, are you using the same device for development on both platforms ?

                  Interested in AI ? www.idiap.ch
                  Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                  1 Reply Last reply
                  2
                  • aha_1980A aha_1980

                    @eswar

                    Ok, so some more questions:

                    • Is this Linux system a regular PC? Is it the same running Windows?
                    • How do you connect the device to the PC? True RS-232, or USB (like FTDI?)
                    • Is the external device properly powered?
                    E Offline
                    E Offline
                    eswar
                    wrote on last edited by
                    #22

                    @aha_1980
                    The linux system is regular laptop and windows is another laptop.
                    The device is connected via USB( converter is used to covert the serial RS-232 to USB)
                    The external device is properly powered using separate power supply.

                    @aha_1980

                    Same device is used to development on both platforms. The previous attached screenshot are taken same value in device for both linux and windows platform.

                    1 Reply Last reply
                    0
                    • SGaistS Offline
                      SGaistS Offline
                      SGaist
                      Lifetime Qt Champion
                      wrote on last edited by
                      #23

                      Might be a silly question but did you try to connect it to another Linux station to see if it gives you the same results ?

                      Interested in AI ? www.idiap.ch
                      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                      1 Reply Last reply
                      1
                      • E Offline
                        E Offline
                        eswar
                        wrote on last edited by eswar
                        #24

                        Hi @SGaist and @aha_1980

                        The issue was solved. Its related to linux OS problem. Its will work well with linux mint 19 OS. Before the earlier version of linux, the data received as encoded format only. In Linux mint 19, it will work fine in both cutecom as well as Qt application. Thanks for the support to solve the issue.

                        1 Reply Last reply
                        2

                        • Login

                        • Login or register to search.
                        • First post
                          Last post
                        0
                        • Categories
                        • Recent
                        • Tags
                        • Popular
                        • Users
                        • Groups
                        • Search
                        • Get Qt Extensions
                        • Unsolved