Skip to content

Commit

Permalink
fixing type issue and chipdescription constructir
Browse files Browse the repository at this point in the history
  • Loading branch information
snhobbs committed Jun 5, 2024
1 parent 157abdc commit 7110826
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 7 deletions.
Empty file modified pyproject.toml
100755 → 100644
Empty file.
19 changes: 14 additions & 5 deletions src/isp_programmer/ISPConnection.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ def _write_serial(self, out: bytes) -> None:
self._delay_write_serial(out)
else:
self.iodevice.write(out)
logging.log(logging.DEBUG - 1, f"Write: [{out.decode('utf-8')}]")
logging.log(logging.DEBUG - 1, f"Write: [{out}]")

def _flush(self):
self.iodevice.flush()
Expand Down Expand Up @@ -567,17 +567,24 @@ class ChipDescription:
}

def __init__(self, descriptor: dict[str, str]):
self.RAMRange = [0, 0]
self.RAMBufferSize = 0
self.FlashRange = [0, 0]

# for name in dict(descriptor):
# self.__setattr__(name, descriptor[name])

self.RAMRange = descriptor.pop("RAMRange")
self.FlashRange = descriptor.pop("FlashRange")
self.RAMBufferSize = int(descriptor.pop("RAMBufferSize"))
self.SectorCount: int = int(descriptor.pop("SectorCount"))
self.RAMStartWrite: int = int(descriptor.pop("RAMStartWrite"))
self.CrystalFrequency = 12000 # khz == 30MHz
self.kCheckSumLocation = 7 # 0x0000001c

assert self.RAMRange[0] > 0
assert self.RAMRange[1] > self.RAMRange[0]

assert self.FlashRange[1] > self.FlashRange[0]

assert self.SectorCount > 0

@property
def MaxByteTransfer(self) -> int:
return self.RAMBufferSize
Expand All @@ -586,6 +593,8 @@ def MaxByteTransfer(self) -> int:
def sector_bytes(self):
sector_bytes = self.SectorSizePages * self.kPageSizeBytes
assert sector_bytes % self.kWordSize == 0
if sector_bytes > self.MaxByteTransfer:
raise UserWarning(f"Sector Bytes: {sector_bytes} / {self.MaxByteTransfer}")
assert sector_bytes <= self.MaxByteTransfer
return sector_bytes

Expand Down
8 changes: 6 additions & 2 deletions src/isp_programmer/parts_definitions.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,12 @@ def read_lpcparts_string(string: str) -> dict[str, list]:
continue
split_line = line.strip().split(",")
for column, index in lpc_tools_column_locations.items():
value: int = int(split_line[index].strip(), 0)
df_dict[column].append(value)
read = split_line[index].strip()
try:
value: int = int(read, 0)
df_dict[column].append(value)
except ValueError:
df_dict[column].append(read)

for col in df_dict:
df_dict[col] = np.array(df_dict[col])
Expand Down

0 comments on commit 7110826

Please sign in to comment.