how can i access serial port data in c++ using wxwidgets - c++

i am electronics and communication engineering student. i am working on a project in which a microcontroller send data to serial port of computer (asynchronously).
i currently learning wxWidgets for my GUI work.
my question-
is it possible to do using wxWidgets to get data and display. is it very difficult to implement this.
i search for it but not get direct answer that how to implement this. so suggest me what i need to read for this. and what alternative available to do this. i use windows 7.
i also need to upload this data to web server (it is needed later)

wxWidgets, to the best of my knowledge, does not implement serial I/O facilities. There are other libraries available that provide this. One of the best choices is probably boost::asio (see http://www.boost.org/doc/libs/1_40_0/doc/html/boost_asio/overview/serial_ports.html)

wxWidgets is a cross-platform GUI framework.
Reading a serial port is nothing to do with the GUI, and not cross platform.
So wxWidgets has nothing to do with reading serial ports.
You can read/write from/to a serial port using the windows API.
CreateFile opens the port
ReadFile reads data from the port
Difficult? Kinda!

I've never used it myself but there is wxCTB.

Related

Wemos D1 Mini (ESP8266) control with USB

I have a Wemos D1 Mini (ESP8266), flashed with WLED and I want to create an application like .exe and have control on turning it on/off and choose colors. Does anyone have any idea how I can do without to connect on wifi and just do everything via USB?
To control the WLED firmware over USB, you would use the firmware's ability to be controlled over a serial connection. It looks like you would open the virtual serial port that appears when you plug in the device, at a speed of 115200, and then you take the same JSON that you would POST to /json/state for controlling it over WiFi, and instead send it over the serial connection, and get your responses back over the serial connection.
You could also implement the TPM2 protocol, or the Adalight protocol (which doesn't really seem to be documented except in code), as those are also supposed to be supported.
If you want to do all this in C++ on Windows, you might start by reading the (very old) Windows tutorials for Win32 API serial port programming. If you only want to target Win10 or newer, you could learn C++/WinRT and then use the new WinRT serial APIs. Or you could consult the answers to this question about serial programming on Windows.

C++ USB library

Is there a library/method for communicating with a microcontroller (Arduino)?
Basically, I need a method of receiving and sending data between the PC and the Arduino. I don't know what library to use, so I'm asking you. The data I'm going to send is little. Maybe 500 bytes back and forth. Everything is happening in Visual C++ 2010, in a console application.
libusb seems to be one of the best choices in your case. This is a lightweight, widely-used, open-source, cross-platform and well-documented C library.
termios also works fine. I've been using it to connect an Arduino to a Raspberry Pi (Linux) via serial link (USB). You could find some useful code snippets here.
Boost ASIO works well. Have a look at Stack Overflow question Reading messages from a serial port with Boost Asio. I recently had to write some code for communicating through the serial port, and I used an Arduino Uno to test it.
If you install the FTDI driver for your Arduino board, Windows will recognise it as a COM port, and you can communicate with it as if it is a normal serial port.
Yes, ArduSerail is a SUPER easy to use C++ library to interface with Arduinos on Windows platforms via USB.

C++ library for network communication between laptop/device without router

Background
For my project, I'm attempting to control an AUV using an Arduino mega with an ethernet shield that receives instruction from a laptop (running Windows). The server side (laptop) will be written in C++.
Since there'll only be a one to one network using TCP/IP, I am trying to avoid the use of routers in order to simplify the hardware. I found out that you could do a direct connection between two devices (with auto-MDIX).
Therefore...
I have briefly looked into Boost:asio but I think it's probably an overkill (because I won't need to consider multiple clients etc) crossover for what I'm trying to achieve here. Am I right?
Any advice would be appreciated! Thanks.
TL;DR:
Looking for a C++ networking library (that works on Windows) that allows a clean, simple code to do a one-to-one TCP/IP connection.
The simplest way is to set-up your arduino as a web server. See this example sektch for the details.
On your Windows box use a web client library.
This way you can test the arduino even without your client software using your browser.

Convert application under win16 with a driver to win32

In general, what needs to be done to convert a 16 bit Windows program to Win32? The application is used to be serial communication with a driver. I have known how to use the DLL file of the driver. Then what is the next step? I hope to hear some useful information, not copied from other website.
The code in question is C++
Thanks
If the app is using a driver to access a serial port, then drop the driver altogether. In Win32, you can use the standard Win32 API CreateFile(), ReadFile(), and WriteFile() functions to read/write data over a serial port, and various SetComm...() functions (SetCommState(), SetCommTimeouts(), SetCommMask(), etc) to configure the port settings. Refer to MSDN for more details:
Serial Communications

USB and a personal-created device interfacing in Windows using C/C++

I know how to interface using the parallel port and also have a little idea on serial port interfacing. But is there a way to interface using the USB port in Windows? Or any links that would give tutorials on how to do this?
Specifically, I wanted to know the programming side of it.
I don't know how to start. I have searched into google but I have not seen any code samples.
Thanks in advance and Happy New Year.
USB programming is considerably more complex than serial or parallel port programming. For writing USB drivers for Windows, you'll probably need the Windows WDK. However, for a device you build yourself you can start with implementing a serial port class driver in your device, so that it shows up as a new serial port in Windows. The HID is another potentially useful driver class, generally used for some kind of input device.
I would recommend a good book if you want to do USB programming, for example Jan Axelson's USB Complete. And a real hardware protocol analyser is indispensable.
Found an interesting blog post http://yeohhs.blogspot.com/2006/08/programming-usb-port.html
it mentions a library 'libusb' and a wrapper for the same. The library is a GNU project. The library and documentation of the same may prove useful. The API documentation of libusb is here: http://libusb.sourceforge.net/api-1.0/