@@ -729,7 +729,7 @@ def validate_eeprom_page(page):
729
729
int page
730
730
"""
731
731
try :
732
- page = int (page )
732
+ page = int (page , base = 16 )
733
733
except ValueError :
734
734
click .echo ('Please enter a numeric page number' )
735
735
sys .exit (ERROR_NOT_IMPLEMENTED )
@@ -848,8 +848,8 @@ def eeprom_hexdump_pages_general(logical_port_name, pages, target_page):
848
848
return return_code , output
849
849
lines .append (output )
850
850
else :
851
- lines .append (f'\n { EEPROM_DUMP_INDENT } Upper page { page :x} h' )
852
- return_code , output = eeprom_dump_general (physical_port , page , page * PAGE_SIZE + PAGE_OFFSET , PAGE_SIZE , PAGE_OFFSET )
851
+ lines .append (f'\n { EEPROM_DUMP_INDENT } Upper page { int ( str ( page ), base = 16 ) :x} h' )
852
+ return_code , output = eeprom_dump_general (physical_port , page , int ( str ( page ), base = 16 ) * PAGE_SIZE + PAGE_OFFSET , PAGE_SIZE , PAGE_OFFSET )
853
853
if return_code != 0 :
854
854
return return_code , output
855
855
lines .append (output )
@@ -895,7 +895,7 @@ def eeprom_hexdump_pages_sff8472(logical_port_name, pages, target_page):
895
895
lines .append (output )
896
896
else :
897
897
lines .append (f'\n { EEPROM_DUMP_INDENT } A2h dump (upper 128 bytes) page { page - 2 :x} h' )
898
- return_code , output = eeprom_dump_general (physical_port , page , SFF8472_A0_SIZE + PAGE_OFFSET + page * PAGE_SIZE , PAGE_SIZE , PAGE_SIZE )
898
+ return_code , output = eeprom_dump_general (physical_port , page , SFF8472_A0_SIZE + PAGE_OFFSET + int ( str ( page ), base = 16 ) * PAGE_SIZE , PAGE_SIZE , PAGE_SIZE )
899
899
if return_code != 0 :
900
900
return ERROR_NOT_IMPLEMENTED , 'Error: Failed to read EEPROM for A2h upper page!'
901
901
lines .append (output )
@@ -928,28 +928,6 @@ def eeprom_dump_general(physical_port, page, flat_offset, size, page_offset, no_
928
928
return 0 , '' .join ('{:02x}' .format (x ) for x in page_dump )
929
929
930
930
931
-
932
- def eeprom_dump_general (physical_port , page , flat_offset , size , page_offset , no_format = False ):
933
- """
934
- Dump module EEPROM for given pages in hex format.
935
- Args:
936
- logical_port_name: logical port name
937
- pages: a list of pages to be dumped. The list always include a default page list and the target_page input by
938
- user
939
- target_page: user input page number, optional. target_page is only for display purpose
940
- Returns:
941
- tuple(0, dump string) if success else tuple(error_code, error_message)
942
- """
943
- sfp = platform_chassis .get_sfp (physical_port )
944
- page_dump = sfp .read_eeprom (flat_offset , size )
945
- if page_dump is None :
946
- return ERROR_NOT_IMPLEMENTED , f'Error: Failed to read EEPROM for page { page :x} h, flat_offset { flat_offset } , page_offset { page_offset } , size { size } !'
947
- if not no_format :
948
- return 0 , hexdump (EEPROM_DUMP_INDENT , page_dump , page_offset , start_newline = False )
949
- else :
950
- return 0 , '' .join ('{:02x}' .format (x ) for x in page_dump )
951
-
952
-
953
931
def convert_byte_to_valid_ascii_char (byte ):
954
932
if byte < 32 or 126 < byte :
955
933
return '.'
0 commit comments