How to obtain a serial number of scanner with TWAIN? - c#

I would like to obtain the serial number of a scanner in C# using twain_32.dll.
I've found out it has to be done with dscap method with the icap_serialnumber capability.
Can anyone give me an example how to do this?

You have confirmed that your scanner driver supports this capability? I find it in the TWAIN spec as CAP_SERIALNUMBER (0x1024). And it is optional - you cannot assume that a scanner supports it.
If you get TWRC_FAILURE when you try to GET that capability, check the condition code. Your library or component should provide a way to get the condition code after the GET. A value of TWCC_CAPUNSUPPORTED would mean that the scanner driver does not support that capability. Other condition codes are described in the TWAIN specification, although sometimes a little imagination is needed to guess what the driver is trying to say...
The TWAIN Working Group forum is maybe a little better place for this kind of question.

Related

Extract gps data storage

I am using dotSpatial labrary in c#, I only can read realtime data.
but my problem is this.. how could I extract gps data storaged in my usb-gps device (it is passive gps)?
device information
brand : landairsea
Model: Gps Tracking Key
webPage: http://www.landairsea.com/gps-tracker/gps-tracking-key
From looking at their user guide:
http://www.landairsea.com/downloads/past-track-10.pdf
You could use the past-track software to save the stored data as .las format.
I believe that DotSpatial has a LIDAR plug-in that can read .las files:
Dotspatial.Plugins.LiDAR
If you are asking how to write a C# replacement for the Past-Track program that connects directly to the USB however, I don't know exactly.
DotSpatial has a positioning library that is DotSpatial.Positioning that was originally ported from http://geoframework.codeplex.com/. It is possible that this utility will have the capability to connect to your device, but I think it would probably only support a limited subset of GPS devices, and I never used it myself at all.
Hopefully that information is a little helpful though and will point you in the right direction.
Edit:
I have downloaded the Past-Track 10 software that is designed to retrieve data from the unit. This in turn installed Antaris4 and u-blox5 USB drivers. I think this is half of what you will need to write a C# app that can talk to your GPS and do things in code. You can find the drivers on the web. I think I found it here:
http://www.driverguide.com/driver/detail.php?driverid=1869444
But make sure you find a version of the driver that matches your PC configuration (32/64 and correct operating system). Incidentally, that will probably mean you will need to make x86 and x64 builds for your C# app.
The next step is to find some documentation for it and then attempt to use the drivers from C#. So far I haven't found a good document showing how to work with the drivers, but I'm sure it exits. I will update with a link when I find it.

.NET BarCode Reader in WPF

I am trying to see whether its possible to read the barcode in WPF Applications without using any 3rd party tools. We built an application using WPF and they are not willing to buy any third party devices to read the barcode. Is there any other way to read the barcode data in WPF Applications using .NET APIS?
Note: I seen examples in .NET, but most of them using Barcode reader tool. I have seen examples in Android ZXing library does that with out any tools like barcode reader or scanner.
Any ideas or thoughts is greatly appreciated.
Thanks,
Ramesh
In order to shorten the discussion in comments and possibly help other people with similar problem, I will summarize it here.
It is not clear to me whether the real question you wanted to ask is "does .NET provide barcode reader class". If so, the answer is no.
Now, since WPF application is just a normal .NET application, for sure it is possible to implement barcode reading without 3rd party libraries. All the algorithms are public, there is plenty of open source implementation which can serve as reference, and .NET provides all you need to talk to the peripherals, acquire the image and analyze it. You "just" need to code it.
E.g. there is a C# port of ZXing, so you can take a look (though it looks like automatic translation from Java, so I wouldn't expect much idiomatic C# in there).
You also mention that your customers "are not willing to buy any third party devices". I am not sure if 'devices' was meant to read 'libraries'. If so, there are open source libraries which they (or you) don't have to pay, and commercial components usually provide royalty free licenses (e.g. the first one that google showed), which means that only you have to pay the development license, but your customer doesn't even know about it.

Reading numbers from hand scanner or bar code reader in C#

Can any body who did some work on related thing tell me how can I achieve this?
What I want to achieve is to read number (printing on my boxes) from scanner and put that number in database. The numbers can be product IDs. What I need to know
From where to start
What is type of hand scanner can i choose for this
can i read these numbers by c# too adn what classes supports this?
any tutorial available?
As extensively explained here: https://stackoverflow.com/questions/613881/how-to-read-a-value-from-a-barcode-reader a barcode reader/scanner (either parallel, serial or USB connected) is normally seen as a keyboard from the computer, this happens at the device driver level, you have nothing to do about that in your C# code.
In fact you should also support manual entry of the code ( alpha-numeric ), like the cashier does in the supermarket when you took an item with unreadable (by the scanner) barcode.
in your C# application have a textbox where the user can type the code using the keyboard and when focus is on that textbox and the user scans a code with the reader you won't notice any difference between the input coming from the normal keyboard or the reader... no differences except that in some cases the barcode reader will also include a CR ( ENTER ) at the end of the code and you can use that to initiate your next action, like database operation etc.
I think you can actually configure if you want the CR to be sent to you after each read or not, somewhere in the driver settings of the device, it might depend on the specific device.
What i know is most of new scanners comes with a library or SDK in different programming languages so before you buy ask about one with support library, and if it doesn't come with one i think you can use the SerialPort component in windows forms.
This example might help you Using Barcode Reader In C Sharp

Testing WIA without having a scanner/camera device

I wrote a simple scanning code using WIA. I don't have a scanner device so I can't test it. Can I simulate a WIA device to testing it ?
This does definitely what you want: https://github.com/twain/wia-on-twain
I simulates a scanner and publishes a TWAIN and a WIA interface. Also the scanning of a graphical page is simulated, so you can try out different resolutions and colour schemes.
Not sure, but maybe http://scanworkssoftware.com/twainimporter.aspx will help you
or, Go to http://twain.org and under the "Fast Find" section click the last link titled "Sample Data Source & Application". This will install TWAIN 2.0 and a sample source named "TWAIN2 FreeImage Software Scanner" which has some basic scanning features. It does not have a driver interface but will let you preform scans and Get/Set some general properties.
With enough effort and the WIA SDK (and probably the Windows DDK as well) you probably can. But it will be a large amount of effort, especially compared to the price tag of a cheap scanner.
I'm assuming your time is worth something. If this is a hobby project, then compare the price of a cheap scanner to the time saved that can be spent working on the fun parts of the project. If this is a work project, then the time saved is more valuable to your customer than to you, but there should still be business case for buying hardware that will save more time than it cost.
I know this question is very old, but I'll post this as a reference.
Since Windows 10 Microsoft has made a GitHub repository with sample drivers, including the WIA ones:
https://github.com/Microsoft/Windows-driver-samples/tree/master/wia
I wasn't able to test them yet, but they should create a test device.
Well, try if this virtual webcam supports the WIA interface: http://www.soundmorning.com/
If so, you are all set and ready to go.
You can also search for "Fake webcam", there are many versions.
One thing to be concerned about is that all WIA drivers are not created equally. We recently had trouble using some Brother WIA drivers that were supposedly certified. The driver would not allow access to the feeder tray. We ended up having to write TWAIN integration also.
(1)
http://graphics.kodak.com/docimaging/US/en/Support_Center/Document_Scanners/Desktop/i65_Scanner/Support/Drivers_And_Downloads/i55_and_i65_Scanner_Driver/index.htm
InstallSoftware__v1.7.exe
(2)
http://sourceforge.net/projects/twain-samples/files/TWAIN%202%20Sample%20Application/
WIAonTWAIN_SDK.msi
(3)
For testing only you can also use the free demo version of the commercial file import TWAIN driver XPCTWAIN.
Product info: http://www.jse.de/products.html#xpctwain
Demo download: http://www.jse.de/download/setup_xd.exe
setup_xd.exe
Sounds like an occasion where writing the virtual device that is WIA compat might be the thing that needs to be given back to the community.

How to write files on smart cards in C#

I'd like to write to file in a processor smart card that accepts APDU commands.
Do you know any examples in C# or smartcard sdk?
Has anyone used http://code.google.com/p/pcsc-sharp/?
First, you need to create a managed wrapper for WinScard dll. WinScard is Microsoft's implementation of PC/SC. You will need this dll to send and receive APDUs from the card.
Next, you need to know what is the OS of the smart card you are going to use. You must have the API documentation of the smart card. This will help you construct the correct APDUs for writing a file. In the smart card world, there is no single, generic way to create a file. It all depends on the card's OS.
Subsembly is what we use. We don't do much with it, but it should get you started.
http://www.smartcard-api.com/
Here is an article in CodeProject call "A Smart Card Framework" that can help you.
pcsc-sharp mentioned at your link above is not really actively maintained. However, I have had great success with Daniel Müller's library with the same name (pcsc-sharp)
The docs here are quite good, and the library itself has worked for me very well on both 32bit and 64bit windows and linux.
I have developed my Managed Wrappers of Winscard in C# for sending APDUs and receiving Response from processor based smart cards.
If you don't have the API for the card's OS but you know that it follows ISO 7816 then you can use that standard to construct the APDU.
Let me know if u require more help on the topic. I have been working 4 years now on Smart Cards.

Categories