當前位置: 首頁>>代碼示例>>C++>>正文


C++ CanRead函數代碼示例

本文整理匯總了C++中CanRead函數的典型用法代碼示例。如果您正苦於以下問題:C++ CanRead函數的具體用法?C++ CanRead怎麽用?C++ CanRead使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。


在下文中一共展示了CanRead函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C++代碼示例。

示例1: GetAttributeIndexToRead

void CGXDLMSAutoConnect::GetAttributeIndexToRead(std::vector<int>& attributes)
{
    //LN is static and read only once.
    if (CGXDLMSObject::IsLogicalNameEmpty(m_LN))
    {
        attributes.push_back(1);
    }
    //Mode
    if (CanRead(2))
    {
        attributes.push_back(2);
    }
    //Repetitions
    if (CanRead(3))
    {
        attributes.push_back(3);
    }
    //RepetitionDelay
    if (CanRead(4))
    {
        attributes.push_back(4);
    }
    //CallingWindow
    if (CanRead(5))
    {
        attributes.push_back(5);
    }
    //Destinations
    if (CanRead(6))
    {
        attributes.push_back(6);
    }
}
開發者ID:bfabio,項目名稱:Gurux.DLMS.cpp,代碼行數:33,代碼來源:GXDLMSAutoConnect.cpp

示例2: CanConfig

int CanConfig(unsigned char channel)
{
	unsigned char temp;
	
	CanReset(channel);	// reset CAN controller
	
	//------ Write Control Register (CR)
	CanWrite(channel, CR, 0x01);	// Enter Reset Mode without setting RIE
	// and enter reset mode (Set Reset Request bit)
	
	//------ Write Bus Timing Register 0 & 1 (BTR0 & BTR1)
	// BTR can be accessed (read/write) if the reset mode is active
	CanWrite(channel, BTR0, CAN[channel].btr0); // Write Bus Timing Register 0 (BTR0)
	CanWrite(channel, BTR1, CAN[channel].btr1); // Write Bus Timing Register 1 (BTR1)
	
	temp = CanRead(channel, BTR0);
	if(temp != CAN[channel].btr0)			// Read BTR0 and confirm it
		return(ERR_CONFIG);					// fail to configure
	
	temp = CanRead(channel, BTR1);
	if(temp != CAN[channel].btr1)			// Read BTR1 and confirm it
		return(ERR_CONFIG);					// fail to configure
	
	//------ Write Acceptance Code Register (ACR) and
	//		 Acceptance Mask Register (AMR)
	CanWrite(channel, ACR, CAN[channel].acc_code);        // Write ACR
	CanWrite(channel, AMR, CAN[channel].acc_mask);        // Write AMR
	
	//------ Write Output Control Register (OCR)
	//   Set Normal Output Mode & Push-pull dirver
	CanWrite(channel, OCR, 0xfa);
	
	return(ERR_OK);	        // successful
}
開發者ID:auxsophia,項目名稱:Jaemi-DRC,代碼行數:34,代碼來源:CAN.CPP

示例3: GetAttributeIndexToRead

void CGXDLMSActivityCalendar::GetAttributeIndexToRead(std::vector<int>& attributes)
{
    //LN is static and read only once.
    if (CGXDLMSObject::IsLogicalNameEmpty(m_LN))
    {
        attributes.push_back(1);
    }
    //CalendarNameActive
    if (CanRead(2))
    {
        attributes.push_back(2);
    }
    //SeasonProfileActive
    if (CanRead(3))
    {
        attributes.push_back(3);
    }

    //WeekProfileTableActive
    if (CanRead(4))
    {
        attributes.push_back(4);
    }
    //DayProfileTableActive
    if (CanRead(5))
    {
        attributes.push_back(5);
    }
    //CalendarNamePassive
    if (CanRead(6))
    {
        attributes.push_back(6);
    }
    //SeasonProfilePassive
    if (CanRead(7))
    {
        attributes.push_back(7);
    }
    //WeekProfileTablePassive
    if (CanRead(8))
    {
        attributes.push_back(8);
    }
    //DayProfileTablePassive
    if (CanRead(9))
    {
        attributes.push_back(9);
    }
    //Time.
    if (CanRead(10))
    {
        attributes.push_back(10);
    }
}
開發者ID:d21d3q,項目名稱:Gurux.DLMS.cpp,代碼行數:54,代碼來源:GXDLMSActivityCalendar.cpp

示例4: GetWBack

wxInputStream& wxInputStream::Read(void *buf, size_t size)
{
    char *p = (char *)buf;
    m_lastcount = 0;

    size_t read = GetWBack(buf, size);
    for ( ;; )
    {
        size -= read;
        m_lastcount += read;
        p += read;

        if ( !size )
        {
            // we read the requested amount of data
            break;
        }

        if ( p != buf && !CanRead() )
        {
            // we have already read something and we would block in OnSysRead()
            // now: don't do it but return immediately
            break;
        }

        read = OnSysRead(p, size);
        if ( !read )
        {
            // no more data available
            break;
        }
    }

    return *this;
}
開發者ID:BackupTheBerlios,項目名稱:wxbeos-svn,代碼行數:35,代碼來源:stream.cpp

示例5: RETURN_ZERO_IF_FALSE

size_t BufferStream::ReadDataTo(MemoryData& outData, DataReadingMode mode/*=DataReadingMode::AlwaysCopy*/)const
{
	RETURN_ZERO_IF_FALSE(CanRead());
	FlushOnReadWrite(StreamDataOperation::Read);

	size_t outPos = 0;
	size_t outSize = outData.Size();

	//read left buffer data
	size_t bufferLeftLength = mBufferLength - mBuffer.Position();
	if (bufferLeftLength != 0)
	{
		size_t readSize = Math::Min(bufferLeftLength, outSize);
		MemoryData tempData = MemoryData::FromStatic(outData.MutableData() + outPos, readSize);
		readSize = mBuffer.ReadDataTo(tempData, DataReadingMode::AlwaysCopy);
		outPos += readSize;
		outSize -= readSize;
	}

	//directly read to out data block per block
	size_t blockSize = mBuffer.Length();
	size_t blockCount = outSize / blockSize;
	FOR_EACH_SIZE(i, blockCount)
	{
		MemoryData tempData = MemoryData::FromStatic(outData.MutableData() + outPos, blockSize);
		size_t readSize = mSourceStream->ReadDataTo(tempData);
		outPos += readSize;
		outSize -= readSize;
		if (readSize != blockSize)	//last block
		{
			return outPos;
		}
	}
開發者ID:fjz13,項目名稱:Medusa,代碼行數:33,代碼來源:BufferStream.cpp

示例6: accept

bool EzSockets::accept(EzSockets& socket)
{

	if (!blocking && !CanRead())
		return false;

	#if defined(HAVE_INET_NTOP)
		char buf[INET_ADDRSTRLEN];

		inet_ntop(AF_INET, &addr.sin_addr, buf, INET_ADDRSTRLEN);
		address = buf;

	#elif defined(HAVE_INET_NTOA)
		address = inet_ntoa(addr.sin_addr);
	#endif
	
	int length = sizeof(socket);
	
	socket.sock = ::accept(sock,(struct sockaddr*) &socket.addr, 
						   (socklen_t*) &length);
	
	lastCode = socket.sock;

	if (socket.sock <= 0)
		return false;
	
	socket.state = skCONNECTED;
	return true;
}
開發者ID:geekmaster,項目名稱:stepmania-3.9,代碼行數:29,代碼來源:ezsockets.cpp

示例7: RETURN_ZERO_IF_FALSE

size_t IStream::ReadToStream(size_t size, IStream& dest, size_t bufferSize/*=1024*/)const
{
	RETURN_ZERO_IF_FALSE(CanRead() && dest.CanWrite());

	if (dest.IsPtrAvailable())//could directly write
	{
		dest.ReserveLeftSize(size);
		byte* buffer = dest.MutablePtr();
		MemoryData destBuffer = MemoryData::FromStatic(buffer, size);
		return ReadDataTo(destBuffer, DataReadingMode::AlwaysCopy);
	}
	else
	{
		//should use temp  buffer
		size_t count = 0;
		size_t realBufferSize = Math::Min(LeftLength(), bufferSize, size);

		MemoryData tempBuffer = MemoryData::Alloc(realBufferSize);
		do
		{
			size_t readSize = Math::Min(size, realBufferSize);
			tempBuffer.ForceSetSize(readSize);

			readSize = ReadDataTo(tempBuffer, DataReadingMode::AlwaysCopy);
			BREAK_IF_ZERO(readSize);
			tempBuffer.ForceSetSize(readSize);
			count += dest.WriteData(tempBuffer);
			tempBuffer.ForceSetSize(realBufferSize);
			size -= readSize;
		} while (size > 0);
		return count;
	}

}
開發者ID:fjz13,項目名稱:Medusa,代碼行數:34,代碼來源:IStream.cpp

示例8: RecvUnknowLen

// 接收數據
int RecvUnknowLen(int SocketFd, void *ptr, size_t nbytes, int nSecond, int nMiniSec) {
	ssize_t	  n = -1;	

	if (nbytes > 0)
	{
		while ((n = recv(SocketFd, (char *)ptr, nbytes, 0)) < 0)
		{
			if (EWOULDBLOCK == errno)
			{
				if (nSecond || nMiniSec)
				{
					if (CanRead(SocketFd, nSecond, nMiniSec) <= 0)
					{
						break;
					}
					nSecond = 0;//nMiniSec隻等一次
					nMiniSec = 0;
				}
				else
				{
					break;
				}
			}
			else
			{
				//連接需要關閉
				n = 0;	
				break;
			}
		}
	}

	return n;
}
開發者ID:hamburger20140810,項目名稱:utils,代碼行數:35,代碼來源:socket_util.cpp

示例9: GetAttributeIndexToRead

void CGXDLMSAutoAnswer::GetAttributeIndexToRead(std::vector<int>& attributes)
{
    //LN is static and read only once.
    if (CGXDLMSObject::IsLogicalNameEmpty(m_LN))
    {
        attributes.push_back(1);
    }
    //Mode is static and read only once.
    if (!IsRead(2))
    {
        attributes.push_back(2);
    }
    //ListeningWindow is static and read only once.
    if (!IsRead(3))
    {
        attributes.push_back(3);
    }
    //Status is not static.
    if (CanRead(4))
    {
        attributes.push_back(4);
    }

    //NumberOfCalls is static and read only once.
    if (!IsRead(5))
    {
        attributes.push_back(5);
    }
    //NumberOfRingsInListeningWindow is static and read only once.
    if (!IsRead(6))
    {
        attributes.push_back(6);
    }
}
開發者ID:d21d3q,項目名稱:Gurux.DLMS.cpp,代碼行數:34,代碼來源:GXDLMSAutoAnswer.cpp

示例10: CanSendMsg

// CAN 메세지를 보내는 함수
int CanSendMsg(unsigned char channel, unsigned short id, unsigned char *data, unsigned char dlc, unsigned char rtr)
{
    unsigned char v, i;

	//RtWprintf(L"\n>>> ID:%x Tx_Data:%x Tx_DLC:%x", id, data[0], dlc);

    v = id >> 3;
    CanWrite(channel, TXID1, v);	// write Identifier (ID.10 .. ID.3)
    v = id & 0x07;        			// write Identifier (ID.2 .. ID.0) to b7..b5
    v <<= 5;
	
    if(rtr==1) v |= 0x10;  			// check Remote Transmit Request (RTR) bit
	
    v += dlc;            			// add Data Length Code (DLC)
    CanWrite(channel, TXID2, v);	// Write Identifier unsigned char 2
	
    for(i=0; i<dlc; i++) CanWrite(channel, TXDATA+i, *(data+i));	// write Data unsigned char
	
    // Write TR of Command Register (CMR)
    CanWrite(channel, CMR, 0x01);	// Set Transmission Request (TR): message will be transmitted
	
    while(1)
    {
		v = CanRead(channel, SR);	// Read Status Register (SR)
		if(v & 0x40)				// If Error Status(ES) bit is set
			return(ERR_SEND);		// fail to send
		if(v & 0x08)				// when Transmission Complete Status (TCS) bit is set
			return(ERR_OK);	        // return (=successful)
    }
}
開發者ID:auxsophia,項目名稱:Jaemi-DRC,代碼行數:31,代碼來源:CAN.CPP

示例11: Read

void CBPacket::Read(void* buf, long size)
{
	if (size < 1 || !CanRead(size))
		return ;
	memcpy(buf, m_buf + m_ptr, size);
	m_ptr += size;
}
開發者ID:Light-Games-Ink,項目名稱:LMLastChaosSource,代碼行數:7,代碼來源:BPacket.cpp

示例12: ReadBool

// Read a boolean value
bool BufferedSocket::ReadBool(bool &val)
{
    if (!CanRead(1))
    {
        wxLogDebug(_T("ReadBool: End of buffer reached!"));
        
        val = false;
        
        m_BadRead = true;
        
        return false;
    }
        
    wxDataInputStream dis(*m_ReceiveBufferHandler);
    dis.BigEndianOrdered(BigEndian);

    wxInt8 Value = 0;

    Value = dis.Read8();
    
    if (Value < 0 || Value > 1)
    {
        wxLogDebug(_T("ReadBool: Value is not 0 or 1, possibly corrupted packet"));
        
        val = false;
        
        m_BadRead = true;
        
        return false;
    }
    
    val = Value ? true : false;
    
    return true;
}
開發者ID:JohnnyonFlame,項目名稱:odamex,代碼行數:36,代碼來源:net_io.cpp

示例13: CanReset

// CAN Reset 함수
void CanReset(unsigned char channel)
{	
	unsigned char temp;
	temp = CanRead(channel, 0x0100);
	CanWrite(channel, 0x0100, temp);
	Sleep(100); 	// wait 100ms
}
開發者ID:auxsophia,項目名稱:Jaemi-DRC,代碼行數:8,代碼來源:CAN.CPP

示例14: sizeof

ezSockets * ezSockets::Accept()
{
	if (!bBlocking && !CanRead())
		return NULL;

	sockaddr_in local_addr;
	int length = sizeof(local_addr);

	int localsock = ::accept(sock,(struct sockaddr*) &local_addr,
						   (socklen_t*) &length);

	if ( localsock == SOCKET_ERROR )
		return NULL;

	ezSockets * sNew = new ezSockets;

	#if !( defined (_WIN32) || defined( _XBOX ) )
		char buf[INET_ADDRSTRLEN];
		inet_ntop(AF_INET, &local_addr.sin_addr, buf, INET_ADDRSTRLEN);
		sNew->address = buf;
	#else
		sNew->address = inet_ntoa(local_addr.sin_addr);
	#endif

	lastCode = localsock;


	sNew->bBlocking = bBlocking;
	sNew->lastCode = 0;
	sNew->mode = mode;
	sNew->pDataInHead = NULL;
	sNew->sock = localsock;
	sNew->state = skCONNECTED;
	return sNew;
}
開發者ID:Hazzytje,項目名稱:Kyubu,代碼行數:35,代碼來源:ezSockets.cpp

示例15: Accept

bool ezSockets::Accept(ezSockets& socket)
{
	if (!bBlocking && !CanRead())
		return false;

	int length = sizeof(socket);

	socket.sock = ::accept(sock,(struct sockaddr*) &socket.addr,
						   (socklen_t*) &length);

	#if !( defined (_WIN32) || defined( _XBOX ) )
		char buf[INET_ADDRSTRLEN];
		inet_ntop(AF_INET, &socket.addr.sin_addr, buf, INET_ADDRSTRLEN);
		address = buf;
	#else
		address = inet_ntoa(socket.addr.sin_addr);
	#endif

	lastCode = socket.sock;

	if ( socket.sock == SOCKET_ERROR )
		return false;

	socket.state = skCONNECTED;
	return true;
}
開發者ID:Hazzytje,項目名稱:Kyubu,代碼行數:26,代碼來源:ezSockets.cpp


注:本文中的CanRead函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。