Simulate UART device on host pc

Hey everyone!

I just want to simulate an uart device on the host pc to test my code locally.
I’m using tty0tty to simulate the uart interface.
My code so far:

defmodule UartSimulator do
    use GenServer

    @path_tty0tty "/bin/tty0tty"   

    def start_link() do
    {:ok, pid} = GenServer.start_link(__MODULE__, %{})
  end

  def init(state) do
    tty0tty = Port.open({:spawn, path_tty0tty}, [:binary])
    port = File.open!("/dev/pts/2", [:write])

    {:ok, %{state | tty0tty: tty0tty, port: port}}
  end

  def handle_cast({:data_reporting_mode, mode, activity}, %{port: port} = state) do
    IO.binwrite(port, "hello world")
    {:noreply, state}
  end
end

Is this the way to go?
And how can I implement this module in my testing environment? I’m getting the error that the module is not available.