0
votes

I'm quite new to programming at linux and its file-based communication. I need to create a virtual modem (or modem emulator) at linux machine. The idea is that the software module that sends commands to hardware modem on an FPGA,

At FPGA:

SoftwareModule <= ttyACM => HardwareModem

What I need to achieve at my computer:

SoftwareModule <=> MyModemEmulator acting like a fake UART

Purpose is that the software module can be tested on a linux machine where I have a fake software modem UART(?) port. So the software module sends the modem commands and my fake modem module catches and responds accordingly. So my module will be actually acting like a hardware modem.

What could be the steps I need to take for that? I'm quite new to working with serial ports and don't have deep knowledge of linux or hardware stuff.

I have come across 'socat' but I'm not sure if that can really serve the purpose. So far I have only learned how to create a basic file system with FUSE (as it was suggested by someone), but I'm not sure how can I use it for my purpose. I'm not looking for a proprietary solution, and not looking for windows based solution either.
Please guide me to the right directions. Thank you !

1
A complicated project like that might not be quite feasible for someone who's "quite new to programming at linux and its file-based communication". Nothing wrong with trying, but this is a fairly technical subject matter, and is not really answerable without a lot more detail. Perhaps a pty device would work here, and configuring the program to use /dev/ptyxxx instead of /dev/ttyS?, as the modem, but that cannot be stated for certainty.Sam Varshavchik
🐴 This is an “I want a pony” type of question that’s difficult to answer concisely and is off-topic on Stack Overflow. If you can, make an attempt and then show us your code we can understand what you’re trying to do on a technical level. Even a small amount of code, however incomplete or broken, can give us context and illustrate your intentions. Instead of leaving us to speculate on what you might need, give us something to build so we can focus help in those areas where it’s most needed.tadman
You're confusing "UART" and "modem" and treating them as if they're part of the same thing, which they aren't. There's a huge divide between a serial port like the typical RS-232 found on most systems, even virtually, and a modem, which is a telecommunications device. When you say "hardware modem on an FPGA" do you mean "serial connection to FPGA" or do you mean literal "modem" as in V.92 modem?tadman
@tadman I was told that the FPGA has ttyACM to talk to hardware modem. My computer with ubuntu does not have ttyACM, so I was told to create a fake modem, i.e. create a fake serial port that can grab the messages and respond as if it's a hardware modem. I may be mixing up some concepts here, but the very reason I'm asking the question here is to get the right directions. And my understanding is that stackoverflow is not about coding only.Usman.3D
I have omitted the word UART from the title. My goal is not to argue about keywords but to know how to emulate a modem through serial port.Usman.3D

1 Answers

0
votes

Creating a Fake Serial Port to Emulate Modem

What you refer to as a "serial port" in Linux is actually a serial terminal with many software layers.
Study Linux serial drivers, and the termios man page for salient functions that need to be emulated.
And you have not even considered how to factor in the USB component of the communication path.

At FPGA:

SoftwareModule <= ttyACM => HardwareModem
...
My computer with ubuntu does not have ttyACM

A /dev/ttyACMx device node is only created when a USB serial gadget is connected to the host.
So it's not surprising that you cannot find such a device node.

What I need to achieve at my computer:

SoftwareModule <=> MyModemEmulator acting like a fake UART

You have stated the issue poorly, since you (misguidedly) think that a "fake UART" (integrated with your "MyModemEmulator") is the appropriate solution.

Do not try to emulate both a serial terminal and an external modem on the Ubuntu host, since you are "quite new to programming at linux and serial ports" and the task of accurately emulating a serial terminal is risky and expensive.
What your goal should be is:

SoftwareModule <= ? => MyModemEmulator

and the question is "what is needed in the middle to interface these two units?".
IOW you have posted an XY problem.


There are a plethora of SBCs (single board computer) that have a USB gadget port and can be configured as a USB serial gadget that uses CDC ACM.
Since the actual "hardware modem on an FPGA" will use a USB CDC ACM connection, you should consider using an actual /dev/ttyACMx serial terminal, and emulating just the external device ("hardware modem") with a SBC.

In other words, instead of trying to achieve:

SoftwareModule <=> MyModemEmulator + fake USB serial terminal

it should be much easier to use existing interfaces and implement:

SoftwareModule <= USB => emulated HardwareModem

with a SBC running your Linux application for modem emulation using /dev/ttyGS0 (a USB serial terminal on the gadget end).
By using an actual USB CDC ACM connection and not implementing the "fake USB serial terminal", this approach eliminates an entire layer of SW+HW emulation and its possible false test results.


Addendum

If the use and/or cost of embedded Linux on a SBC concerns you, then there is an alternative scheme to emulate the "hardware modem" on your Ubuntu PC host instead of the SBC using a USB-to-RS232-to-USB connection.

  1. Acquire a pair (i.e. quantity 2) of USB-to-RS232 adapters and a (very short) null-modem cable.

  2. Connect the DB-9 ends of the adapters to the null-modem cable to make a single cable with both ends having a USB male type-A connector.

  3. Plug one adapter into the PC to create the /dev/ttyUSB0 device node. Treat this as the equivalent to /dev/ttyACM0 for your SoftwareModule.

  4. Plug the other adapter into the PC to create the /dev/ttyUSB1 device node. Treat this as the equivalent to /dev/ttyGS0 for your emulated "hardware modem".

  5. Develop, execute, and debug your emulated "hardware modem" on the Ubuntu PC host (without the unnecessary task of "creating a fake serial port").