DUNE-DAQ
DUNE Trigger and Data Acquisition software
Loading...
Searching...
No Matches
amc_butler Namespace Reference

Classes

class  Commands
 

Functions

 ping (host)
 
 main (crate_ip, amcs, cmd)
 

Detailed Description

Created on: 05/06/2025 11:16

Author: Shyam Bhuller, Alessandro Thea

Description: Check the status of an AMC or multiple AMCs to ensure they can be reached.

Function Documentation

◆ main()

amc_butler.main ( crate_ip,
amcs,
cmd )

Definition at line 57 of file amc_butler.py.

57def main(crate_ip, amcs, cmd):
58
59 # get list of amcs from the command arguments
60 try:
61 sh.ping(["-c", '1', crate_ip])
62 print(f"[green]uTCA crate {crate_ip} is active[/green]")
63 except sh.ErrorReturnCode as e:
64 print(f"[red]Could not ping uTCA Crate at IP: {crate_ip}[/red]")
65 exit(1)
66
67 crate_subnet = crate_ip.rsplit(".", 1)[0]
68
69 amc_ips = { i: crate_subnet + f".{i + 1}" for i in amcs}
70
71 if cmd=='arping':
72 # Arping the crate, just for completeness
73 try:
74 r = sh.arping(["-c", '1', crate_ip])
75 print(f"- [green]uTCA crate {crate_ip} responded to arping[/green]")
76 print(r)
77 except sh.ErrorReturnCode as e:
78 print(f"- [red]Could not arping uTCA Crate at IP: {crate_ip}[/red]")
79
80 # Arping the AMCs
81 for amc, amc_ip in amc_ips.items():
82 try:
83 r = sh.arping(["-c", '1', amc_ip])
84 print(f"- [green]AMC {amc} ({amc_ip}) responded to arping[/green]")
85 print(r)
86
87 except sh.ErrorReturnCode as e:
88 print(f"- [red]Could not arping AMC {amc} at IP: {amc_ip}[/red]")
89
90 # Arping the NIC
91 nic_ip = crate_subnet+'.129'
92 try:
93 r = sh.arping(["-c", '1', nic_ip])
94 print(f"- [green]NIC data sink {nic_ip} responded to arping[/green]")
95 print(r)
96 except sh.ErrorReturnCode as e:
97 print(f"- [red]Could not arping NIC data at IP: {nic_ip}[/red]")
98
99 else:
100 if cmd:
101 controllers = { amc_ip:tdemodules.AMCController(amc_ip, 54321 + (i + 1)) for i,amc_ip in amc_ips.items() }
102 print(controllers)
103 cmds = Commands(controllers)
104 getattr(cmds, cmd)()
105 else:
106 print("no command was provided.")
107
108 return
109
int main(int argc, char **argv)

◆ ping()

amc_butler.ping ( host)

Definition at line 18 of file amc_butler.py.

18def ping(host):
19 return subprocess.call(['ping', "-c", '1', host]) == 0
20