当前位置: 首页>>代码示例>>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;未经允许,请勿转载。