예제 #1
0
bool SerialPort::waitForData(const Misc::Time& timeout) const
	{
	/* Check if there is unread data in the buffer: */
	if(getUnreadDataSize()>0)
		return true;
	
	/* Wait for data on the socket and return whether data is available: */
	Misc::FdSet readFds(fd);
	return Misc::pselect(&readFds,0,0,timeout)>=0&&readFds.isSet(fd);
	}
예제 #2
0
bool TCPPipeMaster::waitForData(const Misc::Time& timeout) const
	{
	/* Check if there is unread data in the buffer: */
	if(getUnreadDataSize()>0)
		return true;
	
	/* Wait for data on the socket and return whether data is available: */
	Misc::FdSet readFds(fd);
	bool result=Misc::pselect(&readFds,0,0,timeout)>=0&&readFds.isSet(fd);
	
	/* Send a status message to the slaves: */
	Packet* statusPacket=multiplexer->newPacket();
	{
	Packet::Writer writer(statusPacket);
	writer.write<int>(result?1:0);
	}
	multiplexer->sendPacket(pipeId,statusPacket);
	
	return result;
	}