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. [PLEASE HELP] how to make a barcode receiver?
Forum Updated to NodeBB v4.3 + New Features

[PLEASE HELP] how to make a barcode receiver?

Scheduled Pinned Locked Moved Solved General and Desktop
57 Posts 9 Posters 14.3k Views 4 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.
  • JKSHJ JKSH

    @davidlabib said in [PLEASE HELP] how to make a barcode receiver?:

    can you help me on setting the right mod and use QtSerialPort

    If you want to use Qt Serial Port, choose the RS-232 option. You will also need to connect the barcode scanner to a serial port on your computer.

    ? Offline
    ? Offline
    A Former User
    wrote on last edited by
    #31

    @JKSH is it must came from serial port not usb?

    JKSHJ 1 Reply Last reply
    0
    • ? A Former User

      @JKSH is it must came from serial port not usb?

      JKSHJ Online
      JKSHJ Online
      JKSH
      Moderators
      wrote on last edited by
      #32

      @davidlabib said in [PLEASE HELP] how to make a barcode receiver?:

      is it must came from serial port not usb?

      Qt Serial Port works with serial ports. A USB port is not a serial port.

      If your computer doesn't have a serial port, you can use a USB-to-serial converter.

      Qt Doc Search for browsers: forum.qt.io/topic/35616/web-browser-extension-for-improved-doc-searches

      mrjjM raven-worxR 2 Replies Last reply
      4
      • JKSHJ JKSH

        @davidlabib said in [PLEASE HELP] how to make a barcode receiver?:

        is it must came from serial port not usb?

        Qt Serial Port works with serial ports. A USB port is not a serial port.

        If your computer doesn't have a serial port, you can use a USB-to-serial converter.

        mrjjM Offline
        mrjjM Offline
        mrjj
        Lifetime Qt Champion
        wrote on last edited by
        #33

        @JKSH
        Hi
        this mode, i wonder if
        alt text

        does not install a virtual comport and allows to use usb connection much like
        serial over USB converter. just without the converter.

        What do you think ? ( purely guessing here)

        1 Reply Last reply
        3
        • JKSHJ JKSH

          @davidlabib said in [PLEASE HELP] how to make a barcode receiver?:

          is it must came from serial port not usb?

          Qt Serial Port works with serial ports. A USB port is not a serial port.

          If your computer doesn't have a serial port, you can use a USB-to-serial converter.

          raven-worxR Offline
          raven-worxR Offline
          raven-worx
          Moderators
          wrote on last edited by
          #34

          @JKSH said in [PLEASE HELP] how to make a barcode receiver?:

          Qt Serial Port works with serial ports. A USB port is not a serial port.

          thats not true. Of course QtSerialPort works with USB.
          USB = Universal Serial Bus

          The code above i've posted definitively works with a USB Barcode scanner and i used it myself already.

          --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
          If you have a question please use the forum so others can benefit from the solution in the future

          K 1 Reply Last reply
          1
          • raven-worxR raven-worx

            @davidlabib
            use the very first code (RS232).
            Then check the COM port of the scanner it is connected to (e.g. on Windows in the Device Manager).

            in your .pro file add QT += serialport

            QSerialPort example usage:

            QSerialPort* port = new QSerialPort( this );
            port->setBaudRate( QSerialPort::Baud115200 ); // possible something else, also check the manual
            port->setPort( QPortInfo("COM4") ); // COM port - check Device Manager for connected port
            if( port->open(QSerialPort::ReadOnly) )
            {
                    connect(port, &QSerialPort::readyRead, this, [port]() {
                          if( !port->bytesAvailable() )
                               return;
                          const QByteArray scannedData = port->readAll();
                          // ...
                    });
            }
            else
            {
                // check port->error()
            }
            
            ? Offline
            ? Offline
            A Former User
            wrote on last edited by
            #35

            @raven-worx
            0_1534947972491_3255bdcc-2942-41cb-986a-e4f1bb6adf9c-image.png
            I'm using ubuntu now

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

              Hi,

              It's QSerialPortInfo.

              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
              • ? Offline
                ? Offline
                A Former User
                wrote on last edited by
                #37

                0_1534969744372_9c1d0188-4bd4-47a2-9e26-5799df5452cc-image.png

                i dosn't do any thing it always execute "else"
                QSerialPort::SerialPortError(DeviceNotFoundError)

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

                  And what is the error ?

                  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
                  0
                  • raven-worxR raven-worx

                    @JKSH said in [PLEASE HELP] how to make a barcode receiver?:

                    Qt Serial Port works with serial ports. A USB port is not a serial port.

                    thats not true. Of course QtSerialPort works with USB.
                    USB = Universal Serial Bus

                    The code above i've posted definitively works with a USB Barcode scanner and i used it myself already.

                    K Offline
                    K Offline
                    kuzulis
                    Qt Champions 2020
                    wrote on last edited by
                    #39

                    @raven-worx said in [PLEASE HELP] how to make a barcode receiver?:

                    thats not true. Of course QtSerialPort works with USB.
                    USB = Universal Serial Bus

                    What? QtSerialPort works only with serial ports. It has nothing common with USB... Please don't confuse peoples. ;)

                    1 Reply Last reply
                    2
                    • ? A Former User

                      0_1534969744372_9c1d0188-4bd4-47a2-9e26-5799df5452cc-image.png

                      i dosn't do any thing it always execute "else"
                      QSerialPort::SerialPortError(DeviceNotFoundError)

                      JKSHJ Online
                      JKSHJ Online
                      JKSH
                      Moderators
                      wrote on last edited by JKSH
                      #40

                      @davidlabib said in [PLEASE HELP] how to make a barcode receiver?:

                      QSerialPort::SerialPortError(DeviceNotFoundError)

                      Well, that means your program can't find a port called COM4. Read the comments in @raven-worx's code and think about what they are asking you to do.

                      What is the name of the port that your scanner is connected to? https://www.cyberciti.biz/faq/find-out-linux-serial-ports-with-setserial/

                      @raven-worx said in [PLEASE HELP] how to make a barcode receiver?:

                      The code above i've posted definitively works with a USB Barcode scanner and i used it myself already.

                      My apologies; I didn't read the codes or think of the scenario that @mrjj highlighted in his last post.

                      If the barcode scanner implements RS232-over-USB, then you're right -- Qt Serial Port can indeed work with the scanner via the USB port.

                      QtSerialPort works with USB.
                      USB = Universal Serial Bus

                      Even though they both have "serial" in their names, Universal Serial Bus is completely unrelated to old-school serial ports. The term "serial port" usually refers to an RS-232 port: https://en.wikipedia.org/wiki/Serial_port

                      A USB device can be programmed to emulate serial port comms, but these are the minority. You cannot, for example, use Qt Serial Port to read your USB keyboard.

                      Qt Doc Search for browsers: forum.qt.io/topic/35616/web-browser-extension-for-improved-doc-searches

                      1 Reply Last reply
                      2
                      • ? Offline
                        ? Offline
                        A Former User
                        wrote on last edited by
                        #41

                        @JKSH i didn't worked
                        i tried form com 1 to com 18
                        non of them worked

                        JKSHJ 1 Reply Last reply
                        0
                        • ? A Former User

                          @JKSH i didn't worked
                          i tried form com 1 to com 18
                          non of them worked

                          JKSHJ Online
                          JKSHJ Online
                          JKSH
                          Moderators
                          wrote on last edited by JKSH
                          #42

                          @davidlabib said in [PLEASE HELP] how to make a barcode receiver?:

                          @JKSH i didn't worked
                          i tried form com 1 to com 18
                          non of them worked

                          What is the name of the port that your scanner is connected to? COMX is a Windows name. Linux names are different.

                          Read https://www.cyberciti.biz/faq/find-out-linux-serial-ports-with-setserial/ to find the name on your Ubuntu machine.

                          Qt Doc Search for browsers: forum.qt.io/topic/35616/web-browser-extension-for-improved-doc-searches

                          1 Reply Last reply
                          3
                          • ? Offline
                            ? Offline
                            A Former User
                            wrote on last edited by
                            #43

                            same error
                            i tried from ttyS0 to ttyS5 didn't work

                            JKSHJ 1 Reply Last reply
                            0
                            • ? A Former User

                              same error
                              i tried from ttyS0 to ttyS5 didn't work

                              JKSHJ Online
                              JKSHJ Online
                              JKSH
                              Moderators
                              wrote on last edited by JKSH
                              #44

                              @davidlabib said in [PLEASE HELP] how to make a barcode receiver?:

                              same error
                              i tried from ttyS0 to ttyS5 didn't work

                              You didn't answer my question. What is the name of the port that your scanner is connected to?

                              Also, what does QSerialPortInfo::availablePorts() give you? http://doc.qt.io/qt-5/qserialportinfo.html#availablePorts

                              Qt Doc Search for browsers: forum.qt.io/topic/35616/web-browser-extension-for-improved-doc-searches

                              ? 1 Reply Last reply
                              4
                              • JKSHJ JKSH

                                @davidlabib said in [PLEASE HELP] how to make a barcode receiver?:

                                same error
                                i tried from ttyS0 to ttyS5 didn't work

                                You didn't answer my question. What is the name of the port that your scanner is connected to?

                                Also, what does QSerialPortInfo::availablePorts() give you? http://doc.qt.io/qt-5/qserialportinfo.html#availablePorts

                                ? Offline
                                ? Offline
                                A Former User
                                wrote on last edited by A Former User
                                #45

                                @JKSH ok i could find the right port and passed from

                                if( port->open(QSerialPort::ReadOnly) )
                                

                                now I'm stuck on

                                if( !port->bytesAvailable() )
                                                  return;
                                

                                it always return
                                witch mean no bytes is available

                                JKSHJ 1 Reply Last reply
                                0
                                • ? A Former User

                                  @JKSH ok i could find the right port and passed from

                                  if( port->open(QSerialPort::ReadOnly) )
                                  

                                  now I'm stuck on

                                  if( !port->bytesAvailable() )
                                                    return;
                                  

                                  it always return
                                  witch mean no bytes is available

                                  JKSHJ Online
                                  JKSHJ Online
                                  JKSH
                                  Moderators
                                  wrote on last edited by
                                  #46

                                  @davidlabib said in [PLEASE HELP] how to make a barcode receiver?:

                                  now I'm stuck on

                                  if( !port->bytesAvailable() )
                                                    return;
                                  

                                  it always return
                                  witch mean no bytes is available

                                  Did you choose the correct settings? How is your scanner configured for the following?

                                  • Baud rate
                                  • Parity
                                  • Data bits
                                  • Stop bits
                                  • Flow control

                                  Qt Doc Search for browsers: forum.qt.io/topic/35616/web-browser-extension-for-improved-doc-searches

                                  1 Reply Last reply
                                  0
                                  • ? Offline
                                    ? Offline
                                    A Former User
                                    wrote on last edited by A Former User
                                    #47

                                    @JKSH
                                    Baud rate 115200

                                    aha_1980A 1 Reply Last reply
                                    0
                                    • ? A Former User

                                      @JKSH
                                      Baud rate 115200

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

                                      @davidlabib

                                      I guess you don't have permission to use the serial port.

                                      Please type: ls -l /dev/<your-serial-port-name> in a terminal and post the output here.

                                      Qt has to stay free or it will die.

                                      1 Reply Last reply
                                      1
                                      • ? Offline
                                        ? Offline
                                        A Former User
                                        wrote on last edited by
                                        #49

                                        @aha_1980 yes i don't have
                                        but i use sudo

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

                                          Don't develop as super-user.

                                          The command @aha_1980 will show the user and group affected to the device. Add your own user to that group, then log out and log in again and you will have access to the device.

                                          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
                                          4

                                          • Login

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