0

I'm writing a dotnet core application that interfaces with a cellular modem through a serial COM port (USB) and sends and receives AT commands. The application utilizes the SerialPort class. This is working great. However, there is a business requirement that, while the application is running, the customer can still Putty to that (or a) COM port and send/receive AT commands to the modem. Currently this is not possible because the application holds the port and the port is thus locked.

Is there a way, in C# dotnet core, to create a new virtual com port and forward the existing modem COM port send/receive data onto that new virtual com port? The end goal being, the customer can use Putty to interface with the modem while at the same time the application can still hold the port open and also communicate with the modem.

Ideally, the solution would work both on Windows and Linux.

Any help is greatly appreciated!

smoothgrips
  • 407
  • 3
  • 15
  • The answer can only be "maybe". Yes you can create a [virtual NM pair](https://stackoverflow.com/q/20979783/327083) of COM ports (for [linux](https://stackoverflow.com/q/52187/327083)) so that the existing application can connect to the VCP and send data to your application instead of to the modem. Your application would then need to manage receiving those data packets and forwarding them to the modem (and the reverse for responses) as well as determining which of the two applications gets priority in the case of simultaneous or conflicting messaging requests. – J... Jan 10 '22 at 20:49
  • The existing software may also have timing requirements that might be difficult or impossible to meet with this man-in-the-middle solution. Only you have the answers to those questions. RS-232 ports are not networks so having two masters is fundamentally incompatible with the protocol. In some cases you may still be able to make it work, but it will depend on the usage and the specific implementation. Some types of functionality would be easy to allow like this and some others would not. Better if your software can take over both roles, really. – J... Jan 10 '22 at 20:50
  • Thank you @J... for the advice! – smoothgrips Jan 10 '22 at 22:38

0 Answers0