Skip to content

Commit

Permalink
Merge pull request #7 from Aharoni-Lab/feature_uart_downlink
Browse files Browse the repository at this point in the history
Downlink commands for reconfig
  • Loading branch information
t-sasatani authored Aug 16, 2023
2 parents 713c434 + e1555fd commit 97c059f
Show file tree
Hide file tree
Showing 4 changed files with 245 additions and 184,925 deletions.
35 changes: 21 additions & 14 deletions miniscope_io/io.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,15 @@ class SDCard:
def __init__(
self,
drive: Union[str, Path],
layout: SDLayout

layout: SDLayout,
directpath: bool = False
):

self.drive = Path(drive).resolve()
if directpath == False:
self.drive = Path(drive).resolve()
else:
self.drive = drive
# Logs the error appropriately.
self.layout = layout

# Private attributes used when the file reading context is entered
Expand Down Expand Up @@ -68,17 +72,20 @@ def __init__(
@property
def config(self) -> SDConfig:
if self._config is None:
with open(self.drive, 'rb') as sd:
sd.seek(self.layout.sectors.config_pos, 0)
configSectorData = np.frombuffer(sd.read(self.layout.sectors.size), dtype=np.uint32)

self._config = SDConfig(
**{
k: configSectorData[v]
for k, v in self.layout.config.dict().items()
if v is not None
}
)
try:
with open(self.drive, 'rb') as sd:
sd.seek(self.layout.sectors.config_pos, 0)
configSectorData = np.frombuffer(sd.read(self.layout.sectors.size), dtype=np.uint32)

self._config = SDConfig(
**{
k: configSectorData[v]
for k, v in self.layout.config.dict().items()
if v is not None
}
)
except Exception as error:
print("An exception occurred:", error)

return self._config

Expand Down
Loading

0 comments on commit 97c059f

Please sign in to comment.