DUNE-DAQ
DUNE Trigger and Data Acquisition software
Toggle main menu visibility
Loading...
Searching...
No Matches
dunedaq
sourcecode
timing
python
afc
ipmi.py
Go to the documentation of this file.
1
from
__future__
import
print_function
2
3
import
pyipmi.interfaces
4
import
click
5
import
struct
6
7
# ------------------------------------------------------------------------------
8
def
establishIPMIConnectionToAMC
(mch_ip_adr,amc_slot):
9
amc_ipmb_addresses= [0x72, 0x74, 0x76, 0x78, 0x7a, 0x7c, 0x7e, 0x80, 0x82, 0x84, 0x86, 0x88]
10
amc_ipmb_adr = amc_ipmb_addresses[amc_slot-1]
11
12
interface = pyipmi.interfaces.create_interface(
'ipmitool'
, interface_type=
'lan'
)
13
connection = pyipmi.create_connection(interface)
14
15
connection.target = pyipmi.Target(amc_ipmb_adr)
16
connection.target.set_routing([(0x81,0x20,0),(0x20,0x82,7),(0x20,amc_ipmb_adr,
None
)])
17
connection.session.set_session_type_rmcp(mch_ip_adr, port=623)
18
connection.session.set_auth_type_user(
''
,
''
)
19
connection.session.establish()
20
return
connection
21
# ------------------------------------------------------------------------------
22
23
24
# ------------------------------------------------------------------------------
25
def
readRegOverIPMI
(ipmi_connection, reg):
26
raw_read_cmd = b
'\x00\x02\x4B\x01\x01'
27
cmd = raw_read_cmd+struct.pack(
"B"
, reg)
28
29
max_attempts=10
30
read_attempts=0
31
32
while
True
:
33
if
read_attempts > max_attempts:
34
raise
click.ClickException(
"Failed to read value of reg {} after {} attempts"
.format(hex(reg), max_attempts))
35
read_cmd_result = []
36
result = ipmi_connection.raw_command(0x00, 0x30, cmd)
37
for
char
in
result:
38
read_cmd_result.append(char)
39
if
read_cmd_result[1] == 1
and
read_cmd_result[2] == 1:
40
return
read_cmd_result[3]
41
else
:
42
read_attempts += 1
43
# ------------------------------------------------------------------------------
44
45
46
# ------------------------------------------------------------------------------
47
def
writeRegOverIPMI
(ipmi_connection, reg, data):
48
raw_write_cmd = b
'\x00\x02\x4B\x02\x01'
49
cmd = raw_write_cmd+struct.pack(
"B"
, reg)+struct.pack(
"B"
, data)
50
51
max_attempts=10
52
write_attempts=0
53
54
while
True
:
55
if
write_attempts > max_attempts:
56
raise
click.ClickException(
"Failed to write value of reg {} after {} attempts"
.format(hex(reg), max_attempts))
57
write_cmd_result = []
58
result = ipmi_connection.raw_command(0x00, 0x30, cmd)
59
for
char
in
result:
60
write_cmd_result.append(char)
61
if
write_cmd_result[1] == 2
and
write_cmd_result[2] == 1:
62
return
63
else
:
64
write_attempts += 1
65
# ------------------------------------------------------------------------------
afc.ipmi.writeRegOverIPMI
writeRegOverIPMI(ipmi_connection, reg, data)
Definition
ipmi.py:47
afc.ipmi.establishIPMIConnectionToAMC
establishIPMIConnectionToAMC(mch_ip_adr, amc_slot)
Definition
ipmi.py:8
afc.ipmi.readRegOverIPMI
readRegOverIPMI(ipmi_connection, reg)
Definition
ipmi.py:25
Generated on
for DUNE-DAQ by
1.17.0