Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Direct access PCI serial port

Hello i have an application built some times ago in C++.

It is used to control an appliance via serial port.

I remember the guy that developed it saying that his software is directly accessing the serial port (directly accessing the memory).

Since PCs with serial ports are becoming rare these days, would the software still directly access the serial port if i used a PCI extension serial port?

Thanks

like image 756
Cyril Avatar asked Nov 24 '22 22:11

Cyril


2 Answers

That depends a bit on how much backward-compatible driver support your PCIe serial port has.

If it provides direct I/O-space mapping of a (possibly virtual) 16550 UART's registers, you will need to change the "base address" in the software but then it might work. If the drivers do not, then it's not going to work.

The first four standard serial ports have the following base addresses and interrupts associated with them:

     | base   IRQ 
-----------------
COM1 | 0x3f8  IRQ4
COM2 | 0x2f8  IRQ3
COM3 | 0x3e8  n/a
COM4 | 0x2e8  n/a

The software should probably be rewritten to use more high-level access to the port.

like image 190
unwind Avatar answered Nov 27 '22 12:11

unwind


I believe that the vast majority of local bus serial port cards emulate a 16x50 RS-232 UART. Unless you intend to use some special card, such as those expensive multiport cards used for managing modem banks, it would probably be fine.

USB/RS-232 converters are a different story altogether - in general they will not work with software that accesses the serial port directly, as their driver only provides access via the OS serial port subsystem. Even if their driver somehow manages to emulate a proper local bus UART, those converters often have different behavior w.r.t. signal timing that might lead to issues with software that does unusual things with the serial port. For example, I have had issues with attaching IR remote control receivers to some USB/RS-232 converters. Using a converter that supports USB 2.0 helps somewhat, but it is still far from the real thing.

You should also keep in mind that if your application is designed for an older OS, newer versions of that operating system might not allow direct access to serial ports anymore.

If all else fails, you might still be able to improve the situation by using a virtual machine. For example, VirtualBox allows the guest OS to access the host serial ports, emulating a 16550A UART. This might allow you to work around a driver or an OS that does not support or allow direct access to a serial port.

like image 41
thkala Avatar answered Nov 27 '22 11:11

thkala