Beispiel #1
0
bool QSerialPort::open(int block)
{
	if( block== 1) portDesc = ::open(portName.toAscii(),O_RDWR);
	else portDesc = ::open(portName.toAscii(),O_RDWR | O_NONBLOCK );
	if(portDesc == -1)
	{
		return false;
	}
	portOpen = true;

	tcgetattr(portDesc, &portConfig);
	
	portConfig.c_cflag|=(CLOCAL | CREAD);
	portConfig.c_lflag&=(~(ICANON|ECHO|ECHOE|ECHOK|ECHONL|ISIG));
	portConfig.c_iflag&=(~(IGNBRK|BRKINT|PARMRK|ISTRIP |INLCR| IGNCR|ICRNL|IXON)); //  (~(INPCK|IGNPAR|PARMRK|ISTRIP|IXANY));
	portConfig.c_iflag&=~(ICRNL);

	portConfig.c_oflag&=(~OPOST);
	
	tcsetattr(portDesc, TCSANOW, &portConfig);

	setBaudRate(settings.baudRate);
	setDataBits(settings.dataBits);
	setFlowControl(settings.flowControl);
	setParity(settings.parity);
	setStopBits(settings.stopBits);
	setDtr();
	setRts();

	connect(&portFile, SIGNAL(readyRead()), this, SLOT(slotNotifierActivated()));

	return true;
}
/**
 *  Initialize the interface.
 *
 *  The base class handles all hardware initialization for us, so we only
 *  have to set up the correct control line states to power the interface.
 */
int T_TX_InterfaceSerPIC::init (SimpleXMLTransfer *config)
{
#if DEBUG_TX_INTERFACE > 0
  std::cout << "T_TX_InterfaceSerPIC::init ()\n";
#endif
  int ret = T_TX_InterfaceSerial::init (config);

  if (ret == 0)
  {
    // initialized successfully, now turn on the power supply for the
    // interface hardware (careful, could throw an exception)
    try
    {
      setRts (true);
      setDtr (false);
    }
    catch (CharDevice::ConfigureDeviceException e)
    {
      setErrMsg ("Setting Rts/Dtr states failed.");
      cerr << "Serial interface initialization: " << getErrMsg () << endl;
      ret = 1;
    }

    int default_sync_byte = DEFAULT_SYNC_BYTE_19200;
    int default_button_channel = DEFAULT_BUTTON_CHANNEL_19200;
    if (T_TX_InterfaceSerial::getBaudRate() == 9600)
    {
      default_sync_byte = DEFAULT_SYNC_BYTE_9600;
      default_button_channel = DEFAULT_BUTTON_CHANNEL_9600;
    }
    // read sync and button byte settings from config file
    SimpleXMLTransfer *port = config->getChild(getXmlChildName() + ".port", true);
    ucSyncByte              = port->attributeAsInt("sync", default_sync_byte);
    iSPIC_ButtonChannel     = port->attributeAsInt("button_channel", default_button_channel);
#if DEBUG_TX_INTERFACE > 0
    std::cout << "  Configured sync byte: 0x" << std::hex << int(ucSyncByte) << std::dec;
    std::cout << ", " << std::string((iSPIC_ButtonChannel == 0) ? "no" : "has") << " button channel";
    std::cout << std::endl;
#endif
  }

  return ret;
}
Beispiel #3
0
/*!
    Sets the DCD (carrier) modem status line to \a value.  This is used by
    programs that accept incoming serial connections to indicate to the
    peer machine that the carrier has dropped.

    By default, this calls setDtr(), which supports the case where a
    null modem cable is connecting DTR to DSR and DCD on the peer machine.
    The caller should wait for a small delay and then setDtr(true)
    to restore DTR to the correct value.

    This function will return false if it uses setDtr() to transmit the
    carrier change, or true if it can use a real carrier signal
    (QGsm0710MultiplexerServer supports real carrier signals).

    \sa carrier()
*/
bool QSerialIODevice::setCarrier( bool value )
{
    setDtr( value );
    return false;
}