Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
A
AIDA-2020 TLU - Software
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
0
Merge Requests
0
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
AIDA-2020 TLU - Software
Commits
1357467e
Commit
1357467e
authored
Jun 11, 2018
by
Paolo Baesso
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added class for SFP cage
parent
0193c6e8
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
47 additions
and
14 deletions
+47
-14
PCA9548ADW.py
packages/PCA9548ADW.py
+1
-0
SFPI2C.py
packages/SFPI2C.py
+46
-14
No files found.
packages/PCA9548ADW.py
View file @
1357467e
...
...
@@ -3,6 +3,7 @@ import uhal
from
I2CuHal
import
I2CCore
import
StringIO
class
PCA9548ADW
:
#Class to configure the I2C multiplexer
...
...
packages/SFPI2C.py
View file @
1357467e
...
...
@@ -10,13 +10,19 @@ class SFPI2C:
self
.
i2c
=
i2c
self
.
slaveaddr
=
slaveaddr
def
readEEPROM
(
self
,
startadd
,
nBytes
):
"""
def readEEPROM(self, startadd, nBytes):
#Read EEPROM memory locations
mystop= False
myaddr= [startadd]#0xfa
self.i2c.write( self.slaveaddr, [startadd], mystop)
res= self.i2c.read( self.slaveaddr, nBytes)
return
res
return res"""
def
_listToString
(
self
,
mylist
):
mystring
=
""
for
iChar
in
mylist
:
mystring
=
mystring
+
str
(
unichr
(
iChar
))
return
mystring
def
writeReg
(
self
,
regN
,
regContent
,
verbose
=
False
):
#Basic functionality to write to register.
...
...
@@ -34,24 +40,50 @@ class SFPI2C:
self
.
i2c
.
write
(
self
.
slaveaddr
,
[
regN
],
mystop
)
res
=
self
.
i2c
.
read
(
self
.
slaveaddr
,
nwords
)
return
res
def
getConnector
(
self
):
"""Code for connector type (table 3.4)"""
conntype
=
self
.
readReg
(
2
,
1
,
False
)[
0
]
print
"Connector type:"
,
hex
(
conntype
)
return
conntype
def
getDiagnosticsType
(
self
):
"""Types of diagnostics available (table 3.9)"""
diaType
=
self
.
readReg
(
92
,
1
,
False
)[
0
]
print
"Available Diagnostics:"
,
hex
(
diaType
)
return
diaType
def
getEncoding
(
self
):
encoding
=
self
.
readReg
(
11
,
1
,
False
)[
0
]
print
"Encoding"
,
encoding
return
encoding
def
getEnhancedOpt
(
self
):
enOpt
=
self
.
readReg
(
93
,
1
,
False
)[
0
]
print
"Enhanced Options:"
,
enOpt
return
enOpt
def
getTransceiver
(
self
):
res
=
self
.
readReg
(
3
,
8
,
False
)
return
res
def
getVendorId
(
self
):
""" Returns the OUI vendor id"""
id
=
[
0
,
0
,
0
]
id
[
0
]
=
self
.
readReg
(
37
,
1
,
False
)[
0
]
id
[
1
]
=
self
.
readReg
(
38
,
1
,
False
)[
0
]
id
[
2
]
=
self
.
readReg
(
39
,
1
,
False
)[
0
]
print
id
return
id
vendID
=
self
.
readReg
(
37
,
3
,
False
)
return
vendID
def
getVendorName
(
self
):
res
=
self
.
readReg
(
20
,
16
,
False
)
mystring
=
self
.
_listToString
(
res
)
return
mystring
def
getVendorPN
(
self
):
""" Returns the part number defined by the vendor"""
pn
=
[]
for
iaddr
in
range
(
0
,
16
):
item
=
self
.
readReg
(
40
+
iaddr
,
1
,
False
)[
0
]
pn
.
append
(
item
)
print
pn
return
pn
mystring
=
""
res
=
self
.
readReg
(
40
,
16
,
False
)
mystring
=
self
.
_listToString
(
res
)
return
mystring
def
scanI2C
(
self
):
mystop
=
True
...
...
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