# `mix ads.route`
[🔗](https://github.com/tallakt/yaads/blob/v0.1.0/lib/mix/tasks/ads.route.ex#L1)

Finds the PLCs on the network, and adds a route on one for this machine with the login of a user
on it, so that `ADS.Client` can connect; then connects, to see that it can:

    $ mix ads.route
    Searching for PLCs...

      1  CX-1234AB   10.0.0.5   5.36.69.176.1.1
      2  DESKTOP-B9  10.0.0.9   10.0.0.9.1.1

    PLC (1-2, or an address): 1
    User [Administrator]:
    Password:
    This machine's NetId [10.0.0.7.1.1]:
    Route name [scada-1]:
    Adding a route on CX-1234AB (10.0.0.5)...
    Connecting...
    Connected to Plc30 App 3.1.4026, in run.

        {:ok, plc} = ADS.Client.start_link(host: "10.0.0.5", net_id: "5.36.69.176.1.1")

A firewall on this machine, such as ufw, may drop the PLCs' answers to the search, as they come
from another address than the broadcast went to; a PLC asked by its address answers through it.

Enter takes what's in brackets. A PLC given on the command line isn't searched for, and an
option given isn't asked for; `--yes` takes what's in brackets without asking:

    $ mix ads.route 10.0.0.5 --yes

As with TwinCAT's own tools, the password goes over the network unencrypted. The search and the
route go over UDP port 48899 (see `ADS.Discovery`), and the connection over TCP port 48898.

## Options

  * `--user`, `--password`, `--net-id`, `--name` - as asked; a password given here is kept in
    the shell's history
  * `--address` - this machine's address as the PLC is to know it, as behind NAT (default the
    address it sends from)
  * `--search` - where to search, a broadcast address or a PLC's, as often as needed (default
    every network this machine is on)
  * `--yes`, `-y` - take what's in brackets without asking
  * `--no-connect` - don't connect after
  * `--list` - list the PLC's routes rather than add one, through this machine's route to it,
    which it needs; no login is asked for
  * `--delete` - delete the route rather than add it; the route of the name, which TwinCAT
    deletes by, as it was added. If the PLC doesn't answer this machine over ADS, it has no
    route for it, and nothing is asked or deleted; if it does, the login and name are asked for
    as when adding, and it is to answer no more after, or the removal failed, as TwinCAT's
    answer doesn't tell
  * `--timeout` - how long to wait for answers over UDP, in ms (default 2000 for the search,
    5000 otherwise)
  * `--tcp-port`, `--udp-port`, `--ams-port` - if not 48898, 48899 and 851
  * `--codepage` - of the PLC's strings, such as `windows-1251`, if not Windows-1252 (see
    `ADS.Codepage`)

---

*Consult [api-reference.md](api-reference.md) for complete listing*
