Convert application under win16 with a driver to win32 - c++

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

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.

serial write to COM port using C/C++ from MATLAB reference code

I am using a simple matlab code to send serial data to a COM port device, however I am having issues and would like an equivalent C/C++ code to achieve the same result. Shown below is the MATLAB code.
s_port = serialport('COM1',9600);
configureTerminator(s_port,'CR');
write(s_port,char([50 01]),"char");
pause(1)
write(s_port,char([16 2 150]),"char")
write(s_port,char([55 18]),"char")
write(s_port,char(54),"char");
I attempted to use MATLAB coder, but I don't think there is a stock equivalent to matlab's serialwrite function.
Thanks
Because the port is named "COM1" and not "/dev/ttyS0" I assume you are running on Windows.
You can fopen("COM1:") and fwrite() to it, but that won't give you control over baud rate.
For control over serial port settings (baud rate, parity, stop bits, flow control), you need to use the Win32 API (CreateFile, build or modify a DCB structure, SetCommState, WriteFile). Official example
On other (POSIX-like) operating systems, you'd use open, build or modify a termios structure, tcsetattr, write. Examples of termios configuration here on Stack Overflow
There are also some wrapper libraries that abstract away the OS-specific parts, but I can't recommend any of them.

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.

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

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.

Stack independent c/c++ bluetooth api?

I wanted to know if there is any stack independent C/C++ bluetooth api for windows (XP, Vista, 7, x86 and x64).
My target is to create a connection and send/receive some time critical data over bluetooth.
My researches gave me the following options and there disadvantage for this task:
Windows Sockets for BluetoothOnly works with microsoft bluetooth stack
Using the COM port (CreateFile/ReadFile/...)Slower than the socket option and the user has to connect to the device first.
Use stack dependent APIThis would require to detect the used stack and create read/write functions for every stack. Very time consuming and I don't know if it is even possible to support all stacks
Writing a KMDF driverI thought about writing a function driver to talk directly with the bluetooth HCI driver which should be stack independent. This would be very time consuming because I would have to read the whole bluetooth spec, or is there an API for the HCI commands?
I know that there is also a commercial sdk from btframework.com which supports most (or all) bluetooth stacks, but I need a freeware option.
Please tell me if there are any other options for this task.
If there aren't any, could you tell me which options you would prefer and why?
Is it okay to use Windows Sockets and ignore the other bluetooth stacks?
Thanks for your help :)
I guess one option would be to use C++/CLI to interface with my managed Bluetooth library 32feet.NET which supports most of the stacks on Windows. http://32feet.codeplex.com/
I've been successfully using this library it is called WCL but it is not free. With this you can connect through SPP without requiring to create a virtual COM port.
While their documentation is not very good, they provide some good demo code that you may want to try.
It supports the Microsoft, Toshiba, Widcomm and Bluesoleil stacks and there is a native C++ implementation (as well as a .NET one).