1
0
mirror of https://github.com/jonathanhogg/scopething synced 2025-07-14 03:02:09 +01:00

Use array objects for samples and timestamps (as two items in a DotDict per trace); put +2 back into timeout calculation logic

This commit is contained in:
Jonathan Hogg
2017-07-29 15:04:38 +01:00
parent 36f85b8e8c
commit 33311848f0
2 changed files with 18 additions and 22 deletions

5
vm.py
View File

@ -13,6 +13,7 @@ document][VM01B].
"""
import array
import asyncio
from collections import namedtuple
from enum import IntEnum
@ -356,10 +357,10 @@ class VirtualMachine:
if sample_width == 2:
data = await self._reader.readexactly(2 * n)
data = struct.unpack(f'>{n}h', data)
return [(value+32768)/65535 for value in data]
return array.array('d', ((value+32768)/65535 for value in data))
elif sample_width == 1:
data = await self._reader.readexactly(n)
return [value/255 for value in data]
return array.array('d', (value/255 for value in data))
else:
raise ValueError(f"Bad sample width: {sample_width}")