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 3 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
15 changes: 10 additions & 5 deletions sonic_platform_base/sonic_eeprom/eeprom_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@ 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.o = None
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Prefer using a more descriptive name, like eeprom_raw_bytes or similar.

self.byte_array = None
self.lock_file = None

def check_status(self):
Expand Down Expand Up @@ -220,19 +223,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.o = self.read_eeprom_bytes(sizeof_info)
return self.o

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 +248,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,8 +261,8 @@ def read_eeprom_bytes(self, byteCount, offset=0):
finally:
if F is not None:
F.close()

return bytearray(o)
self.byte_array = bytearray(o)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't need to store this as a class member. It should be local only.

return self.byte_array

def read_eeprom_db(self):
return 0
Expand Down