Files
Jungfraujoch/receiver/jfjoch_pcie_set_network.cpp

27 lines
797 B
C++

// Copyright (2019-2022) Paul Scherrer Institute
// SPDX-License-Identifier: GPL-3.0-or-later
#include "../common/Logger.h"
#include "../common/JFJochException.h"
#include "PCIExpressDevice.h"
#include "../common/NetworkAddressConvert.h"
int main(int argc, char **argv) {
Logger logger("jfjoch_pcie_set_network");
if (argc != 3) {
logger.Error("Usage: ./jfjoch_pcie_set_network <device name> <IPv4 address>");
exit(EXIT_FAILURE);
}
logger.Info("Device {} IPv4 address {}", argv[1], argv[2]);
try {
PCIExpressDevice test(argv[1], 0);
test.SetDefaultMAC();
test.SetIPv4Address(IPv4AddressFromStr(std::string(argv[2])));
logger.Info("Done");
} catch (const JFJochException &e) {
logger.ErrorException(e);
}
}