[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

com port DTR and RTS - work around



I was able to clr DTR with one of the hwtest routines:
void clrbits( int bitmap ) {
 int devfd;
 devfd = open("/dev/gpiob", O_WRONLY);
 ioctl(devfd, _IO(ETRAXGPIO_IOCTYPE, IO_CLRBITS), bitmap);
 close( devfd );
}
 
// my new open
  int setvalue = 0x10;
 
  if ((fd = open("ttyS0", O_RDWR)) < 0) {
    printf("Couldn't open Com1\n");
    exit(1);
  }
 
  tcgetattr(fd, &tio);          /* get the termio information */
  tio.c_cflag &= ~HUPCL;        /* clear the HUPCL bit */
  tcsetattr(fd, TCSANOW, &tio); /* set the termio information */
 
  ioctl(fd, TIOCMGET, &status); /* get the serial port status */
 
  status |= TIOCM_DTR;
  status |= TIOCM_RTS;
 
  ioctl(fd, TIOCMSET, &status); /* set the serial port status */
 
  // this takes care or DTR
  clrbits(setvalue);
 
  close(fd);                    /* close the device file */
Murray