Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
P
Production Test Suite - base
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
1
Merge Requests
1
Wiki
Wiki
image/svg+xml
Discourse
Discourse
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Projects
Production Test Suite - base
Commits
8c6bc063
Commit
8c6bc063
authored
Jul 18, 2022
by
Pieter Van Trappen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
converted to python3
parent
ddf02977
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
37 additions
and
37 deletions
+37
-37
bin2dec.py
common/fmceeprom/bin2dec.py
+7
-7
fmc_eeprom.py
common/fmceeprom/fmc_eeprom.py
+15
-15
fmc_eeprom_example.py
common/fmceeprom/fmc_eeprom_example.py
+15
-15
No files found.
common/fmceeprom/bin2dec.py
View file @
8c6bc063
#! /usr/bin/env python
2
#! /usr/bin/env python
3
# coding: utf8
# coding: utf8
# Copyright CERN, 2011
# Copyright CERN, 2011
...
@@ -14,7 +14,7 @@ import os
...
@@ -14,7 +14,7 @@ import os
def
dump_file_to_eeprom
(
filename
):
def
dump_file_to_eeprom
(
filename
):
eeprom_content
=
[]
eeprom_content
=
[]
eeprom_addr
=
[]
eeprom_addr
=
[]
print
filename
print
(
filename
)
f
=
open
(
filename
,
"r+"
)
f
=
open
(
filename
,
"r+"
)
for
line
in
f
:
for
line
in
f
:
addr
,
data
=
line
.
split
()
addr
,
data
=
line
.
split
()
...
@@ -34,14 +34,14 @@ def main (default_directory = '.'):
...
@@ -34,14 +34,14 @@ def main (default_directory = '.'):
for
line
in
f_in
:
for
line
in
f_in
:
addr
,
data
=
line
.
split
()
addr
,
data
=
line
.
split
()
print
"
%
d 0x
%
X"
%
(
int
(
addr
,
2
),
int
(
data
,
2
))
print
(
"
%
d 0x
%
X"
%
(
int
(
addr
,
2
),
int
(
data
,
2
)
))
eeprom_content
.
append
(
int
(
data
,
2
))
eeprom_content
.
append
(
int
(
data
,
2
))
eeprom_addr
.
append
(
int
(
addr
,
2
))
eeprom_addr
.
append
(
int
(
addr
,
2
))
print
"
\n
CONTENT"
print
(
"
\n
CONTENT"
)
print
eeprom_content
print
(
eeprom_content
)
print
"
\n
ADDR"
print
(
"
\n
ADDR"
)
print
eeprom_addr
print
(
eeprom_addr
)
if
__name__
==
'__main__'
:
if
__name__
==
'__main__'
:
main
()
main
()
common/fmceeprom/fmc_eeprom.py
View file @
8c6bc063
#!/usr/bin/env python
2
#!/usr/bin/env python
3
from
ctypes
import
cdll
,
Structure
,
POINTER
,
cast
,
c_int
,
\
from
ctypes
import
cdll
,
Structure
,
POINTER
,
cast
,
c_int
,
\
c_char_p
,
c_void_p
,
c_ubyte
,
c_ushort
,
byref
c_char_p
,
c_void_p
,
c_ubyte
,
c_ushort
,
byref
...
@@ -79,7 +79,7 @@ class InternalUseArea:
...
@@ -79,7 +79,7 @@ class InternalUseArea:
self
.
set_data
(
data
)
self
.
set_data
(
data
)
def
set_data
(
self
,
data
):
def
set_data
(
self
,
data
):
self
.
struct
.
data
=
c_char_p
(
array
.
array
(
'B'
,
data
)
.
to
string
())
self
.
struct
.
data
=
c_char_p
(
array
.
array
(
'B'
,
data
)
.
to
bytes
())
self
.
struct
.
len
=
c_int
(
len
(
data
))
self
.
struct
.
len
=
c_int
(
len
(
data
))
class
CommonHeader
:
class
CommonHeader
:
...
@@ -121,24 +121,24 @@ class BoardInfoArea:
...
@@ -121,24 +121,24 @@ class BoardInfoArea:
self
.
struct
.
mfg_date0
=
c_ubyte
(
val
[
3
])
self
.
struct
.
mfg_date0
=
c_ubyte
(
val
[
3
])
def
set_manufacturer
(
self
,
data
):
def
set_manufacturer
(
self
,
data
):
self
.
struct
.
mfgr_data
=
c_char_p
(
data
)
self
.
struct
.
mfgr_data
=
c_char_p
(
data
.
encode
()
)
self
.
struct
.
mfgr_typelen
=
(
len
(
bytearray
(
data
))
&
0x3f
)
|
(
0x3
<<
6
)
self
.
struct
.
mfgr_typelen
=
(
len
(
bytearray
(
data
,
'utf-8'
))
&
0x3f
)
|
(
0x3
<<
6
)
def
set_product_name
(
self
,
data
):
def
set_product_name
(
self
,
data
):
self
.
struct
.
product_data
=
c_char_p
(
data
)
self
.
struct
.
product_data
=
c_char_p
(
data
.
encode
()
)
self
.
struct
.
product_typelen
=
(
len
(
bytearray
(
data
))
&
0x3f
)
|
(
0x3
<<
6
)
self
.
struct
.
product_typelen
=
(
len
(
bytearray
(
data
,
'utf-8'
))
&
0x3f
)
|
(
0x3
<<
6
)
def
set_serial_number
(
self
,
data
):
def
set_serial_number
(
self
,
data
):
self
.
struct
.
serial_data
=
c_char_p
(
data
)
self
.
struct
.
serial_data
=
c_char_p
(
data
.
encode
()
)
self
.
struct
.
serial_typelen
=
(
len
(
bytearray
(
data
))
&
0x3f
)
|
(
0x3
<<
6
)
self
.
struct
.
serial_typelen
=
(
len
(
bytearray
(
data
,
'utf-8'
))
&
0x3f
)
|
(
0x3
<<
6
)
def
set_part_number
(
self
,
data
):
def
set_part_number
(
self
,
data
):
self
.
struct
.
partnum_data
=
c_char_p
(
data
)
self
.
struct
.
partnum_data
=
c_char_p
(
data
.
encode
()
)
self
.
struct
.
partnum_typelen
=
(
len
(
bytearray
(
data
))
&
0x3f
)
|
(
0x3
<<
6
)
self
.
struct
.
partnum_typelen
=
(
len
(
bytearray
(
data
,
'utf-8'
))
&
0x3f
)
|
(
0x3
<<
6
)
def
set_fru_file_id
(
self
,
data
):
def
set_fru_file_id
(
self
,
data
):
self
.
struct
.
fru_fid_data
=
c_char_p
(
data
)
self
.
struct
.
fru_fid_data
=
c_char_p
(
data
.
encode
()
)
self
.
struct
.
fru_fid_typelen
=
(
len
(
bytearray
(
data
))
&
0x3f
)
|
(
0x3
<<
6
)
self
.
struct
.
fru_fid_typelen
=
(
len
(
bytearray
(
data
,
'utf-8'
))
&
0x3f
)
|
(
0x3
<<
6
)
class
DCLoadRecord
:
class
DCLoadRecord
:
...
@@ -308,7 +308,7 @@ class OEMRecord:
...
@@ -308,7 +308,7 @@ class OEMRecord:
def
ipmi_open_file
(
name
):
def
ipmi_open_file
(
name
):
lib
.
ipmi_file_open
(
c_char_p
(
name
))
lib
.
ipmi_file_open
(
c_char_p
(
name
.
encode
()
))
def
ipmi_close_file
():
def
ipmi_close_file
():
lib
.
ipmi_file_close
()
lib
.
ipmi_file_close
()
...
@@ -369,10 +369,10 @@ def main():
...
@@ -369,10 +369,10 @@ def main():
with
open
(
'test.out'
,
'rb'
)
as
testf
:
with
open
(
'test.out'
,
'rb'
)
as
testf
:
test
=
testf
.
read
()
test
=
testf
.
read
()
print
ipmi_get_mfg_date
(
test
)
print
(
ipmi_get_mfg_date
(
test
)
)
d
=
ipmi_get_internal_use_data
(
test
)
d
=
ipmi_get_internal_use_data
(
test
)
for
v
in
d
:
for
v
in
d
:
print
hex
(
v
)
print
(
hex
(
v
)
)
if
__name__
==
"__main__"
:
if
__name__
==
"__main__"
:
main
()
main
()
...
...
common/fmceeprom/fmc_eeprom_example.py
View file @
8c6bc063
#! /usr/bin/env python
2
#! /usr/bin/env python
3
# coding: utf8
# coding: utf8
# Copyright CERN, 2011
# Copyright CERN, 2011
...
@@ -32,7 +32,7 @@ def main (default_directory='.'):
...
@@ -32,7 +32,7 @@ def main (default_directory='.'):
#==================================================
#==================================================
# Serial number
# Serial number
serial
=
SERIAL
serial
=
SERIAL
print
"Board's serial number:
%
s
\n
"
%
serial
print
(
"Board's serial number:
%
s
\n
"
%
serial
)
#==================================================
#==================================================
# Calculate number of minutes since 0:00 1/1/96
# Calculate number of minutes since 0:00 1/1/96
...
@@ -41,17 +41,17 @@ def main (default_directory='.'):
...
@@ -41,17 +41,17 @@ def main (default_directory='.'):
diff_date
=
now_date
-
ref_date
diff_date
=
now_date
-
ref_date
total_seconds
=
diff_date
.
days
*
86400
+
diff_date
.
seconds
total_seconds
=
diff_date
.
days
*
86400
+
diff_date
.
seconds
current_date
=
int
(
total_seconds
//
60
)
current_date
=
int
(
total_seconds
//
60
)
print
"Current date/time:
%
d minutes (since 0:00 1/1/96)
\n
"
%
current_date
print
(
"Current date/time:
%
d minutes (since 0:00 1/1/96)
\n
"
%
current_date
)
# Manufacturiing date = current date
# Manufacturiing date = current date
print
"Manufacturing date :
%
d 0x
%06
X"
%
(
current_date
,
current_date
)
print
(
"Manufacturing date :
%
d 0x
%06
X"
%
(
current_date
,
current_date
)
)
mfg_date
=
current_date
mfg_date
=
current_date
#==================================================
#==================================================
# Create Board Info Area
# Create Board Info Area
# FRU field is used to store the date of generation of the eeprom content
# FRU field is used to store the date of generation of the eeprom content
# This could be used later to determine if the content has to be udated (bug fix, ...)
# This could be used later to determine if the content has to be udated (bug fix, ...)
print
"EEPROM content generated:
%
s
\n
"
%
now_date
print
(
"EEPROM content generated:
%
s
\n
"
%
now_date
)
fru
=
"
%
s"
%
now_date
fru
=
"
%
s"
%
now_date
bia
=
BoardInfoArea
(
mfg_date
,
"CERN"
,
"FmcAdc100m14b4cha"
,
serial
,
PART_NUMBER
,
fru
)
bia
=
BoardInfoArea
(
mfg_date
,
"CERN"
,
"FmcAdc100m14b4cha"
,
serial
,
PART_NUMBER
,
fru
)
...
@@ -107,30 +107,30 @@ def main (default_directory='.'):
...
@@ -107,30 +107,30 @@ def main (default_directory='.'):
byte
=
f_eeprom
.
read
(
1
)
# reads one byte
byte
=
f_eeprom
.
read
(
1
)
# reads one byte
f_eeprom
.
close
()
f_eeprom
.
close
()
print
"Raw EEPROM data:"
print
(
"Raw EEPROM data:"
)
i
=
0
i
=
0
for
data
in
eeprom_data
:
for
data
in
eeprom_data
:
if
i
%
8
==
0
:
if
i
%
8
==
0
:
print
"0x
%02
X (
%3
d) :
%02
X"
%
(
i
,
i
,
data
),
print
(
"0x
%02
X (
%3
d) :
%02
X"
%
(
i
,
i
,
data
),
end
=
' '
)
else
:
else
:
print
"
%02
X"
%
(
data
),
print
(
"
%02
X"
%
(
data
),
end
=
' '
)
i
+=
1
i
+=
1
if
i
%
8
==
0
:
if
i
%
8
==
0
:
print
""
print
(
""
)
print
(
"
\n
"
)
print
(
"
\n
"
)
dsum
=
0
dsum
=
0
for
data
in
eeprom_data
[
158
:
162
]:
for
data
in
eeprom_data
[
158
:
162
]:
dsum
+=
data
dsum
+=
data
print
(
"0x
%02
X 0x
%
X"
%
(
data
,
dsum
))
print
(
(
"0x
%02
X 0x
%
X"
%
(
data
,
dsum
)
))
print
(
"
\n\n
sum: 0x
%02
X"
%
dsum
)
print
(
(
"
\n\n
sum: 0x
%02
X"
%
dsum
)
)
checksum
=
(
0xff
&
(
1
+
~
dsum
))
checksum
=
(
0xff
&
(
1
+
~
dsum
))
print
(
"calculated checksum: 0x
%02
X"
%
checksum
)
print
(
(
"calculated checksum: 0x
%02
X"
%
checksum
)
)
print
(
"data checksum : 0x
%02
X"
%
eeprom_data
[
162
]
)
print
(
(
"data checksum : 0x
%02
X"
%
eeprom_data
[
162
])
)
print
(
""
)
print
(
""
)
print
(
"check data: 0x
%02
X"
%
(
dsum
+
eeprom_data
[
162
]
))
print
(
(
"check data: 0x
%02
X"
%
(
dsum
+
eeprom_data
[
162
])
))
print
(
"check data: 0x
%02
X"
%
(
dsum
+
checksum
))
print
(
(
"check data: 0x
%02
X"
%
(
dsum
+
checksum
)
))
if
__name__
==
'__main__'
:
if
__name__
==
'__main__'
:
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment