#include <sys/fcntl.h>
#include <sys/file.h>
#include <unistd.h>
#include <stdio.h>
#include <termio.h>
#include <termios.h>
#include <errno.h>
#include <string.h>
#include <stdlib.h>

int main(){
  
  //fd is the file descriptor.  It is not a pointer, but rather a number
  //that unix assigns
  int fd, written, bytes, status, returned;
  char ispeed,ospeed;
  char pmessage[1]="p";
  char *amessage;
  char tmessage[1]="t";
  char smessage[1]="s";
  char *word;
  struct termios options;
  int p=0xFF;
  int errno;
  errno=0;
  //pmessage is a pointer that is initialized to point to a string constant
  //  int open(char *name, int flags, int perms);
  //fd=open("/home/lances/readme.txt",O_RDWR,0);
  //Open the Serial Port to be used
  fd=open("/dev/usb/ttyUSB0",O_RDWR | O_NONBLOCK | O_NOCTTY | O_NDELAY);
  errno=0; 
   
  //Do some setting business
  //Force a zero delay time in reading the serial port

  //Enable the receiver and set local mode

  written=write(fd,"s",1);
  //ioctl(fd,FIONREAD,&bytes);
  sleep(1);
  returned=read(fd,word,1);
  //ioctl(fd,TIOCMGET, &status);
//  fprintf(stderr, "%s: Couldn't open file %s; %s\n",
 //	  program_invocation_short_name,strerror(errno));
 
  perror("Your error:");
  printf("Your Error Number:%d\n",errno);
  printf("handle= %ld\n",fd);
  printf("number of bytes written=%ld\n",written);
  printf("value returned=%ld\n",returned);
  printf("value returned=%ld\n",*amessage);
  close(fd);
  return 0;
}

