Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Any way to use HTML as an interface to a C/C++ program?

I'm developing a product that is interfaced over USB. I want to write a control app for it, but I cannot program a GUI for poo, so I came up with the idea of using a web page (local to the app's install directory) as the interface to the program.

So, the line of communication would be: User --> HTML page (not hosted - it's local) --> C++ program --> USB port

I'd like to do it this way because it's portable, at least UI wise, and I can write HTML fluently.

My question is this: would it be possible to use an HTML page to talk to the USB port through a C++ program?

If not, I'll learn GTK - it's portable enough.

PS. Would this be possible with PHP, or (eugh) Java?

EDIT: Just realised PHP is a server-side language - it wouldn't work in my situation because the page needs to be run as a program (I.E., just use the web browser and HTML as the GUI, with the actual processing done using C/C++)

like image 607
Bojangles Avatar asked Oct 03 '10 13:10

Bojangles


People also ask

Can we connect HTML with C?

You can include or embed C code in an HTML document, but it will not do anything; it will taken just as text data. There is no support in browsers for using C as client-side scripting language. Theoretically, you could write an interpreter for C (or a subset of C) in JavaScript.

Can you integrate C++ and HTML?

Actually, there are various ways to combine C++ and HTML. It just depends on what you want to do. Both IIS and Apache allow the use of Common Gateway Applications to execute on the server. Your C++ would then receive the requests through its input handle and would send the response through their output handle.

Can we use HTML CSS with C++?

Using CSS style sheets, UI designers and developers have the power to easily brand and style their applications. Views Style Sheets, available as part of the Visualization C++ software, follow the HTML Cascading Style Sheets (CSS) standard.


1 Answers

You can actually create web applications in C++ using a toolkit called Wt (similar API to Qt). There is a standalone browser as well as a module for Apache. This way you can use C++ as your programming language the same way you would C# with ASP.NET, and thus you can also use your existing C++ code. It's not really elegant though.

I'd actually recommend you learn Qt and write the whole application on top of it. It's incredibly portable and has an extensive API for just about everything - it's an application framework; GTK+ does just the UI, and in C, although the GTKmm wrapper for C++ is nice. Check it out at http://qt.nokia.com - it's available under the GNU LGPL.

like image 174
CMircea Avatar answered Sep 22 '22 18:09

CMircea