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

Downlink commands for reconfig #7

Merged
merged 6 commits into from
Aug 16, 2023
Merged
Show file tree
Hide file tree
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
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