예제 #1
0
int EscapeCommFunction (int fd, int whatToDo)
{
  switch(whatToDo)
  {
    case CLRDTR: return setDTR(fd, 0); break;
    case CLRRTS: return setRTS(fd, 0); break;
    case SETDTR: return setDTR(fd, 1); break;
    case SETRTS: return setRTS(fd, 1); break;
  default: return (setDTR(fd, 0) && setRTS(fd, 0)); break; //is this a good idea? :/
  }
}
예제 #2
0
int main(int argc, char **argv)
{
    if (argc > 1) {
        openserial(argv[1]);
    } else {
        openserial(SERIAL_PORT);
    }
    setDTR(1);
    return 0;
}
예제 #3
0
int openserial(char *devicename) 
{
     struct termios attr;

     if ((fd = open(devicename, O_RDWR)) == -1) return 0; /* Error */ 
     atexit(closeserial);

     if (tcgetattr(fd, &oldterminfo) == -1) return 0; /* Error */
     attr = oldterminfo;
     attr.c_cflag |= CRTSCTS | CLOCAL;
     attr.c_oflag = 0;
     if (tcflush(fd, TCIOFLUSH) == -1) return 0; /* Error */
     if (tcsetattr(fd, TCSANOW, &attr) == -1) return 0; /* Error */ 

     /* Set the lines to a known state, and */
     /* finally return non-zero is successful. */
     return setRTS(0) && setDTR(0);
}
예제 #4
0
파일: softmodem.cpp 프로젝트: Avin15/dospad
void CSerialModem::setRTSDTR(bool rts, bool dtr) {
	setDTR(dtr);
}
예제 #5
0
void CSerialDummy::setRTSDTR(bool rts, bool dtr) {
	setRTS(rts);
	setDTR(dtr);
}
int plugin_open_rig( char * config )
{
  struct termios ios;
  tcflag_t bauds;
  char *tty;
  char *ptr;

  if( config != NULL )
    tty=config;
  else
    tty="/dev/ttyS0";

#ifdef DEBUG
  fprintf(stderr,"ICR10: trying to open rig on %s with config: %s.\n",tty,config);
#endif

  /* Open the tty and configure it */

  if ((port = open(tty, O_RDWR | O_NOCTTY)) == -1) {
    perror("open");
    return 0;
  }

  if (!isatty(port)) {
    close(port);
    fprintf(stderr, "ICR10: %s: not a tty\n", tty);
    return 0;
  }

  memset(&ios, 0, sizeof(ios));

  cfsetispeed(&ios, B9600);
  cfsetospeed(&ios, B9600);

  ios.c_cflag |=  (CLOCAL | CREAD);
  ios.c_cflag &= ~HUPCL ;
  ios.c_cflag &= ~PARENB ;
  ios.c_cflag &= ~CSTOPB ;
  ios.c_cflag &= ~CSIZE;
  ios.c_cflag |= CS8;

  /* ICANON  : enable canonical input disable all echo functionality,
     and don't send signals to calling program */
  ios.c_lflag |= ICANON;
  ios.c_lflag &= ~(ECHO | ECHOCTL);

  /* ignore bytes with parity errors */
  ios.c_iflag |= IGNPAR;

  /* Raw output.  */
  ios.c_oflag &= ~OPOST;

  if (tcsetattr(port, TCSANOW, &ios) == -1) {
    perror("tcsetattr");
    return 0;
  }

  setDTR( port );

#ifdef DEBUG
  fprintf(stderr,"ICR10: open rig succeed.\n");
#endif

  return 1;
}
예제 #7
0
int plugin_open_rig( char * config )
{
  struct termios ios;
  tcflag_t bauds;
  char dummy[64];
  char tty[12];
  char speed[8];
  char *ptr, *parm;
  int portbauds, n;

  tty[0]='\0';
  speed[0]='\0';
  civid[0]='\0';

  if(config) {
    strncpy(dummy,config,64);

    ptr=dummy;
    parm=ptr;
    while( parm != NULL ) {
      parm=strsep(&ptr,":");
      if(parm==NULL)
	break;
      if(strlen(parm)!=0) {
	switch( *parm ) {
	case 'D':
	  strcpy(tty,parm+1);
	  break;
	case 'S':
	  strcpy(speed,parm+1);
	  break;
	}
      }
    }
  }
    
  if(strlen(tty)==0)
    strcpy(tty,"/dev/ttyS0");
  if(strlen(speed)==0)
    strcpy(speed,"4800");

  portbauds=atoi(speed);
  switch( portbauds ) {
  case 300:
    bauds=B300;
    break;
  case 1200:
    bauds=B1200;
    break;
  case 2400:
    bauds=B2400;
    break;
  case 4800:
    bauds=B4800;
    break;
  case 9600:
    bauds=B9600;
    break;
  case 19200:
    bauds=B19200;
    break;
  default:
    bauds=B9600;
  }

#ifdef DEBUG
  fprintf(stderr,"FT817: trying to open rig with config: %s.\n",config);
  fprintf(stderr,"FT817: config tty: %s\n",tty);
  fprintf(stderr,"FT817: config speed: %s\n",speed);
#endif

  /* Open the tty and configure it */

  if ((port = open(tty, O_RDWR | O_NOCTTY)) == -1) {
    perror("open");
    return 0;
  }

  if (!isatty(port)) {
    close(port);
    fprintf(stderr, "FT817: %s: not a tty\n", tty);
    return 0;
  }

  memset(&ios, 0, sizeof(ios));

  cfsetispeed(&ios, bauds);
  cfsetospeed(&ios, bauds);

  ios.c_cflag |=  (CLOCAL | CREAD);
  ios.c_cflag &= ~HUPCL ;
  ios.c_cflag &= ~PARENB ;
  ios.c_cflag &= ~CSTOPB ;
  ios.c_cflag &= ~CSIZE;
  ios.c_cflag |= CS8;

  /* ICANON  : enable canonical input disable all echo functionality,
     and don't send signals to calling program */
  ios.c_lflag |= ICANON;
  ios.c_lflag &= ~(ECHO | ECHOCTL);

  /* ignore bytes with parity errors */
  ios.c_iflag |= IGNPAR;

  /* Raw output.  */
  ios.c_oflag &= ~OPOST;

  if (tcsetattr(port, TCSANOW, &ios) == -1) {
    perror("tcsetattr");
    return 0;
  }

  setDTR( port );

#ifdef DEBUG
  fprintf(stderr,"FT817: open rig succeed.\n");
#endif

  return 1;
}