
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <process.h>
#include <conio.h>
#include <time.h>
#include <dos.h>  /* Dos-specific functions are used to get date/time. */

#include "common.h"
#include "modem.h"     /* Routines for accessing the modem. */

main()
{
char the_char;     /* Use this for hold everything. */
modem_port  = 1;
modem_speed = 2400;
if (initSerial(modem_port,modem_speed,modem_parity,modem_bits,modem_stopbits))
  {
  printf("?Problem opening port %d at speed %d!\n",modem_port,modem_speed);
  return(1);
  }
printf("Connected to COM%d at speed %d; enter ^A to exit, ^B for status!\n",modem_port,modem_speed);
while (1)     /* Loop until we break out. */
  {
  if (kbhit())       /* Was a character entered at the keyboard? */
    {
    the_char = getch();
    if (the_char == 1)   /* Exit? */
      break;         /* Break out of loop, ending program. */
    if (the_char == 2)
      printf("CD state is %d.\n",port_cd());
    else
    if (the_char == 4)
      printf("Ring indicator is %d.\n",port_ring());
    else
      port_out(the_char);
    }
  the_char = port_in();   /* Is a character waiting from the modem? */
  if (the_char != -1)
    printf("%c",the_char);
  }
deinitSerial(0);   /* ...turning off DTR. */
return(0);
}


