/*
 *  File: brick.c
 *  Date: 13 February 2001
 *  Acct: Matthew Ahrens (mahrens)
 *        touched up by Albert Huang (ashuang)
 *  Desc: demonstrates lnp debugging or something like that
 *
 */

#include <dlcd.h>
#include <conio.h>
#include <lnp/lnp.h>

#include <unistd.h>
#include <string.h>
#include <stdio.h>

/*  
 *
 */

int lnp_printf(unsigned char dest, const char *fmt, ...)
{
  int len;
  va_list arg;
  char buf[250];

  va_start(arg, fmt);
  len = vsnprintf(buf, sizeof(buf), fmt, arg);
  va_end(arg);

  /* send the formatted string to the destination, and set the
   * originating source port as 1, even though we don't really
   * want a response
   */
  lnp_addressing_write(buf, 
		       len < sizeof(buf) ? len : sizeof(buf),
		       dest, 1);

  return len;
}

int main() {
  int i;

  /* 
   * 0xf2 is hopefully the address and port of the target computer 
   *
   * should start lnp_listen program with these arguments if you set
   * the address to 0xf0 and the port to 0x02
   * 
   * 	lnp_listen f0 02
   *
   */

  unsigned char addr, port, dest;

  addr = 0xf0;
  port = 0x02;
  dest = addr | port;  /* the destination is the OR of the address and the port */

  for (i=0; i<50; i++)
    {
      lnp_printf(dest, "testing %d\n", i);
    }
	
  return 0;

}
