Пример #1
0
int
main()
{
	xpcc::log::info << "########## XPCC TIPC COMPONENT Test TRANSMIT ##########" << xpcc::flush;

	// the hardware, that transfers the messages
	xpcc::TipcConnector tipc;

	// set the filters of the hardware
	tipc.addReceiverId(0x11);

	// set the 'list' of connections to the postman
	xpcc::DynamicPostman postman;

	// connect the 'hardware' to the postman
	xpcc::Communication com(&tipc, &postman);
	com.setCurrentComponent(0x11);

	xpcc::Header actionHeader( xpcc::Header::REQUEST, false, 0x10, 0x20, 0x01 );	// ACTION
	xpcc::Header eventHeader( xpcc::Header::REQUEST, false, 0x00, 0x20, 0x01 );	// ACTION

	int data(0);

	xpcc::IOStream stream(xpcc::log::device );

	while(1) {
		data++;

		com.update();

		xpcc::SmartPointer payload(&data);
		XPCC_LOG_INFO << XPCC_FILE_INFO << "data   =" << data << xpcc::endl;
		XPCC_LOG_INFO << XPCC_FILE_INFO << "payload=" << payload << xpcc::endl;


		com.callAction(0x10, 0x20, data);
		com.publishEvent(0x01, data);


		sleep(1);
	}


	xpcc::log::info << "########## XPCC TIPC RAW Test END ##########" << xpcc::flush;
}
Пример #2
0
int
main()
{
	XPCC_LOG_INFO << "########## XPCC TIPC RAW Test TRANSMIT ##########" << xpcc::endl;
	
	xpcc::TipcConnector tipc;
	tipc.addReceiverId(0x20);
	
	xpcc::Header actionHeader(xpcc::Header::REQUEST, false, 0x10, 0x20, 0x01);	// ACTION
	xpcc::Header eventHeader(xpcc::Header::REQUEST, false, 0x00, 0x20, 0x01);	// ACTION
	
	int data = 0;
	
	while(1)
	{
		data++;
		xpcc::SmartPointer payload(&data);
		
		XPCC_LOG_INFO << data << xpcc::endl;
		
		tipc.sendPacket(actionHeader, payload);
		tipc.sendPacket(eventHeader, payload);
		
		if (tipc.isPacketAvailable()) {
			const xpcc::Header& header =  tipc.getPacketHeader();
			
			XPCC_LOG_INFO
					<< XPCC_FILE_INFO << "has"
					<< ((header.destination != 0) ? " ACTION" : " EVENT")
					<< ((header.isAcknowledge) ? " ACK" : "")
					<< " from:" << (int)header.source
					<< xpcc::endl;

			tipc.dropPacket();
		}

		sleep(1);
	}
	
	XPCC_LOG_INFO << "########## XPCC TIPC RAW Test END ##########" << xpcc::endl;
}