[PLEASE HELP] how to make a barcode receiver?
-
the only payment method is cash only (for now), so we can skip 3
It's not very require to make focus when the barcode input something but i thought that it will be a good extra feature in the application
@davidlabib
Hi
The complication of trying to guess if its user typing or scanner input
can be complicated. While often a scan is terminated with same
symbols, you first know later if scan or keypress and hence
makes it complicated to handle.So its actually complicated to make work flawless and hence a
straight way of saying for user. "I want to scan" is often preferred.
As it avoid confusing and guessing. -
the only payment method is cash only (for now), so we can skip 3
It's not very require to make focus when the barcode input something but i thought that it will be a good extra feature in the application
@davidlabib
just a note:
Some barcode scanners have different modes. One mode is "keyboard" mode (like you are using it now) and another can be via the serial interface. The later would let you use QtSerialPort module to receive the scanned code in plain text.
Those modes can be switched by scanning a special barcode. Take a look at the scanners manual. -
@davidlabib
just a note:
Some barcode scanners have different modes. One mode is "keyboard" mode (like you are using it now) and another can be via the serial interface. The later would let you use QtSerialPort module to receive the scanned code in plain text.
Those modes can be switched by scanning a special barcode. Take a look at the scanners manual.wrote on 19 Aug 2018, 12:53 last edited by@raven-worx
can you help me on setting the right mod and use QtSerialPort -
@raven-worx
can you help me on setting the right mod and use QtSerialPort@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.
-
@raven-worx
can you help me on setting the right mod and use QtSerialPort@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() }
-
@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.
wrote on 21 Aug 2018, 23:38 last edited by@JKSH is it must came from serial port not usb?
-
@JKSH is it must came from serial port not usb?
@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.
-
@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.
@JKSH
Hi
this mode, i wonder if
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)
-
@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.
@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 BusThe code above i've posted definitively works with a USB Barcode scanner and i used it myself already.
-
@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() }
wrote on 22 Aug 2018, 14:29 last edited by@raven-worx
I'm using ubuntu now -
Hi,
It's QSerialPortInfo.
-
wrote on 22 Aug 2018, 20:43 last edited by
-
And what is the error ?
-
@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 BusThe code above i've posted definitively works with a USB Barcode scanner and i used it myself already.
@raven-worx said in [PLEASE HELP] how to make a barcode receiver?:
thats not true. Of course QtSerialPort works with USB.
USB = Universal Serial BusWhat? QtSerialPort works only with serial ports. It has nothing common with USB... Please don't confuse peoples. ;)
-
i dosn't do any thing it always execute "else"
QSerialPort::SerialPortError(DeviceNotFoundError)@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 BusEven 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.
-
wrote on 23 Aug 2018, 03:46 last edited by
@JKSH i didn't worked
i tried form com 1 to com 18
non of them worked -
@JKSH i didn't worked
i tried form com 1 to com 18
non of them worked@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 workedWhat 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.
-
wrote on 23 Aug 2018, 04:46 last edited by
same error
i tried from ttyS0 to ttyS5 didn't work -
same error
i tried from ttyS0 to ttyS5 didn't work@davidlabib said in [PLEASE HELP] how to make a barcode receiver?:
same error
i tried from ttyS0 to ttyS5 didn't workYou 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 -
@davidlabib said in [PLEASE HELP] how to make a barcode receiver?:
same error
i tried from ttyS0 to ttyS5 didn't workYou 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#availablePortswrote on 23 Aug 2018, 05:51 last edited by 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
35/57