How do I control the Com Port under Firemonkey? - firemonkey

I am developing in Firemonkey and need to access the com port (serial port) for an OSX application. There is a component by Winsoft, but this limits the user to standard baud rates. I need to set this to 48000 (not 4800). It was straightforward using WinAPI but I am not sure of the commands I can now use. Any advice, anyone?

Related

Define the COM port for other computers

I got a Silicon Labs CP2102 USB to UART Bridge and i need it to transfer data from my GUI to a Nucleos F446RE.
I want to know if there is a way to define the COM port for the Bridge for other computers as well since on my computer it is COM8 and for a diffrent computer it is COM7.
I know that i could change it manually but not anyone got admin rights and if there is any way to do it automatically it would be great.
If you can, avoid a USB-to-UART bridge for exactly the reason you describe: it basically prevents a good user experience.
It is possible to change the COM port number after installation, just not to preselect it. During installation of the virtual COM device, Windows automatically chooses a COM port number that is not already in use. The avoiding conflicts part is important, and reveals why it is impossible to have the hardware choose the number. (Thanks to Ben Voigt for this part.)
You have several options:
The Nucleo F446RE board has a UBS interface. So you can directly connect it to your PC without a USB-to-UART bridge. Of course, the firmware needs to implement a USB device, preferably with a custom protocol and with WinUSB descriptors. That way, no device driver installation is needed and your application can communicate with the board using the WinUSB APIs.
If this is not possible, another alternative is to select the COM port with matching attributes, in particular with the matching vendor and product ID (VID and PID) - see links below. That way, you can at least narrow it down to a device with a Silicon Labs CP2102, which will often be sufficient to uniquely identify the port.
Another option is to use a USB-to-UART bridge that allows to configure a string descriptor. That way, you can uniquely identify the COM port. For a true plug and play experience, you would need to select a bridge chip that either does not need driver installation as it implements the standardized USB CDC ACM protocol (e.g. PL2303GD) or can automatically install the drivers (such as the FTDI chips).
Links:
https://www.codeproject.com/Tips/349002/Select-a-USB-Serial-Device-via-its-VID-PID
https://aticleworld.com/get-com-port-of-usb-serial-device/

How do you programmatically configure the Serial FIFO Receive and Transmit Buffers in Windows?

From Device Manager in Windows it is possible to configure the Receive Buffer and Transmit FIFO Buffer sizes for a serial port from Advanced Settings for a COM port:
I would like to configure the values for the TX and RX FIFO buffers for COM ports programmatically. Ideally a method to do it in LabVIEW or even via .NET / command line as both are easy to interface with from LabVIEW.
Edit: Just to clarify this is in regards to the 16550 compatible UART FIFO buffers and not software buffers like the VISA I/O Buffer, etc.
A few options are available that are not as ideal for this case but useful to note:
The CodeProject post by Vladimir titled "Serial Ports. Enumeration and FIFO control" has an approach that uses the Microsoft Driver Development Kit (DDK) which is now the Windows Driver Kit (WDK) in Visual C++.
The forum "How to set Serial port Fifo buffers without reboot" describes that the values can be changed in the registry (manually or programmatically I suppose) and then the serial port interface restarted using the DEVCON command-line tool. I am not sure how reliable that approach and documentation is hard to find.

Windows COM port for IPC

Can the Windows COM port be used by two programs running on the same PC for inter process communication? Our ultimate goal is to write a program which communicates over COM port to control a hardware. Since the hardware is not available we want to emulate the hardware in a program which reads from a virtual COM port and responds.
A trivial emulator would be a program which waits for bytes to be read from the COM port and responds by writing on to the COM port. To start with the values of these messages can be hardcoded.
So what I do is I have two programs written in C/C++ using the ReadFile, WriteFile functions given by windows to read and write over the file. This approach will not work because of access conflict. Hence I was wondering if our approach for the emulator itself is wrong.
I am new to Windows based programming though I have programming experience in other areas. Any help would be greatly appreciated.
Update:
Solution:
Installed Virtual Serial Port Driver 7.1 by Eltima Software (trial version)
Added a pair of virtual ports (e.g. COM1 and COM2)
The controller program communicates through COM1
The emulator program communicates through COM2
Eltima software takes care of transferring the data between the two ports
You can open a file with sharing parameters that allow both of the processes to read/write to it. But that's not a good solution, because reading/writing serial port has a number of differences with reading and writing to a file.
Instead I recommend to get a virtual COM port driver (like com0com.sourceforge.net, or select another from here en.wikipedia.org/wiki/COM_port_redirector). Install it, create two COM ports and connect them virtually. That way you will be sure that your program will work on real COM port too.
If that solution is not acceptable look into using pipes rather than a file

Using HID USB in Visual Basic 6.0

im trying to interface a Gramin usb GPS to get the coordinates in a visual basic project, but i dont have an idea how to accomplish this, anyone point me out in the right direction please?
If the Garmin unit uses an RS-232 (standard serial) interface, then its USB driver probably implements a virtual serial port that you can open using the MSCOMM control.
Check that by opening the Hardware Manager and see if there's an extra port, maybe even labeled 'Garmin', while it's plugged in.
There are simple, standard text protocols used by GPS units. As long as no other app has the port open, you should be able to open it in VB and capture the output with a little experimenting for baud rate, etc. 4800,8,N,1 is a good place to start.

Faking an RS232 Serial Port

I'm developing a project that has a number of hardware sensors connecting to the deployment machine through RS232 serial ports.
But ... I'm developing on a machine without an physical RS232 serial ports, but I would like to make fake serial ports that I can connect to and output data from with the aim of faking input from hardware sensors.
Does anyone know of a way to create a fake serial port and control it on Windows XP?
If you are developing for Windows, the com0com project might be, what you are looking for.
It provides pairs of virtual COM ports that are linked via a nullmodem connetion. You can then use your favorite terminal application or whatever you like to send data to one COM port and recieve from the other one.
EDIT:
As Thomas pointed out the project lacks of a signed driver, which is especially problematic on certain Windows version (e.g. Windows 7 x64).
There are a couple of unofficial com0com versions around that do contain a signed driver. One recent verion (3.0.0.0) can be downloaded e.g. from here.
I know this is an old post, but in case someone else happens upon this question, one good option is Virtual Serial Port Emulator (VSPE) from Eterlogic
It provides an API for creating kernel mode virtual comport devices, i.e. connectors, mappers, splitters etc.
However, some of the advertised capabilities were really not capabilities at all.
EDIT
A much better choice, Eltima. This product is fully baked. Good developer tech support. The product did all it claimed to do. Product options include both desktop applications, as well as software development kits with APIs.
Neither of these products are open source, or free. However, as other posts here have pointed out, there are other options. Here is a list of various serial utilities:
com0com (current)
com0com - With Signed Driver (old version)
Yet another place for com0com with Signed Driver (Pete's Blog)
Tactical Software
Termite
COM Port Serial Emulator
Kermit (obsolete, but still downloadable)
HWVSP3
HHD Software (free edition)
I use com0com - With Signed Driver, on windows 7 x64 to emulate COM3 AND COM4 as a pair.
Then i use COM Dataport Emulator to recieve from COM4.
Then i open COM3 with the app im developping (c#) and send data to COM3.
The data sent thru COM3 is received by COM4 and shown by 'COM Dataport Emulator' who can also send back a response (not automated).
So with this 2 great programs i managed to emulate Serial RS-232 comunication.
Hope it helps.
Both programs are free!!!!!
There's always the hardware route. Purchase two USB to serial converters, and connect them via a NULL modem.
Pro tips:
1) Windows may assign new COM ports to the adapters after every device sleep or reboot.
2) The market leaders in chips for USB to serial are Prolific and FTDI. Both companies are battling knockoffs, and may be blocked in future official Windows drivers. The Linux drivers however work fine with the clones.
Another alternative, even though the OP did not ask for it:
There exist usb-to-serial adapters.
Depending on the type of adapter, you may also need a nullmodem cable, too.
They are extremely easy to use under linux, work under windows, too, if you have got working drivers installed.
That way you can work directly with the sensors, and you do not have to try and emulate data.
That way you are maybe even save from building an anemic system.
(Due to your emulated data inputs not covering all cases, leading you to a brittle system.)
Its often better to work with the real stuff.
i used eltima make virtual serial port for my modbus application debug work. it is really very good application at development stage to check serial port program without connecting hardware.

Resources