How can i access and control hardware in Qt - c++

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.

Related

Develope an application for windows and Mac OS

I need to develop an application that can be run on both Windows and Mac OS X, is a application "monitor" that needs to display data in real time, connection over ethernet. I'm interested in the performance and graphics. I know very well the c++. can you help me in choosing a development tool?thank you
JUCE is not just about for Music industry. Its for all. I have used it in Music softwares, Image processing and only GUI applications too.
Its a well built library which supports all platform.
you need not to create different project files for the application. JUCE creates it for you.
And its pure C++.
I would say your two choices are Juce or Qt. Juce is geared toward audio and graphics, letting you get your hands on creating fast and powerful DSP algorithms. Although Juce's largest following is with developers making music software, it's fully capable of making general purpose applications with the same ease as Qt. Qt does have advantages resulting from it's greater adoption; you will find plenty of tutorials, books and courses on Qt but hardly much on Juce at the moment.
Hopefully that will change soon as Juce was bought out by ROLI and will likely have more resources soon.

What is Linux’s native GUI API?

Both Windows (Win32 API) and OS X (Cocoa) have their own APIs to handle windows, events and other OS stuff. I have never really got a clear answer as to what Linux’s equivalent is?
I have heard some people say GTK+, but GTK+ being cross platform. How can it be native?
In Linux the graphical user interface is not a part of the operating system. The graphical user interface found on most Linux desktops is provided by software called the X Window System, which defines a device independent way of dealing with screens, keyboards and pointer devices.
X Window defines a network protocol for communication, and any program that knows how to "speak" this protocol can use it. There is a C library called Xlib that makes it easier to use this protocol, so Xlib is kind of the native GUI API. Xlib is not the only way to access an X Window server; there is also XCB.
Toolkit libraries such as GTK+ (used by GNOME) and Qt (used by KDE), built on top of Xlib, are used because they are easier to program with. For example they give you a consistent look and feel across applications, make it easier to use drag-and-drop, provide components standard to a modern desktop environment, and so on.
How X draws on the screen internally depends on the implementation. X.org has a device independent part and a device dependent part. The former manages screen resources such as windows, while the latter communicates with the graphics card driver, usually a kernel module. The communication may happen over direct memory access or through system calls to the kernel. The driver translates the commands into a form that the hardware on the card understands.
As of 2013, a new window system called Wayland is starting to become usable, and many distributions have said they will at some point migrate to it, though there is still no clear schedule. This system is based on OpenGL/ES API, which means that in the future OpenGL will be the "native GUI API" in Linux. Work is being done to port GTK+ and QT to Wayland, so that current popular applications and desktop systems would need minimal changes. The applications that cannot be ported will be supported through an X11 server, much like OS X supports X11 apps through Xquartz. The GTK+ port is expected to be finished within a year, while Qt 5 already has complete Wayland support.
To further complicate matters, Ubuntu has announced they are developing a new system called Mir because of problems they perceive with Wayland. This window system is also based on the OpenGL/ES API.
Linux is a kernel, not a full operating system. There are different windowing systems and gui's that run on top of Linux to provide windowing. Typically X11 is the windowing system used by Linux distros.
Wayland is also worth mentioning as it is mostly referred as a "future X11 killer".
Also note that Android and some other mobile operating systems don't include X11 although they have a Linux kernel, so in that sense X11 is not native to all Linux systems.
Being cross-platform has nothing to do with being native. Cocoa has also been ported to other platforms via GNUStep but it is still native to OS X / macOS.
Strictly speaking, the API of Linux consists of its system calls. These are all of the kernel functions that can be called by a user-mode (non-kernel) program. This is a very low-level interface that allows programs to do things like open and read files. See http://en.wikipedia.org/wiki/System_call for a general introduction.
A real Linux system will also have an entire "stack" of other software running on it, in order to provide a graphical user interface and other features. Each element of this stack will offer its own API.
To aid in what has already been mentioned there is a very good overview of the Linux graphics stack at this blog: http://blog.mecheye.net/2012/06/the-linux-graphics-stack/
This explains X11/Wayland etc and how it all fits together. In addition to what has already been mentioned I think it's worth adding a bit about the following API's you can use for graphics in Linux:
Mesa - "Mesa is many things, but one of the major things it provides that it is most famous for is its OpenGL implementation. It is an open-source implementation of the OpenGL API."
Cairo - "cairo is a drawing library used either by applications like Firefox directly, or through libraries like GTK+, to draw vector shapes."
DRM (Direct Rendering Manager) - I understand this the least but its basically the kernel drivers that let you write graphics directly to framebuffer without going through X
I suppose the question is more like "What is linux's native GUI API".
In most cases X (aka X11) will be used for that: http://en.wikipedia.org/wiki/X_Window_System.
You can find the API documentation here
XWindows is probably the closest to what could be called 'native' :)
The linux kernel graphical operations are in /include/linux/fb.h as struct fb_ops. Eventually this is what add-ons like X11, Wayland, or DRM appear to reference. As these operations are only for video cards, not vector or raster hardcopy or tty oriented terminal devices, their usefulness as a GUI is limited; it's just not entirely true you need those add-ons to get graphical output if you don't mind using some assembler to bypass syscall as necessary.
Wayland
As you might hear, wayland is the featured choice of many distros these days, because of its protocol is simpler than the X.
Toolkits of wayland
Toolkits or gui libraries that wayland suggests are:
QT 5
GTK+
LSD
Clutter
EFL
The closest thing to Win32 in linux would be the libc, as you mention not only the UI but events and "other os stuff"
GUI is a high level abstraction of capability, so almost everything from XOrg server to OpenGL is ported cross-platform, including for Windows platform. But if by GUI API you mean *nix graphics API then you might be wandering around "Direct Rendering Infrastructure".

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.

C++ UI framework from scratch?

I want to create a C++ UI framework (something like QT or like ubuntu unity Desktop)
How is programmed , is it using OpenGL or lets take plasma ui of QT (how is this programmed )?
Direct answers , reference links anything will be helpful.
Some interesting opengl based UI I founf on the web
LiquidEngine
http://www.youtube.com/watch?v=k0saaAIjIEY
Libnui
en.wikipedia.org/wiki/Libnui
Some UI frameworks render everything themselves, and work based on some kind of clipping-window-within-the-host-systems-screen. Non-display aspects (such as input event handling) have to be translated to/from the host systems underlying APIs.
Some UI frameworks translate as much as possible to some underlying framework.
wxWidgets can do both. You can choose a native version (e.g. wxMSW if you're on Windows) and most wxWidgets controls will be implemented using native Windows controls. Equally, you can choose the wxUniversal version, where all controls are implemented by the wxWidgets library itself.
The trouble is that typical GUI frameworks are huge. If you want a more manageable example to imitate, you might look at FLTK. I haven't got around to studying it myself, but it has a reputation for being consise.
There are also some GUI toolkits that are specifically aimed at games programming, such as Crazy Eddies GUI. My guess - these are probably as idependent of the underlying API as possible, so that particular applications can implement the mapping to whichever underlying API they happen to target (OpenGL, DirectX, SDL, whatever) and can be the boss of the GUI rather than visa versa.
http://www.wxwidgets.org/
http://www.fltk.org/
http://www.cegui.org.uk/wiki/index.php/Main_Page
"no really, don't write your own wm or toolkit"
The #Xorg-devel guys on irc.freenode.org
doing one anyway means that you have to test against a wide range of more or less buggy WMs and X implementations, and that you have to frequently update to be compatible with the latest Xorg server and X protocol features (like Xinput 2.1)
understandably, the Xorg people are tired to support old, unmaintained toolkits and applications. They already have enough bugs.
The GUI frameworks are very dependant on a windows system, which dictates what is allowed and how windows are created and rendered. For example, pass a specific option to create a borderless or full-screen window.
Since you mentioned opengl and ubuntu, I guess you want to start on a linux platform. You should study xlib, for which you can find reference here.
Since the qt library is open source, you can download it and peek into it's sources.
A UI library isn't developed from scratch. It relies on the OS' windowing system, which relies on the driver from your graphics adapter, which relies on the OS kernel, which relies on... and so on.
To develop any software "from scratch", you can start by writing your own BIOS. Once you're done with that, move on to writing an OS, and then you should be just about ready to write the software you wanted. Good luck.
And this is assuming you're willing to cheat, of course, and use a compiler you didn't write from scratch.
Before you do that, it's worth that you spend one week on thinking:
1, Do you really know how to do it? I doubt that.
2, Do you really need to do it? I doubt that too.

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).