The canctl application provides a CAN network service.  Any application on the network can make use of this service to send or receive CAN packets using the API defined by canctl.  Thus, it is possible to develop code written in other languages (java, python, etc.) and/or to run this code under other operating systems.

To start the CAN network service, invoke canctl with the "--server" option:
canctl --server

The canctl application itself can be a client of any canctl server running on the network.  When compiling canctl for a platform which lacks the TS-CAN hardware, use the -DREMOTE_ONLY flag to the compiler to indicate that the executable is to be compiled as a client only.  The supplied Makefile defines this flag when the environment variable "CLIENT" is defined.  This has been tested on an X86 Linux box - the following command builds canctl for client use:
CLIENT=1 make

To invoke canctl as a client, specify the "--port" option.  This option requires an argument which is the IP name or address of the server.  (The canctl server uses TCP/IP port 7552.)  All subsequent command-line arguments will communicate with the specified canctl server using the CAN network service.

Example: Send a CAN packet with the data 01:02:03:04:05:06 on the TS-7552 (it is assumed that the canctl server is running on this board) with IP address 192.168.1.100:
canctl --port=192.168.1.100 --txdat=01:02:03:04:05:06 

The canctl application implements network CAN functionality using the can_rx_remote() and can_tx_remote() functions.  These are very simple functions which read and write one fixed-size packet of struct canmsg to a TCP socket descriptor.  Writing your own canctl client in the language of your choice is as simple as doing the same thing.  The format of the each CAN packet sent or received via the network interface is described below.  The terms "Rx" and "Tx" are relative to the client, so "Rx" would describe packets read from CAN over the network and "Tx" would describe packets written to CAN over the network.

  UINT8    flags:
           bit 7 - set on Tx if packet is a control packet
                   control packets are intercepted by the
                   canctl server to allow control functionality.
           bit 6 - set if message originates locally (unused)
           bit 5 - set if CAN message has extended ID
           bit 4 - set if remote transmission request (RTR)
           bit 3 - set on Rx if CAN error warning condition occurred
           bit 2 - set on Rx if CAN bus had a data overrun
           bit 1 - set on Rx if CAN bus went error passive
           bit 0 - set on Rx if a CAN bus error occurred
           Error conditions are reported for informational
           purposes.  The server normally handles these errors
           and recovers from them.
               control information present (reserved for future use)
               message originates from this node (unused)
  UINT32   CAN id
  UINT32   timestamp_seconds
  UINT32   timestamp_microseconds
  UINT8    bytes of CAN data which are valid
           if bit 7 of flags is set, this byte is instead interpreted
           as a command number:
             0 = set acceptance filter
               if the acceptance filter has been set, then only
               CAN packets which pass the filter will be received.
               to pass the filter, all bits in the acceptance filter
               which are to be checked (specified by a 1 in the
               corresponding bit of the mask) are compared (filter
               id compared to corresponding bit in received id).
               only if all bits to be checked do match will the
               packet be received.
  UINT8[8] CAN data
           if bit 7 of flags is set, this byte is instead interpreted
           as follows:
             cmd 0:
               UINT32 acceptance filter id
               UINT32 acceptance filter mask

(Note: UINT32 values are sent in little-endian format)

So for example, to send a CAN packet of length 6 with contents 01:02:03:04:05:06 and CAN id 55 it would be necessary to open a TCP connection to port 7552 on the device with the canctl server running, and the write the following packet to the socket:
00 55 00 00 00 00 00 00 00 00 00 00 00 06 01 02 03 04 05 06 00 00
