Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[sonic_eeprom/eeprom_base] EEPROM data instantiated and stored as a class member #190

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions sonic_platform_base/sonic_eeprom/eeprom_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ def __init__(self, path, format, start, status, readonly):
self.r = readonly
self.cache_name = None
self.cache_update_needed = False
self.eeprom_file_handle = None
self.eeprom_raw_bytes = None
self.lock_file = None

def check_status(self):
Expand Down Expand Up @@ -220,19 +222,20 @@ def open_eeprom(self):
except Exception:
pass
self.cache_update_needed = using_eeprom
self.eeprom_file_handle = io.open(eeprom_file, "rb")
return io.open(eeprom_file, "rb")

def read_eeprom(self):
sizeof_info = 0
for I in self.f:
sizeof_info += I[2]
o = self.read_eeprom_bytes(sizeof_info)
return o
self.eeprom_raw_bytes = self.read_eeprom_bytes(sizeof_info)
return self.eeprom_raw_bytes

def read_eeprom_bytes(self, byteCount, offset=0):
F = None
try:
F = self.open_eeprom()
F = self.eeprom_file_handle
F.seek(self.s + offset)
o = F.read(byteCount)

Expand All @@ -244,6 +247,7 @@ def read_eeprom_bytes(self, byteCount, offset=0):
self.cache_update_needed = True
F.close()
F = self.open_eeprom()
F = self.eeprom_file_handle
F.seek(self.s + offset)
o = F.read(byteCount)

Expand All @@ -256,7 +260,7 @@ def read_eeprom_bytes(self, byteCount, offset=0):
finally:
if F is not None:
F.close()

return bytearray(o)

def read_eeprom_db(self):
Expand Down