Barcode scanner

Post your Gambas programming questions here.
Post Reply
User avatar
gbWilly
Posts: 68
Joined: Friday 23rd September 2016 11:41am
Location: Netherlands
Contact:

Barcode scanner

Post by gbWilly »

Hi you all,

I'm currently trying to figure out how to make an application to scan barcodes.
I have a USB barcode scanner to scan the barcodes.

I have been searching this forum and other places (like wiki) to figure out how to get this done but nothing was really helpful.

I presume I need to use SerialPort to get this done but I get stuck at something simple as:
DIM BarCodeScanner AS NEW SerialPort

BarCodeScanner.PortName = ????
How do I know the portname, I have no idea.
It would also be nice to have some sample code that I can study to get a grasp on how this works.
It is probably something simple I am completely overlooking... :( :?
gbWilly
- Dutch translation for Gambas3
- Gambas wiki content contributer


... there is always a Catch if things go wrong!
User avatar
cogier
Site Admin
Posts: 1118
Joined: Wednesday 21st September 2016 2:22pm
Location: Guernsey, Channel Islands

Re: Barcode scanner

Post by cogier »

Hi gbWilly, long time no hear!

I have written barcode reading programs, but I have always used a USB reader, which is seen by the computer as a keyboard. Once the gun has read the code, it sends the text to the keyboard with a newline on the end.

Do you have no option but to use one with a serial port?
vuott
Posts: 262
Joined: Wednesday 5th April 2017 6:07pm
Location: European Union

Re: Barcode scanner

Post by vuott »

gbWilly wrote: Monday 31st January 2022 4:09pm
BarCodeScanner.PortName = ????
How do I know the portname, I have no idea.
...something similar to:
"/dev/ttyACM0"
or
"/dev/ttyUSB1"
Europaeus sum !

Amare memorentes atque deflentes ad mortem silenter labimur.
Diverod
Posts: 28
Joined: Friday 12th November 2021 1:31am
Location: North Central Florida

Re: Barcode scanner

Post by Diverod »

I used to just monitor a TextBox for keyboard entry, something like this:
Private Sub txbBarCodeInput_KeyPress() 

  If Chr(13) Then   ' This is the last non-text character from BCreader
    ' Put Code here
  EndIf
     
End Sub
This is just from memory but hopefully will give you an idea to work from. Make sure the TextBox has focus so it will receive keyboard input.
User avatar
gbWilly
Posts: 68
Joined: Friday 23rd September 2016 11:41am
Location: Netherlands
Contact:

Re: Barcode scanner

Post by gbWilly »

cogier wrote: Monday 31st January 2022 6:02pm Hi gbWilly, long time no hear!

I have written barcode reading programs, but I have always used a USB reader, which is seen by the computer as a keyboard. Once the gun has read the code, it sends the text to the keyboard with a newline on the end.
Hi Cogier,

I am using a USB reader and reading your and the other comments I understand that it is more simple than I could imagine.
The Universal Serial Bus made me think I needed SerialPort for some reason, that's where I went wrong. :?
Luckily, no need to use SerialPort. It is all so much simpler than I imagined.

If I get it right it's just getting the focus on a TextBox, scan with USB scanner and the barcode should be in the TextBox.

So I guess it's playtime ;)
Last edited by gbWilly on Tuesday 1st February 2022 2:09pm, edited 1 time in total.
gbWilly
- Dutch translation for Gambas3
- Gambas wiki content contributer


... there is always a Catch if things go wrong!
User avatar
gbWilly
Posts: 68
Joined: Friday 23rd September 2016 11:41am
Location: Netherlands
Contact:

Re: Barcode scanner

Post by gbWilly »

Diverod wrote: Monday 31st January 2022 8:45pm I used to just monitor a TextBox for keyboard entry, something like this:
Private Sub txbBarCodeInput_KeyPress() 

  If Chr(13) Then   ' This is the last non-text character from BCreader
    ' Put Code here
  EndIf
     
End Sub
This is just from memory but hopefully will give you an idea to work from. Make sure the TextBox has focus so it will receive keyboard input.
Thanks Diverod,

You remembered correctly, your code works as a charm.
It is so simple if you know where to look... :D

Thanks
gbWilly
- Dutch translation for Gambas3
- Gambas wiki content contributer


... there is always a Catch if things go wrong!
User avatar
Hasenkaber
Posts: 1
Joined: Tuesday 14th February 2023 10:04am

Re: Barcode scanner

Post by Hasenkaber »

Hey there. Refreshing this thread. I see you tried to figure out how to get your USB barcode scanner up and to run. I had a similar problem when I was starting out, but I figured it out eventually. Regarding the portname issue, you can try going to your device manager and looking for the scanner under the "Ports (COM & LPT)" section. The port name will be listed there. Also, I wanted to bring to your attention a cool tool that can help with barcode scanning and even OCR (Optical Character Recognition) - smartengines.com/. They've got some really impressive tech that could save you a lot of time and effort. Good luck, and keep us posted on your progress!
Post Reply