
IPBusMock
Introduction
IPBusMock is a back-end that lets you communicate with hardware devices via the IPBus protocol or emulate a connexion:
Mock your connection API, not your connected hardware:
- Implement 1 back-end, mock any number of hardware using it.
- Always runs in 1 process on your laptop.
- Use a mock back-end and a real back-end at the same time:
- Create mock files automatically with record mode:
- Expand your mock files with record mode.
Prerequired
- IpBus software and its requirements
- PhoenixCMake
- PhoenixDataStream
- PhoenixSocket
https://ipbus.web.cern.ch/doc/user/html/software/installation.html
Quick Start
mkdir build
cd build
cmake .. -DIPBUS_PATH=YOUR_IPBUS_PATH
make
Installation
Usage
- First, start the UDP server, on a terminal to emulating the IPbus protocol on localhost:50001:
/opt/cactus/bin/uhal/tests/DummyHardwareUdp.exe -p 50001 -v 2
- On another terminal run the test app
cd build/TESTS/TEST_MOCK_READ_WRITE$
./test_interface NO_MOCK
./test_interface MOCK_RECORD
- Test the MOCK mode.
3.1. Stop the application that emalutes the IPbus protocol on localhost:50001
3.2. Start the test in MOCK mode
./test_interface MOCK
Code example
This package implements a "dummy equivalent" of uhal::HwInterface and uhal::Node named PIpBusInterface::HwInterface and PIpBusInterface:Node Note: For the time being, the read, write, readBlock and WriteBlock method on Node are implemented.
After having executing read and/or write commands in MOCK_RECORD mode, a new file will be created and filled in a directory named with the connectionId argument of the hwInterface constructor + "mock_dir" and the file name localhost_0_.pmockbackend
#include "PGenericSocketManager.h"
#include "HwInterface.h"
using namespace PIpBusInterface;
PSocketMode::PSocketMode _mock_mode = PSocketMode::NO_MOCK; // Or MOCK_RECORD or MOCK
std::string connectionId = "dummy.udp.0";
HwInterface hwInterface("file://./connexion.xml", connectionId, _mock_mode);
std::string calibration_nodeId = "calibration";
uint32_t calibration_value = 0xabcdef13;
hwInterface.getNode(calibration_nodeId).write(calibration_value);
std::string latournett_nodeId = "latournett";
uint32_t latournett_value = 0x31fedcba;
hwInterface.getNode(latournett_nodeId).write(latournett_value);
uint32_t read_value = hwInterface.getNode(calibration_nodeId).read();
read_value = hwInterface.getNode(latournett_nodeId).read();
std::string mem_nodeId = "MEM";
std::vector<uint32_t> mem_values = {0xabcdef13, 0xfedcba98, 0x00000001};
hwInterface.getNode(mem_nodeId).writeBlock(mem_values);
std::vector<uint32_t> read_values;
read_values = hwInterface.getNode(mem_nodeId).readBlock(mem_values.size());