29 const char cmd_pv_help[] =
"Show / Modify process variables";
31 static void listPVs() {
34 for (subsys = 0; subsys < SUBSYS_COUNT; ++subsys)
36 const subsys_info_t * sinfo = &subsys_info[subsys];
37 printf(
"Subsystem %s (#%d)\n", sinfo->name, subsys);
39 for (vars = 0; vars < sinfo->count; ++vars) {
40 int32_t
id = sinfo->ids[vars];
41 if (
id == 0)
continue;
42 const char * name = sinfo->names[vars];
43 printf(
" - %-20s (%08x) - ", name,
id);
45 printf(
"array of %d elements of ",
vidArrSize(
id));
53 static void printBuffer(
void * buf,
int id) {
55 case VID_SCLTYP_U8: printf(
"%u (%03x)", *((uint8_t *)buf), *((uint8_t *)buf));
break;
56 case VID_SCLTYP_U16: printf(
"%u (%04x)", *((uint16_t *)buf), *((uint16_t *)buf));
break;
57 case VID_SCLTYP_U32: printf(
"%lu (%08x)", *((uint32_t *)buf), *((uint32_t *)buf));
break;
58 case VID_SCLTYP_U64: printf(
"%llu (%016x)", *((uint64_t *)buf), *((uint64_t *)buf));
break;
64 case VID_SCLTYP_BOOL: printf((*((uint8_t*)buf)) ?
"True" :
"False");
break;
66 printf(
"Not supported");
70 static void showPVByID(
const char * name,
int id) {
71 printf(
"%-20s: ", name);
75 if (!
xsRead(
id, buf,
sizeof(buf))) {
84 printf(
"Array of %d elements:", elements);
86 for (i = 0; i < elements; ++i) {
87 printf(
"\n * %3d: ", i);
100 static void showPV(
const char * search) {
102 for (subsys = 0; subsys < SUBSYS_COUNT; ++subsys)
104 const subsys_info_t * sinfo = &subsys_info[subsys];
105 for (vars = 0; vars < sinfo->count; ++vars) {
106 int32_t
id = sinfo->ids[vars];
108 if (
id == 0)
continue;
109 const char * name = sinfo->names[vars];
111 if (strncmp(name, search, strlen(search)) == 0) {
112 showPVByID(name,
id);
123 bool cmd_pv_exec(
int argc,
const char *args[])
128 puts(
"Only summery information available, not build with meta-data (PV_META / DEBUG)");
132 puts(
"use pv [name] to show variable contents");
136 }
else if (argc == 1) {
147 const char cmd_state_help[] =
"Control/view high-level state machine";
149 bool cmd_state_exec(
int argc,
const char *args[])
156 for (i = 0; i < CLB_SUB_CNT; ++i)
160 printf(
" -> %s (%x)\n", errMsg, errCode);
165 puts(
"Invoke 'state help' for more information");
166 }
else if (argc == 1 && strcmp(args[0],
"help") == 0)
168 puts(
"state [<event>|help|clear]");
169 puts(
"Without argument, lists all subsystems with there current states");
170 puts(
"With argument:");
171 puts(
" help Show this help");
172 puts(
" clear Clear error state on all state machines");
173 puts(
"Else, emit event, one of:");
177 }
else if (argc == 1 && strcmp(args[0],
"clear") == 0)
180 }
else if (argc == 1) {
187 printf(
"Unknown event %s\n", args[0]);
196 const char cmd_stmach_help[] =
"Configure hardware state machine";
198 bool cmd_stmach_exec(
int argc,
const char *args[])
201 if (argc == 0 || (argc == 1 && strcmp(args[0],
"help") == 0)) {
202 puts(
"stmach [option [arg]]");
203 puts(
"where option ay be:");
204 puts(
" tslice <us> Timeslice duration in us.");
205 puts(
" psize <bytes> Packet size in bytes");
206 puts(
" firq <ch> Generate fake tdc fifo-full IRQ on channel 0..31");
207 puts(
" run <runnr> Set the run-number.");
208 puts(
"\nNote that these values will be set when going to the configured phase\n");
209 printf(
"Current configuration: tslice=%d us, psize=%d bytes\n",
210 sys.time_slice_dur, sys.stmach_pktsize);
211 }
else if (argc == 2)
213 int v = atoi(args[1]);
214 if (strcmp(args[0],
"tslice") == 0) {
215 sys.time_slice_dur = v;
216 }
else if (strcmp(args[0],
"psize") == 0) {
217 sys.stmach_pktsize = v;
218 }
else if (strcmp(args[0],
"firq") == 0) {
220 }
else if (strcmp(args[0],
"run") == 0) {
221 sys.run_number = atoi(args[1]);
#define VID_SCLTYP_I8
Signed 8 bit integer.
const char *const clbEventNames[9]
All state change event names.
ClbEvent
All state change events.
#define VID_SCLTYP_U16
Unsigned 16 bit integer.
ClbState clbState(int idx)
Returns the current clbSubState for the specified subsystem.
#define VID_SCLTYP_F32
32 bit IEEE floating point
bool clbEvent(int idx, ClbEvent event)
Request a subsystem to go to a certain state.
Special library for primitive IEEE 754 floating point handling without dragging all float support alo...
#define VID_SCLTYP_I64
Signed 64 bit integer.
void clbClearErrorState(int idx)
Clears the error state of the specific subsystem.
bool clbStateError(int idx, int *code, const char **message)
Retrieves the error of a subsystem (if any).
#define VID_SCLTYP_I16
Signed 16 bit integer.
#define VID_SCLTYP_BOOL
Boolean, encoded as a byte (0 - false, 1 - true)
const char *const clbSubsystemNames[5]
Contains a list of all the subsystems.
#define VID_SCLTYP_U64
Unsigned 64 bit integer.
void stmachFakeFull(uint32_t mask)
Debugging stuff, don't touch!
static int vidArrSize(int varID)
Returns the number of elements in the array of this variable.
static int vidType(int varID)
Returns the type of the variable.
void errPrint(bool clear)
Prints the last error.
uint32_t f32_t
32 bit representation for float.
const char *const clbStateNames[6]
Contains list of the state names.
#define CLB_SUB_ALL
Indicates all subsystems. Can be used in clbStateGoto.
The CLB stare module tracks is responsible for state management of the various sub-systems on the CLB...
#define VID_SCLTYP_U8
Unsigned 8 bit integer.
bool xsRead(int varID, void *target, int size)
Reads variable into target buffer from variable structure.
#define VID_SCLTYP_U32
Unsigned 32 bit integer.
const char *const vidTypeNames[16]
Types names.
#define VID_SCLTYP_I32
Signed 32 bit integer.
Access provides 'introspective' access to process variables.
static int vidSclSize(int varID)
Returns the size of the scalar part of variable in bytes.
Defines the variable ID format.