6/07/2013

serial port cts rts checking signal cable. linux and win32



// win32

int IsCTSEnabled(int handle)
{
  int status;

  GetCommModemStatus(handle, (LPDWORD)((void *)&status));

  if(status&MS_CTS_ON) return(1);
  else return(0);
}

// linux.

// ref
/*
TIOCM_LE  DSR (data set ready/line enable)
TIOCM_DTR DTR (data terminal ready)
TIOCM_RTS RTS (request to send)
TIOCM_ST  Secondary TXD (transmit)
TIOCM_SR  Secondary RXD (receive)
TIOCM_CTS CTS (clear to send)
TIOCM_CAR DCD (data carrier detect)
TIOCM_CD  Synonym for TIOCM_CAR
TIOCM_RNG RNG (ring)
TIOCM_RI  Synonym for TIOCM_RNG
TIOCM_DSR DSR (data set ready)
*/
int RS232_IsCTSEnabled(int handle)
{
  int status;

  ioctl((int handle, TIOCMGET, &status);

  if(status&TIOCM_CTS) return(1);
  else return(0);
}








댓글 없음: