Solved

Working with COM Ports

Posted on 2009-07-09
8
928 Views
Last Modified: 2012-05-07
PLEASE READ THE UPDATES PLEASE READ THE UPDATES
PLEASE READ THE UPDATES PLEASE READ THE UPDATES

Hi Experts. Are you ready for your stupid question of the week?

I've never worked with COM Ports before.
I have a barcode scanner that is actually USB, and after installing a driver and following some instructions I have enabled a 'Virtual COM Port'. It shows up under Device Manager as 'Symbol USB COM Port Emulation' under 'Human Interface Devices'.

Anybody have a clue as to how to talk to this COM Port? I want to receive any barcode data it is receiving.

======================
UPDATE: This blurb from the Readme might help:
Custom serial communication applications can be developed to work over the
virtual COM port, like the normal PC serial port. Driver supports Win32 serial
communication APIs and applications that use these APIs will work over the
virtual port subject to the limitations listed in Section 9.

======================
UPDATE:
I downloaded the ComPort library from SourceForge:
http://sourceforge.net/projects/comport/
And got it to connect on COM1.
My problem now is, when I deploy my application, will it always be COM1? What if the user has put another serial device which is using COM1 (Please keep in mind that COM1 is being virtualised by some software)?
0
Comment
Question by:rfwoolf
  • 4
  • 4
8 Comments
 
LVL 18

Expert Comment

by:Johnjces
Comment Utility
Just out of curiosity, what make/model of scanner are you using?

We use bar code scanners all the time where I work. All of the USB scanners we have are HID type devices that emulate an added keyboard.  So when you scan a bar code, it is just like typing it into a keyboard. No fuss, no muss, no hassles. No com port programming etc.

If you can, I would look at a different make/model of scanner that works as above.

Look at http://www.posguys.com/barcode-scanner_3/

Lastly, USB to serial devices usually add a virtual type com port above the standard com1 and com2 found on PCs. It is unusual that it is set as COM1. But on another user's PC the USB com port could be be anything especially if they have a modem or serial ports on their PC which are already set as COM1 and/or COM2.

You would need a setup in your application that the user would set the com port setting that was assigned to the scanner after it was installed.

John
0
 
LVL 13

Author Comment

by:rfwoolf
Comment Utility
Thanks John. This is the Symbol (now Motorola) DS6707. It is the USB version which works exactly like Keyboard input. But this is a problem in my application because how do I detect Keyboard Input separate from Barcode Scanner input? This is important for me. I opened a question about how to create a keyboard listener which would detect a PREFIX and SUFFIX string of 'START' and 'END' respectively and ThievingSix helped me write one but it came out with some problems, so I decided the best bet was to use a COM port instead.
Based on your experience developing applications for barcode scanners, do you have any advice for me? I will gladly open a new question if you ask me to.
0
 
LVL 13

Author Comment

by:rfwoolf
Comment Utility
COM Port question
(Assuming I stick with COM Port and JohnJces doesn't have a brilliant idea on how to detect keyboard and scanner input separately):
===
The COMPort component comes with a nice Comport Terminal which works perfectly: I scan a barcode and it appears in the terminal.
Any idea on how to call an event once it has scanned something?
0
 
LVL 18

Accepted Solution

by:
Johnjces earned 500 total points
Comment Utility
The only advice I can give is from the my experience in writting a couple apps that use keyboard type BC scanners. In those apps there would be specific fields that the user would jump to or enter into for bar code input. For multiple scans, like inventory, I did a start button and set the scanner to send a carriage return and line feed at the end of each scan that would in essence be like hitting the enter key. This would loop until the user clicked finished. Single entries would have to be when in a specific field. If they were on a name field and scanned a label, we would have bad data and I checked for numeric or numeric AND alpha data in such fields and would reject such... clear the bad text and set focus again on that edit.

It is tough and IMHO pretty impossible to distinguish real keyboard input from BC scanner input so I do understand the use of the COM port devices. But other users may need to have it set to any com port from 1 - XXX, so you would just need to add a com port setting in your app.

John

0
6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

 
LVL 18

Expert Comment

by:Johnjces
Comment Utility
Sorry..no brilliant ideas!

One question... can you design the labels being read? Or are they like UPC codes that are fixed.

John
0
 
LVL 13

Author Comment

by:rfwoolf
Comment Utility
Yes we are designing the labels being read. They are 2D barcodes using the PDF417 symbology.
0
 
LVL 13

Author Comment

by:rfwoolf
Comment Utility
Thanks for the advice John, I'm still saving up to come visit your Casino ;)
Here's some boring (probably) and irrelevant news about my local casinos:
-One of my local casinos sends me about 4 SMSs a week about their "equal chance" draws that they hold regularly and other similar promotions. Trouble is, word gets around and everyone is getting these SMSs.
-I spoke for about an hour to a croupier at a Casino and they say they get paid about the same as a "banker" but with a lot more perks. By "banker" I assume they mean bank teller or bank salesperson, as opposed to the multi-millionaire investment banker stereotype.
0
 
LVL 18

Expert Comment

by:Johnjces
Comment Utility
Most all of the 'floor' positions are minimum wage or even less due to tips. Tips or tokes is what a lot of their income is based upon. Not sure what tellers make... depending upon the season here they can do pretty good. But it is not consistent.

Back to labels... we use a prefix on ours but I guess that was sort of like the start and stop you tried earlier. Maybe just do a Start, like with the characters BC or BC9 then a carriage return line feed after the BC read might do you.

Anyway... again, no brilliant ideas!

John
0

Featured Post

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

8 Experts available now in Live!

Get 1:1 Help Now