当前位置: 首页>>代码示例>>C++>>正文


C++ APDU类代码示例

本文整理汇总了C++中APDU的典型用法代码示例。如果您正苦于以下问题:C++ APDU类的具体用法?C++ APDU怎么用?C++ APDU使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了APDU类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: ConfigureRequest

void ConfigureUnsol::ConfigureRequest(APDU& arAPDU)
{
	arAPDU.Set(mIsEnable ? FC_ENABLE_UNSOLICITED : FC_DISABLE_UNSOLICITED);
	if(mClassMask & PC_CLASS_1) arAPDU.DoPlaceholderWrite(Group60Var2::Inst());
	if(mClassMask & PC_CLASS_2) arAPDU.DoPlaceholderWrite(Group60Var3::Inst());
	if(mClassMask & PC_CLASS_3) arAPDU.DoPlaceholderWrite(Group60Var4::Inst());
}
开发者ID:diverger,项目名称:dnp3,代码行数:7,代码来源:StartupTasks.cpp

示例2: if

OneByteFrame::OneByteFrame(const APDU& apdu)
{
	m_frame_len = 1;
	m_frame_mem = new UCHAR[1];
	
	if ( apdu.IsAck() )
	{
		m_frame_mem[0] = 0xCC;
		m_type = ACK_FRAME;
	}
	else if ( apdu.IsNack() )
	{
		m_frame_mem[0] = 0x0C;
		m_type = NACK_FRAME;
	}
	else if ( apdu.IsBusy() )
	{
		m_frame_mem[0] = 0xC0;
		m_type = BUSY_FRAME;
	}
	else if ( apdu.IsNackbusy() )
	{
		m_frame_mem[0] = 0x00;
		m_type = NACKBUSY_FRAME;
	}
	else
	{
		// ...
		abort();
	}
}
开发者ID:lubing521,项目名称:edifice,代码行数:31,代码来源:Frame.cpp

示例3: OnFinalResponse

void Master::OnFinalResponse(const APDU& arAPDU)
{
	this->UpdateState(MS_COMMS_UP);
	mLastIIN = arAPDU.GetIIN();
	this->ProcessIIN(arAPDU.GetIIN());
	mpState->OnFinalResponse(this, arAPDU);	
}
开发者ID:diverger,项目名称:dnp3,代码行数:7,代码来源:Master.cpp

示例4: pth_event

Array < eibaddr_t >
  Layer7_Broadcast::A_IndividualAddress_Read (unsigned timeout)
{
  Array < eibaddr_t > addrs;
  A_IndividualAddress_Read_PDU r;
  APDU *a;
  l4->Send (r.ToPacket ());
  pth_event_t t = pth_event (PTH_EVENT_RTIME, pth_time (timeout, 0));
  while (pth_event_status (t) != PTH_STATUS_OCCURRED)
    {
      BroadcastComm *c = l4->Get (t);
      if (c)
	{
	  a = APDU::fromPacket (c->data);
	  if (a->isResponse (&r))
	    {
	      addrs.resize (addrs () + 1);
	      addrs[addrs () - 1] = c->src;
	    }
	  delete a;
	  delete c;
	}
    }
  pth_event_free (t, PTH_FREE_THIS);
  return addrs;
}
开发者ID:AdrienCourtois,项目名称:Domoleaf,代码行数:26,代码来源:layer7.cpp

示例5: SendUp

void AppLayerTest::SendUp(FunctionCodes aCode, bool aFIR, bool aFIN, bool aCON, bool aUNS, int aSEQ)
{
	APDU f;
	f.SetFunction(aCode);
	f.SetControl(aFIR, aFIN, aCON, aUNS, aSEQ);
	lower.SendUp(f.GetBuffer(), f.Size());
}
开发者ID:cmavr8,项目名称:dnp3,代码行数:7,代码来源:AppLayerTest.cpp

示例6: Response

int Frame::Response(Frame*& resp)const  // 旧代码.以后要废弃!!!!
{
	int retcode = 0;
	APDU *apdu = NULL, *apdu2 = NULL;
	std::vector<APDU*> apdus;

	apdu = APDU::BuildAPDUFromFrame(*this);
	if ( NULL == apdu )
	{
		retcode = -11;
		goto _out;
	}

	retcode = apdu->Response(apdu2, apdus);
	if ( 0 != retcode || NULL == apdu2 )
	{
		retcode = -12;
		goto _out;
	}

	resp = Frame::BuildFrameFromAPDU(*apdu2);

_out:
	delete apdu2;
	delete apdu;
	for ( int i = 0; i < apdus.size(); i++ )
	{
		delete apdus[i];
	}

	return retcode;
}
开发者ID:lubing521,项目名称:edifice,代码行数:32,代码来源:Frame.cpp

示例7: LOG_BLOCK

void MockAppLayer::SendUnsolicited(APDU& arAPDU)
{
	LOG_BLOCK(LEV_COMM, "=> " << toHex(arAPDU.GetBuffer(), arAPDU.Size(), true));
	LOG_BLOCK(LEV_INTERPRET, "=> " << arAPDU.ToString());
	mFragments.push_back(arAPDU);
	this->DoSendUnsol();
}
开发者ID:diverger,项目名称:dnp3,代码行数:7,代码来源:MockAppLayer.cpp

示例8: pth_event

APDU *
Layer7_Individual::Request_Response (APDU * r)
{
  APDU *a;
  CArray *c;
  l4->Send (r->ToPacket ());
  pth_event_t t = pth_event (PTH_EVENT_RTIME, pth_time (6, 100));
  while (pth_event_status (t) != PTH_STATUS_OCCURRED)
    {
      c = l4->Get (t);
      if (c)
	{
	  if (c->len () == 0)
	    {
	      delete c;
	      pth_event_free (t, PTH_FREE_THIS);
	      return 0;
	    }
	  a = APDU::fromPacket (*c, this->t);
	  delete c;
	  if (a->isResponse (r))
	    {
	      pth_event_free (t, PTH_FREE_THIS);
	      return a;
	    }
	  delete a;
	  pth_event_free (t, PTH_FREE_THIS);
	  return 0;
	}
    }
  pth_event_free (t, PTH_FREE_THIS);
  return 0;
}
开发者ID:1stsetup,项目名称:knxd,代码行数:33,代码来源:layer7.cpp

示例9: SendUnsolicited

void Slave::SendUnsolicited(APDU& arAPDU)
{
	mRspIIN.BitwiseOR(mIIN);
	arAPDU.SetIIN(mRspIIN);
	mpAppLayer->SendUnsolicited(arAPDU);
	mUnsolExpectCON = (arAPDU.GetControl()).CON;
}
开发者ID:sentient-energy,项目名称:emsw-opendnp3-mirror,代码行数:7,代码来源:Slave.cpp

示例10: LOG_BLOCK

void VtoTransmitTask::ConfigureRequest(APDU& arAPDU)
{
	/*
	 *  Masters never request confirmed data. The response from the
	 *  slave is all that's required for reliable delivery.
	 */
	arAPDU.Set(mUseNonStandardCode ? FC_PROPRIETARY_VTO_TRANSFER : FC_WRITE);

	const size_t MAX_VTO_EVENTS = 7;
	/* Get all of the data objects in the buffer. */
	size_t numObjects = this->mBuffer.Select(PC_ALL_EVENTS, MAX_VTO_EVENTS);

	LOG_BLOCK(LEV_INTERPRET, "VtoTransmitTask Sending: " << numObjects << " of " << this->mBuffer.Size());

	/* If there are no objects to write, skip the remainder. */
	if (numObjects == 0) {
		return;
	}

	/*
	 * Loop through the selected data and add corresponding objects to
	 * the arAPDU instance.
	 */
	VtoDataEventIter vto = this->mBuffer.Begin();

	for (size_t i = 0; i < numObjects; ++i) {
		/* Insert a new object into the APDU message. */
		IndexedWriteIterator itr = arAPDU.WriteIndexed(
		                               Group112Var0::Inst(),
		                               vto->mValue.GetSize(),
		                               vto->mIndex
		                           );

		/*
		 * Check to see if the APDU fragment has enough room for the
		 * data segment.  If the fragment is full, return out of this
		 * function and let the fragment send.
		 */
		if (itr.IsEnd()) {
			return;
		}

		/* Set the object index */
		itr.SetIndex(vto->mIndex);

		/* Write the data to the APDU message */
		Group112Var0::Inst()->Write(
		    *itr,
		    vto->mValue.GetSize(),
		    vto->mValue.mpData
		);

		/* Mark the data segment as being written */
		vto->mWritten = true;

		/* Move to the next data segment in the buffer */
		++vto;
	}
}
开发者ID:SandC,项目名称:dnp3,代码行数:59,代码来源:VtoTransmitTask.cpp

示例11: Read

APDU MockAppLayer::Read()
{
	if(mFragments.size() == 0) throw InvalidStateException(LOCATION, "no more fragments");
	APDU frag = mFragments.front();
	frag.Interpret();
	mFragments.pop_front();
	return frag;
}
开发者ID:diverger,项目名称:dnp3,代码行数:8,代码来源:MockAppLayer.cpp

示例12: ArgumentException

void AppLayer::SendResponse(APDU& arAPDU)
{
	this->Validate(arAPDU.GetControl(), false, false, true, false);
		
	if(arAPDU.GetFunction() != FC_RESPONSE)
		throw ArgumentException(LOCATION, "Non-response function code");	

	mSolicited.Send(arAPDU, this->GetRetries(FC_RESPONSE));	
}
开发者ID:diverger,项目名称:dnp3,代码行数:9,代码来源:AppLayer.cpp

示例13: Send

void ACS_Idle::Send(AppLayerChannel* c, APDU& arAPDU, size_t aNumRetry)
{
	AppControlField acf = arAPDU.GetControl();
	FunctionCodes func = arAPDU.GetFunction();
	acf.SEQ = (acf.FIR && func == FC_RESPONSE) ? c->Sequence() : c->IncrSequence();
	arAPDU.SetControl(acf);
	c->ChangeState(NextState(c, arAPDU.GetFunction(), acf.CON));
	c->SetRetry(aNumRetry);
	c->QueueSend(arAPDU);
}
开发者ID:AlanMarshall,项目名称:dnp3,代码行数:10,代码来源:AppChannelStates.cpp

示例14: main

int main() {

	SCard card;
	
	try {

		card.setContext(SCARD_SCOPE_SYSTEM);

		card.connect();

		cout << card.getReader() << endl;

		
		char input[256];

		for (;;) {
		
			cout << "apdu> ";
		
			cin.getline(input, sizeof(input));

			String in(input);

			in = in.trim().toLower();

			if (in == "quit") {
				
				cout << "Bye" << endl;
				break;
			}

			APDU cmd(in,APDU::Separator::SPACE);
			
			APDU resp;

			try {

				card.transmit(cmd,resp);
				cout << resp.toString() << endl;	
				
			} catch (SCardException& e) {

				cerr << e.what() << endl;
			}

			
		}
		
	} catch (SCardException& e) {

		cerr << e.what() << endl;
	}
		
	return 0;
}
开发者ID:atmarangga,项目名称:scard,代码行数:55,代码来源:main.cpp

示例15: InvalidStateException

void ClassPoll::ConfigureRequest(APDU& arAPDU)
{
	if (mClassMask == PC_INVALID) {
		throw InvalidStateException(LOCATION, "Class mask has not been set");
	}

	arAPDU.Set(FC_READ);
	if (mClassMask & PC_CLASS_0) arAPDU.DoPlaceholderWrite(Group60Var1::Inst());
	if (mClassMask & PC_CLASS_1) arAPDU.DoPlaceholderWrite(Group60Var2::Inst());
	if (mClassMask & PC_CLASS_2) arAPDU.DoPlaceholderWrite(Group60Var3::Inst());
	if (mClassMask & PC_CLASS_3) arAPDU.DoPlaceholderWrite(Group60Var4::Inst());
}
开发者ID:sentient-energy,项目名称:emsw-opendnp3-mirror,代码行数:12,代码来源:DataPoll.cpp


注:本文中的APDU类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。