How to get started with Drivers Programming under windows - c++

I want to start learning drivers programming under windows .
I never programed drivers , and i am looking for information how to get started .
Any tutorials ,links ,book recommendations , and what development tool kit i should start with ? (WDF will be good one ?)
I really want to program following clock link text
Thanks for your help .

I would start by downloading the windows driver kit (WDK).
Afterwards, you decide which kind of driver you want. FileSystem driver? (probably not), RS-232 driver? usb driver? They all follow different rules and quirks.
The WDK comes with examples drivers for most kinds of drivers and should get you on track fast.

To interact with USB hardware you would be best served by looking at WinUSB or the Usermode Driver Framework. Usermode drivers are orders of magnitude easier, being able to use a C++/COM(kind of) framework and a normal debugging environment.
Writing kernelmode drivers should be reserved for stuff like video card, disk, and other latency/throughput sensitive drivers.
An even easier method would be to use libusb-win32 which is a C library that makes talking to a USB endpoint almost as easy as writing data to a file.

Must see resource for windows driver development, of course as addition to the WDK mentioned by Eric.

Related

How can i access and control hardware in Qt

I try to developing simple scada system with C++ in Qt. I want to control hardware or get status(or something) of hardware and send to server or router.(actually my application control softwares too)
And in finish: Qt have a good tools for scada systems?
As of QT 5.7 there is a new Serial Bus library for use with protocols such as CAN BUS and MODBUS, you can read more about it here:
http://doc.qt.io/qt-5/qtserialbus-index.html
For your scenario, QT has plenty of Network support that you could use for your interface, depending on what your hardware specification is. QT does not compare to 'out of the box' SCADA solutions such as a Siemens SCADA system, however developing one based on QT could give you much more flexibility. Depending on what you are trying to achieve, this becomes a trade-off between productivity/time to market and flexibility/value add.
Also there is an opensource qt scada toolkit https://github.com/IndeemaSoftware/QSimpleScada, for visualization.

Resources for Programming the Linux X-Server

Are there any out there that are easy to get ahold of? Preferably free, as I don't have any money to spend right now.
What I'm trying to Accomplish
Basically, I'm writing a multi-platform application in native C/C++, and now that I have Linux installed, I feel as though I'm truly ready to make the "multi-platform" development go. Before anyone says "use SDL" or "Qt", note that I'm doing this for an application which I plan to go commercial with (Qt costs money for commercial applications). While SDL is good, I'm also looking to learn about window managers in general. I feel as though the best way to learn how to communicate directly with the operating system is to write the application yourself.
So, are there any resources out there?
First of all X-Windows has nothing to do with Linux.
X-Windows is both a graphical protocol and a GUI system built up around it. X runs on most OSes including Windows and Mac. The most typical scenario is for an X application to run on a multiuser computer running a UNIX-like OS (for instance Linux) and for the users to interact with it using an X-server which runs on either an X-terminal or a desktop OS. The X-Server is a standard piece of the X-System. If you install an X-Server on Windows then you will be able to interact with graphical applications running on one or more other computers.
It sounds like you want to focus on building the X applications, not the device drivers or the server or any other part of the X-system. Linux is as good a choice as any, but the books and documents that you need were likely written using Solaris or BSD UNIX. But it's the same API.
Since X has been widespread since at least the early 90's, look for books in secondhand shops and university jumble sales. Advertise on Craigslist for X related books.
The lowest level API for X is called Xlib. Toolkits like GTK and QT are layered on top of this so studying their code is a good way to learn how to do things. But there is also something called the X-Toolkit that runs over Xlib and used to be the foundation layer for GUI toolkits like Motif and others. If I were you I would start with X-Toolkit, to get familiar with all the component parts of X and how they interact. For instance, it will take you a while to get used to the fact that a window manager which manages the windows on an X-Server display, doesn't run on the X-server but runs on a remote system. Or that you can have apps running on Linux and OS/X and Solaris all displaying their windows on the X-server on a single Windows box.
Google X Toolkit intrinsics to get all kinds of info including free reference manuals.
As you read more about it you will come across a lot of other unique terms that you can google to get additional info and a broader perspective. Don't spend too much time with old toolkits like Athena Widgets or Motif.
Since there were more people programming X in the early days of the Internet than today, the USENET FAQs are still a good source of introductory tips, e.g. http://www.faqs.org/faqs/Xt-FAQ/
You can write your app as a server in C. Call it Engine. No need to think about the User Interface. After that you can create interface in Qt. The communication protocol will be public (or private) and your Qt application will be open-source. Later if you like you can create many more interface to your application. Such as web interface, Gnome interface, C#.NET interface etc.

Access USB hardware (pressure sensor matrix with native C++ API) using Python

I am working with a pressure-sensing mattress having a USB interface. The maker provides USB device drivers for Windows, and an API written in C++ which has functions to request data and set some parameters.
Currently, I cannot use this sensor for testing some Python data-visualization scripts directly, having had to ask my coworkers to write a text-logger for me, and then I read this information offline with Python.
Also, I cannot use Linux at all with the sensor, because there are not drivers for Linux, and I do not know where to start to "hack" the sensor, and that is why I am asking:
"If I were to try to read data from this sensor directly with Python and perhaps in Linux, what should I do first, or read first?"
EDIT: the device has an FTDI driver (FTD2XX.dll) if it helps.
Any help would be very welcome
Odds are fairly good it's a HID device, in which case you can probably start to write a userspace linux driver for it using libhid. First place to start with that would be enumerating the tree that gives you information about its capabilities. (lsusb -vvv or Example)
Failing that you can use libusb on linux (and other platforms too these days) to write a userspace driver still. You'll want to use something like usbsnoop or a real hardware equivalent to see what the official driver does when it's talking to the device and mimic it from there.
From the python side you can probably generate a decent wrapper to the existing C++ API using SWIG for relatively little effort, especially compared to developing an entirely custom driver.
Update:
If it's an FTDI device then it's might be a lot simpler to work with. Depending on what the vendor and product ID are showing it might automatically work with the FTDI driver in Linux, giving you as USB serial port. Failing that there are parameters to the module - vendor and product that I believe you can use to make it claim other devices besides the pid/vid combinations it knows about already. From there you can try opening the serial port device with different settings. With luck it might be sending state info regularly already.
If it's not you want to try and discover what the official software sends to make it start playing. You're back into the realm of sniffing again, but I think there might well be things that do it at the serial layer instead of the USB layer for windows (although I can't name any). You might also learn something by trying to make their library use a software emulated serial port instead of the FTDI device and seeing what it writes.
The FTDI chips have a linux driver. Just go to the FTDI website and download it. The driver creates a virtual serial port. You can use PySerial to interface with it.
Too bad I didn't see the post sooner!

OpenCV on Embedded Platform

Can some suggest a test/development embedded platform to use with OpenCV.
I would like to develop an embedded video analytics solution, but I don't know where to start.
Some suggestion/ideas/hw starter kits?
Maybe some Pc-104 solutions with Intel Atom? Has someone made some test about performances on this platform or any other embedded platform?
Thanks
A Pentium/PC built OpenCV application will run on any Atom platform with the same OS unmodified. This is because Atoms natively run Pentium executables.
If you are looking for a more embedded solution, there are OpenCV ports for the BeagleBoard. SInce OpenCV is portable code, it can be compiled to most systems that provide a C/C++ compiler. I have successfully used OpenCV on ARM, MIPS and XScale processors.
As for mobile platforms, there are ports to the iPhone, Android and various Windows CE/Mobile/Embdeed versions.
If you're looking for a very small option, I strongly recommend the Gumstix Overo series. I use them for my Computer Vision research, and they work really well. There are a couple of options for processors, I'd recommend the Overo Tide module, which has 512 MB of RAM, and an onboard DSP for offloading some CV operations. Combine this with a Tobi expansion board and a few cables, and you've got a full embedded computer vision research platform for ~$350. They also sell a small camera, which I'm still getting around to trying out. What's nice about the Gumstix is you can just build OpenCV onboard, which saves you some of the headaches with BitBake type solutions.
I'd personally recommend TI OMAP platforms - Beagleboard xM and PandaBoard.
Those boards have embedded video input, run Linux, and have more than enough performance to run OpenCV. They are also extremely portable and have good community support.
Do you mean OpenCV the computer vision library originally developed by Intel? I would be inclined to start with Moblin, Intel's embedded Linux, at moblin.org and for hw use a netbook or any PC that Moblin supports. Hook up a supported webcam from the list at www.qbik.ch/usb/devices/search_res.php?pattern=webcam .
There is a Wikipedia entry that might help. Your project sounds like fun!
cheers -- Rick
You can use the Blackfin kit from Analog Devices. Analog Devices have created a library similar to opencv for the blackfin DSP processor.
you can use Symbian Simulator for this they Nokia have there Open CV for Symbian for hardware testing you have to drop the mail to them they will provide u the hardware through the telnet for given time of time
OpenCV does not need any "special" hardware to function. You can use it fully using images from normal files (e.g. JPG)
Have you looked at some of the tutorials/code? Do they require something specific that you do not have?
Vision Components seem to support the OpenCV in their Smart Cameras (see this article).
I guess I am late to answer.
I have recently used opencv3.4.6 with PC-104 boards (PCM3365) for an INDUSTRIAL Application.
Only thing to note is that when i start webcamera using cv::Videocapture, it takes a long time to open (around 30-40secs), otherwise everything is fine.
Good Luck

What is the best USB library to communicate with USB HID devices on Windows?

The library should;
Be easy to use and few lines of client code should accomplish much
Be as platform independent as possible. (In case of future ports to other platforms)
Have C++ bindings.
Be mature and stable
I would also like to be notified of most HID events through callbacks.
I have considered the following alternatives:
libhid - (Unfortunately?) this is GPL and cannot be used in my application.
WDK - Seems to be a bit low-level for my use. I don’t need that kind of control.
atusbhid - This has an appropriate level of abstraction, but it is firmly tied to the Windows messaging loop
Are there other alternatives to offer?
Take a look at hidapi: it is C, which answers the C++ bindings question (effectively :)), is cross platform and has a very permissive license.
It doesn't appear to have the callbacks, but...
If libhid works for you, then perhaps the thing to do would be to write an application (which you would GPL), which uses libhid to talk to devices, then provides whatever you need via a TCP connection. Your real application would connect via TCP to do what it needs. This would obviously be a massive performance hit.
This application would effectively be a 'shim' between libhid and your application. In this case, the shim would exist for legal, not technical, reasons.
I'm not saying it's a good idea, just that it's an idea.
Consider rolling your own. You'll have total control over the interface, the level of platform independence, and such. Even though a project is GPL, you can use it as a recipe for your own, and as a testbed to find issues with your own.
There are several USB HID host drivers for Windows. An easy-to-use dynamic-link library is from http://embedded24.net.
There are also several example applications included for Visual Studio 2010 (C++, C#, and Visual Basic).
HIDmaker software suite from Trace systems is an option.
Pros:
Easy to use (excellent for learning how to program for USB HID)
Generates working applications source code in a various project formats (Visual Studio and Borland)
Generates stable example code for both host and device (stable in my experience)
High performance (if HID can even be said to have high performance in the first place)
Cons:
Only works on Microsoft Windows
Uses its own USB library I think (ActiveX)
Look at this code:
Read and use FM radio (or any other USB HID device) from C#
It gives you some simple classes to talk to a HID device. It boils down to getting the alias for the device (something like \?\HID#Vid_nnnn&Pid_nnn#...) and use CreateFile to open it. You can get the device's alias under HKML\SYSTEM\CCS\Control\DeviceClasses\{4d1e55...}\.
The Vid and Pid are the vendor ID and product ID of the device (check Device Manager).