Skip to main content

README.md

# sersock

Serial port to socket exporter.

## Installation and Usage

  1. Add `sersock` to your list of dependencies in `mix.exs`:

    ```elixir
    def deps do
      [{:sersock, "~> 0.1.0"}]
    end
    ```

  2. Manually start and stop individual instances in one of the supported modes `:text` (default), `:raw`, and `:modbus`.

  ```elixir
  ["COM1", "ttyUSB0", "cu.usbserial-FTYHQD9MA"] = Baud.Enum.list()
  #Do not prepend /dev/ to the port name
  {:ok, pid} = Sersock.start_link([portname: "ttyUSB0", port: 5000])
  :ok = Sersock.stop(pid)
  ```

  3. Connect your serial port to some device and talk to it with `netcat`. Prepend with `rlwrap` for command history.

    ```
    #Talking to a KTA-223
    nc localhost 5000
    @00 IS 0
    #00 0
    ```

  4. Run the tests

    ```bash
    #Serial port names are hard coded in test_helper.exs
    #TCP ports are hard coded in sersock_test.exs
    #A couple of serial ports are required
    mix test
    ```