pflib v3.9.0-rc3-11-g2537d8f
Pretty Fine HGCROC Interaction Library
Loading...
Searching...
No Matches
main.cxx File Reference

File defining the pftool entrypoint. More...

#include <filesystem>
#include <fstream>
#include "pflib/Compile.h"
#include "pflib/Parameters.h"
#include "pflib/version/Version.h"
#include "pftool.h"
Include dependency graph for main.cxx:

Functions

pflib::logging::logger get_by_file (const std::string &filepath)
 get a logger using the file name as the channel name
 
 ENABLE_LOGGING ()
 
std::string exec (const char *cmd)
 Execute a command and capture its output into a string.
 
bool is_fw_active (const std::string &name)
 Check if the firmware supporting the HGCROC is active.
 
std::string fw_version ()
 Get the current firmware version.
 
static void status (Target *pft)
 Main status of menu.
 
int main (int argc, char *argv[])
 This is the main executable for the pftool.
 

Variables

const std::string FW_SHORTNAME_FIBERLESS = "hcal-zcu102"
 firmware name as it appears as a directory on disk
 
const std::string FW_SHORTNAME_UIO_ZCU = "dualtarget-zcu102"
 

Detailed Description

File defining the pftool entrypoint.

The commands are written into files corresponding to the menu's name.

Function Documentation

◆ exec()

std::string exec ( const char * cmd)

Execute a command and capture its output into a string.

The maximum output is 128 characters.

Parameters
[in]cmdcommand C-string to run
Returns
up to 128 characters of output by cmd

shamelessly taken from https://stackoverflow.com/a/478960

◆ fw_version()

std::string fw_version ( )

Get the current firmware version.

This takes a moment because we simply retrieve the version using an rpm query and the exec function.

Returns
string holding the full firmware version

◆ get_by_file()

pflib::logging::logger get_by_file ( const std::string & filepath)

get a logger using the file name as the channel name

the filename's extension is removed and the file path that is shared with the directory of this file is replaced by 'pftool'.

◆ is_fw_active()

bool is_fw_active ( const std::string & name)

Check if the firmware supporting the HGCROC is active.

Returns
true if correct firmware is active

◆ main()

int main ( int argc,
char * argv[] )

This is the main executable for the pftool.

If '-h' or '–help' is the only parameter provided, the usage information is printed and we exit; otherwise, we continue.

The RC files are read from ${PFTOOLRC}, pftoolrc, and ~/.pftoolrc with priority in that order. Then the command line parameters are parsed; if not hostname(s) is(are) provided on the command line, then the 'default_hostname' RC file option is necessary.

Initialization scripts (provided with -s) are parsed such that white space and lines which start with # are ignored. The keystrokes in those "sripts" are run upon launching of the menu and then the user gets control of the tool back after the script is done.

Parse Command Line Parameters

Load the configuration YAML

Run tool

◆ status()

static void status ( Target * pft)
static

Main status of menu.

Prints the firmware and software versions

Parameters
[in]pftpointer to active target