更新UCD-API库及文档
This commit is contained in:
@@ -1,8 +1,10 @@
|
||||
import time
|
||||
from typing import Union
|
||||
from ctypes import c_int, c_uint, c_int32
|
||||
from typing import Union, List
|
||||
|
||||
from UniTAP.libs.lib_tsi.tsi_io import DeviceIO
|
||||
from UniTAP.libs.lib_tsi.tsi import *
|
||||
import UniTAP.libs.lib_tsi.tsi_types as ci
|
||||
import UniTAP.libs.lib_tsi.tsi_private_types as p_ci
|
||||
from UniTAP.dev.modules.capturer.statuses import CaptureStatus, AudioCaptureStatus, EventCaptureStatus, \
|
||||
VideoCaptureStatus, BulkCaptureStatus
|
||||
from UniTAP.common import AudioFrameData, VideoFrameDSC, create_from_pps
|
||||
@@ -12,6 +14,8 @@ from UniTAP.utils import function_scheduler
|
||||
from UniTAP.dev.ports.modules.capturer.bulk.private_bulk_types import *
|
||||
from UniTAP.dev.ports.modules.capturer.bulk.bulk_types import *
|
||||
from .types import *
|
||||
from UniTAP.utils import tsi_logging as logging
|
||||
|
||||
|
||||
|
||||
TIMEOUT = 10
|
||||
@@ -84,27 +88,27 @@ class Capturer:
|
||||
|
||||
@property
|
||||
def video_capturer_status(self) -> VideoCaptureStatus:
|
||||
return VideoCaptureStatus(self.__io.get(TSI_VIDCAP_CAPTURE_STATUS_R, c_int)[1])
|
||||
return VideoCaptureStatus(self.__io.get(p_ci.TSI_VIDCAP_CAPTURE_STATUS_R, c_int)[1])
|
||||
|
||||
@property
|
||||
def audio_capturer_status(self) -> AudioCaptureStatus:
|
||||
return AudioCaptureStatus(self.__io.get(TSI_R_AUDCAP_STATUS, c_int)[1])
|
||||
return AudioCaptureStatus(self.__io.get(ci.TSI_R_AUDCAP_STATUS, c_int)[1])
|
||||
|
||||
@property
|
||||
def event_capturer_status(self) -> EventCaptureStatus:
|
||||
return EventCaptureStatus(self.__io.get(TSI_EVCAP_CTRL, c_uint32)[1] & 0xFF)
|
||||
return EventCaptureStatus(self.__io.get(ci.TSI_EVCAP_CTRL, c_uint32)[1] & 0xFF)
|
||||
|
||||
@property
|
||||
def bulk_capturer_status(self) -> BulkCaptureStatus:
|
||||
return BulkCaptureStatus(self.__io.get(TSI_BULK_CAPTURE_STATUS_R, c_uint32)[1] & 0x3)
|
||||
return BulkCaptureStatus(self.__io.get(ci.TSI_BULK_CAPTURE_STATUS_R, c_uint32)[1] & 0x3)
|
||||
|
||||
def start_capture(self, config: CaptureConfig):
|
||||
self.__mutex.acquire()
|
||||
|
||||
self.__config.from_int(self.__current_config().to_int() | config.to_int())
|
||||
self.__io.set(TSI_CAP_CONFIG, self.__config.to_int())
|
||||
self.__io.set(ci.TSI_CAP_CONFIG, self.__config.to_int())
|
||||
|
||||
if self.__io.set(TSI_W_CAP_COMMAND, 1) == 0:
|
||||
if self.__io.set(ci.TSI_W_CAP_COMMAND, 1) == 0:
|
||||
self.__status = CaptureStatus.Running
|
||||
else:
|
||||
self.__status = CaptureStatus.Unknown
|
||||
@@ -115,9 +119,9 @@ class Capturer:
|
||||
self.__mutex.acquire()
|
||||
|
||||
self.__config.from_int(self.__current_config().to_int() & ~config.to_int())
|
||||
self.__io.set(TSI_CAP_CONFIG, self.__config.to_int())
|
||||
self.__io.set(ci.TSI_CAP_CONFIG, self.__config.to_int())
|
||||
|
||||
if self.__io.set(TSI_W_CAP_COMMAND, 2) == 0:
|
||||
if self.__io.set(ci.TSI_W_CAP_COMMAND, 2) == 0:
|
||||
self.__status = CaptureStatus.Stop
|
||||
else:
|
||||
self.__status = CaptureStatus.Unknown
|
||||
@@ -128,22 +132,22 @@ class Capturer:
|
||||
event = EventData()
|
||||
|
||||
if event_count > 0:
|
||||
event_size = self.__io.get(TSI_R_EVCAP_DATA, None, 0)[0]
|
||||
event_size = self.__io.get(ci.TSI_R_EVCAP_DATA, None, 0)[0]
|
||||
if event_size > 0:
|
||||
event.data = bytearray(self.__io.get(TSI_R_EVCAP_DATA, c_ubyte, event_size)[1])
|
||||
event.data = bytearray(self.__io.get(ci.TSI_R_EVCAP_DATA, c_ubyte, event_size)[1])
|
||||
|
||||
return event
|
||||
|
||||
def get_buffer_capacity(self, stream_number: int = None):
|
||||
if stream_number is not None:
|
||||
self.__io.set(TSI_DPRX_STREAM_SELECT, stream_number, c_uint32)
|
||||
self.__io.set(TSI_DPRX_MSA_COMMAND_W, 2, c_uint32)
|
||||
self.__io.set(ci.TSI_DPRX_STREAM_SELECT, stream_number, c_uint32)
|
||||
self.__io.set(ci.TSI_DPRX_MSA_COMMAND_W, 2, c_uint32)
|
||||
|
||||
width = self.__io.get(TSI_R_INPUT_WIDTH , c_uint32)[1]
|
||||
height = self.__io.get(TSI_R_INPUT_HEIGHT , c_uint32)[1]
|
||||
total_memory_bytes = self.__io.get(TSI_MEMORY_SIZE_R, c_uint64)[1]
|
||||
bpc = self.__io.get(TSI_INPUT_COLOR_DEPTH_R , c_uint32)[1]
|
||||
color_format = self.__io.get(TSI_INPUT_COLOR_MODE_R , c_uint32)[1]
|
||||
width = self.__io.get(ci.TSI_R_INPUT_WIDTH, c_uint32)[1]
|
||||
height = self.__io.get(ci.TSI_R_INPUT_HEIGHT, c_uint32)[1]
|
||||
total_memory_bytes = self.__io.get(ci.TSI_MEMORY_SIZE_R, c_uint64)[1]
|
||||
bpc = self.__io.get(ci.TSI_INPUT_COLOR_DEPTH_R, c_uint32)[1]
|
||||
color_format = self.__io.get(ci.TSI_INPUT_COLOR_MODE_R, c_uint32)[1]
|
||||
|
||||
bpp = self._get_bits_per_pixel(bpc, color_format)
|
||||
line_alignment = 1023
|
||||
@@ -186,7 +190,7 @@ class Capturer:
|
||||
return (value + alignment) & ~alignment
|
||||
|
||||
def get_available_events_count(self) -> int:
|
||||
return self.__io.get(TSI_R_EVCAP_COUNT, c_uint32)[1]
|
||||
return self.__io.get(ci.TSI_R_EVCAP_COUNT, c_uint32)[1]
|
||||
|
||||
def capture_n_events(self, events_count: int):
|
||||
if events_count <= 0:
|
||||
@@ -215,19 +219,21 @@ class Capturer:
|
||||
|
||||
audio_frame = AudioFrameData()
|
||||
|
||||
audio_frame.channel_count = self.__io.get(TSI_R_AUDCAP_CHANNEL_COUNT, c_int)[1]
|
||||
audio_frame.sample_size = self.__io.get(TSI_R_AUDCAP_SAMPLE_SIZE, c_int)[1] * 8
|
||||
audio_frame.sample_rate = self.__io.get(TSI_R_AUDCAP_SAMPLE_RATE, c_int)[1]
|
||||
audio_frame.timestamp = self.__io.get(TSI_R_AUDCAP_TIMESTAMP, c_uint64)[1]
|
||||
audio_frame.samples = self.__io.get(TSI_R_AUDCAP_SAMPLE_COUNT, c_int)[1]
|
||||
audio_frame.frame_counter = self.__io.get(TSI_R_AUDCAP_FRAME_COUNTER, c_int)[1]
|
||||
audio_frame.sample_format = self.__io.get(TSI_R_AUDCAP_SAMPLE_FORMAT, c_int)[1]
|
||||
audio_frame.channel_count = self.__io.get(ci.TSI_AUDCAP_CHANNEL_COUNT_R, c_int)[1]
|
||||
audio_frame.sample_size = self.__io.get(ci.TSI_AUDCAP_SAMPLE_BITS_SIZE_R, c_int)[1]
|
||||
audio_frame.sample_rate = self.__io.get(ci.TSI_R_AUDCAP_SAMPLE_RATE, c_int)[1]
|
||||
audio_frame.timestamp = self.__io.get(ci.TSI_R_AUDCAP_TIMESTAMP, c_uint64)[1]
|
||||
audio_frame.samples = self.__io.get(ci.TSI_R_AUDCAP_SAMPLE_COUNT, c_int)[1]
|
||||
audio_frame.frame_counter = self.__io.get(ci.TSI_R_AUDCAP_FRAME_COUNTER, c_int)[1]
|
||||
audio_frame.sample_format = self.__io.get(ci.TSI_R_AUDCAP_SAMPLE_FORMAT, c_int)[1]
|
||||
|
||||
min_buff_size = self.__io.get(TSI_R_AUDCAP_MIN_BUFFER_SIZE, c_uint32)[1]
|
||||
audio_frame.data = self.__io.get(TSI_R_AUDCAP_SAMPLE_DATA, c_uint8, min_buff_size)[1]
|
||||
min_buff_size = self.__io.get(ci.TSI_R_AUDCAP_MIN_BUFFER_SIZE, c_uint32)[1]
|
||||
audio_frame.data = self.__io.get(ci.TSI_R_AUDCAP_SAMPLE_DATA, c_uint8, min_buff_size)[1]
|
||||
|
||||
m_sec -= 1000 * len(audio_frame.data) / 2 / audio_frame.channel_count / audio_frame.sample_rate
|
||||
captured_sample_count = len(audio_frame.data) / (audio_frame.sample_size / 8) / audio_frame.channel_count
|
||||
captured_m_sec_count = int(captured_sample_count * 1000 / audio_frame.sample_rate)
|
||||
|
||||
m_sec -= captured_m_sec_count
|
||||
return audio_frame, m_sec
|
||||
|
||||
def capture_audio_by_n_frames(self, frames_count: int, timeout: int = None):
|
||||
@@ -263,29 +269,32 @@ class Capturer:
|
||||
raise ValueError(f"Seconds count must be more than 0.")
|
||||
|
||||
buffer = []
|
||||
time_break = False
|
||||
|
||||
while m_sec > 0 and not time_break:
|
||||
captured = 0
|
||||
last_data_time = time.time()
|
||||
while m_sec > 0:
|
||||
start_time = time.time()
|
||||
while captured < 10 and m_sec > 0:
|
||||
status = self.audio_capturer_status
|
||||
current_time = time.time()
|
||||
if current_time - start_time > TIMEOUT:
|
||||
time_break = True
|
||||
break
|
||||
if status == AudioCaptureStatus.Stop:
|
||||
continue
|
||||
while self.audio_capturer_status != AudioCaptureStatus.Running:
|
||||
if time.time() - start_time > TIMEOUT:
|
||||
logging.error(f"Audio capture device not running for {TIMEOUT} seconds. Aborting.")
|
||||
return buffer
|
||||
logging.debug(f"Audio capture device not running yet: {self.audio_capturer_status}")
|
||||
time.sleep(0.5)
|
||||
|
||||
audio_frame, m_sec = self.__capture_audio(m_sec=m_sec)
|
||||
if len(audio_frame.data) > 0:
|
||||
captured += 1
|
||||
buffer.append(audio_frame)
|
||||
audio_frame, m_sec = self.__capture_audio(m_sec=m_sec)
|
||||
if len(audio_frame.data) > 0:
|
||||
buffer.append(audio_frame)
|
||||
last_data_time = time.time()
|
||||
else:
|
||||
if time.time() - last_data_time > TIMEOUT:
|
||||
logging.error(
|
||||
f"No audio data captured within {TIMEOUT} seconds. "
|
||||
f"Interrupting capture process."
|
||||
)
|
||||
break
|
||||
|
||||
return buffer
|
||||
|
||||
def get_available_video_frame_count(self):
|
||||
return self.__io.get(TSI_VIDCAP_AVAILABLE_FRAME_COUNT, c_int)[1]
|
||||
return self.__io.get(p_ci.TSI_VIDCAP_AVAILABLE_FRAME_COUNT, c_int)[1]
|
||||
|
||||
def __check_available_video(self, timeout) -> bool:
|
||||
def is_video_available(capturer):
|
||||
@@ -322,27 +331,27 @@ class Capturer:
|
||||
f"Cannot start to capture video. Current video capture status {self.video_capturer_status.name}")
|
||||
|
||||
try:
|
||||
result = self.__io.set(TSI_VIDCAP_CAPTURE_NEXT_W, 0)
|
||||
if result == TSI_ERROR_DATA_PROTECTION_ENABLED:
|
||||
result = self.__io.set(ci.TSI_VIDCAP_CAPTURE_NEXT_W, 0)
|
||||
if result == ci.TSI_ERROR_DATA_PROTECTION_ENABLED:
|
||||
raise CaptureError("Video data is HDCP protected. Capturing is not available.")
|
||||
except AssertionError as e:
|
||||
raise CaptureError(f"Error: {e}")
|
||||
|
||||
try:
|
||||
min_buffer_size = self.__io.get(TSI_R_VIDCAP_MIN_BUFFER_SIZE, c_int)[1]
|
||||
min_buffer_size = self.__io.get(ci.TSI_R_VIDCAP_MIN_BUFFER_SIZE, c_int)[1]
|
||||
if min_buffer_size <= 0:
|
||||
raise ValueError("Minimum buffer size must be more than 0")
|
||||
except AssertionError as e:
|
||||
raise CaptureError(f"Error: {e}")
|
||||
|
||||
try:
|
||||
frame_data = bytearray(self.__io.get(TSI_R_VIDCAP_FRAME_DATA, c_uint8, min_buffer_size)[1])
|
||||
frame_data = bytearray(self.__io.get(ci.TSI_R_VIDCAP_FRAME_DATA, c_uint8, min_buffer_size)[1])
|
||||
if len(frame_data) <= 0:
|
||||
raise ValueError("Minimum length of captured data must be more than 0")
|
||||
except AssertionError as e:
|
||||
raise CaptureError(f"Error: {e}")
|
||||
|
||||
frame_attributes = self.__io.get(TSI_VIDCAP_FRAME_HEADER_R, VideoFrameHeader)[1]
|
||||
frame_attributes = self.__io.get(ci.TSI_VIDCAP_FRAME_HEADER_R, VideoFrameHeader)[1]
|
||||
|
||||
if frame_attributes.is_dsc() and len(frame_data) > 128:
|
||||
vf = VideoFrameDSC()
|
||||
@@ -397,12 +406,12 @@ class Capturer:
|
||||
|
||||
def set_video_stream_number(self, number: int):
|
||||
self.__mutex.acquire()
|
||||
self.__io.set(TSI_DPRX_STREAM_SELECT, number, c_uint32)
|
||||
self.__io.set(ci.TSI_DPRX_STREAM_SELECT, number, c_uint32)
|
||||
self.__mutex.release()
|
||||
|
||||
def __current_config(self) -> CaptureConfig:
|
||||
config = CaptureConfig()
|
||||
config.from_int(self.__io.get(TSI_CAP_CONFIG, c_uint)[1])
|
||||
config.from_int(self.__io.get(ci.TSI_CAP_CONFIG, c_uint)[1])
|
||||
return config
|
||||
|
||||
# Capture CRC
|
||||
@@ -410,7 +419,7 @@ class Capturer:
|
||||
if crc_frame_count <= 0:
|
||||
raise ValueError(f"Incorrect crc frame count: {crc_frame_count}")
|
||||
|
||||
crc_values = self.__io.get(TSI_VIDCAP_SIGNAL_CRC_R, CrcStruct, crc_frame_count)[1]
|
||||
crc_values = self.__io.get(ci.TSI_VIDCAP_SIGNAL_CRC_R, CrcStruct, crc_frame_count)[1]
|
||||
crc_list = []
|
||||
if crc_frame_count == 1:
|
||||
crc_list = [(crc_values.r, crc_values.g, crc_values.b)]
|
||||
@@ -420,15 +429,15 @@ class Capturer:
|
||||
|
||||
# Bulk Capturer
|
||||
def read_bulk_capture_caps(self) -> CaptureCaps:
|
||||
return self.__io.get(TSI_BULK_CAPTURE_CAPS_R, CaptureCaps)[1]
|
||||
return self.__io.get(ci.TSI_BULK_CAPTURE_CAPS_R, CaptureCaps)[1]
|
||||
|
||||
def read_bulk_trigger_caps(self) -> int:
|
||||
return self.__io.get(TSI_BULK_TRIGGER_CAPS_R, c_uint32)[1]
|
||||
return self.__io.get(ci.TSI_BULK_TRIGGER_CAPS_R, c_uint32)[1]
|
||||
|
||||
def write_bulk_trigger_settings(self, trigger_mask: int, trigger_config: list, trigger_config_ext: list):
|
||||
self.__io.set(TSI_BULK_TRIGGER_MASK_W, trigger_mask, c_uint32)
|
||||
self.__io.set(TSI_BULK_TRIGGER_CONFIGURATION_W, trigger_config, c_uint32, data_count=len(trigger_config))
|
||||
self.__io.set(TSI_BULK_TRIGGER_CONFIGURATION_EXT_W, trigger_config_ext, c_uint32,
|
||||
self.__io.set(ci.TSI_BULK_TRIGGER_MASK_W, trigger_mask, c_uint32)
|
||||
self.__io.set(ci.TSI_BULK_TRIGGER_CONFIGURATION_W, trigger_config, c_uint32, data_count=len(trigger_config))
|
||||
self.__io.set(ci.TSI_BULK_TRIGGER_CONFIGURATION_EXT_W, trigger_config_ext, c_uint32,
|
||||
data_count=len(trigger_config_ext))
|
||||
|
||||
def write_bulk_size(self, size: int):
|
||||
@@ -436,56 +445,56 @@ class Capturer:
|
||||
data.BLOCK = 0
|
||||
data.OFFSET = 0
|
||||
data.SIZE = size
|
||||
self.__io.set(TSI_BULK_CAPTURE_BLOCK, data, SBlock)
|
||||
self.__io.set(ci.TSI_BULK_CAPTURE_BLOCK, data, SBlock)
|
||||
|
||||
def write_encoding_type(self, value: EncodingTypeEnum):
|
||||
self.__io.set(TSI_BULK_CAPTURE_TYPE, value.value, c_uint32)
|
||||
self.__io.set(ci.TSI_BULK_CAPTURE_TYPE, value.value, c_uint32)
|
||||
|
||||
def read_encoding_type(self) -> EncodingTypeEnum:
|
||||
return EncodingTypeEnum(self.__io.get(TSI_BULK_CAPTURE_TYPE, c_uint32)[1])
|
||||
return EncodingTypeEnum(self.__io.get(ci.TSI_BULK_CAPTURE_TYPE, c_uint32)[1])
|
||||
|
||||
def write_lane_count(self, value: LaneCountEnum):
|
||||
self.__io.set(TSI_BULK_CAPTURE_LANE_COUNT, value.value, c_uint32)
|
||||
self.__io.set(ci.TSI_BULK_CAPTURE_LANE_COUNT, value.value, c_uint32)
|
||||
|
||||
def read_lane_count(self) -> LaneCountEnum:
|
||||
return LaneCountEnum(self.__io.get(TSI_BULK_CAPTURE_LANE_COUNT, c_uint32)[1])
|
||||
return LaneCountEnum(self.__io.get(ci.TSI_BULK_CAPTURE_LANE_COUNT, c_uint32)[1])
|
||||
|
||||
def write_bulk_gpio(self, gpio: bool):
|
||||
self.__io.set(TSI_BULK_CAPTURE_GPIO_W, TSI_BULK_CAPTURE_GPIO_5BIT if gpio else TSI_BULK_CAPTURE_GPIO_OFF,
|
||||
self.__io.set(ci.TSI_BULK_CAPTURE_GPIO_W, ci.TSI_BULK_CAPTURE_GPIO_5BIT if gpio else ci.TSI_BULK_CAPTURE_GPIO_OFF,
|
||||
c_uint32)
|
||||
|
||||
def write_bulk_trigger_position(self, position: int):
|
||||
self.__io.set(TSI_BULK_TRIGGER_POS, position)
|
||||
self.__io.set(ci.TSI_BULK_TRIGGER_POS, position)
|
||||
|
||||
def start_bulk_capture(self):
|
||||
|
||||
self.__mutex.acquire()
|
||||
|
||||
self.__io.set(TSI_EVCAP_CTRL, 1)
|
||||
self.__io.set(TSI_BULK_CAPTURE_CONTROL_W, TSI_BULK_CAPTURE_START)
|
||||
self.__io.set(ci.TSI_EVCAP_CTRL, 1)
|
||||
self.__io.set(ci.TSI_BULK_CAPTURE_CONTROL_W, ci.TSI_BULK_CAPTURE_START)
|
||||
|
||||
self.__mutex.release()
|
||||
|
||||
def stop_bulk_capture(self):
|
||||
self.__mutex.acquire()
|
||||
|
||||
self.__io.set(TSI_EVCAP_CTRL, 0)
|
||||
self.__io.set(TSI_BULK_CAPTURE_CONTROL_W, TSI_BULK_CAPTURE_STOP)
|
||||
self.__io.set(ci.TSI_EVCAP_CTRL, 0)
|
||||
self.__io.set(ci.TSI_BULK_CAPTURE_CONTROL_W, ci.TSI_BULK_CAPTURE_STOP)
|
||||
|
||||
self.__mutex.release()
|
||||
|
||||
def start_event_capture(self):
|
||||
self.__mutex.acquire()
|
||||
|
||||
self.__io.set(TSI_EVCAP_CTRL, 1)
|
||||
self.__io.set(TSI_EVCAP_EVENT_SRC_EN, UCD_ALL_EVENTS)
|
||||
self.__io.set(ci.TSI_EVCAP_CTRL, 1)
|
||||
self.__io.set(ci.TSI_EVCAP_EVENT_SRC_EN, ci.UCD_ALL_EVENTS)
|
||||
|
||||
self.__mutex.release()
|
||||
|
||||
def stop_event_capture(self):
|
||||
self.__mutex.acquire()
|
||||
|
||||
self.__io.set(TSI_EVCAP_CTRL, 0)
|
||||
self.__io.set(ci.TSI_EVCAP_CTRL, 0)
|
||||
|
||||
self.__mutex.release()
|
||||
|
||||
@@ -494,9 +503,9 @@ class Capturer:
|
||||
value = -1
|
||||
time_waited = time.time()
|
||||
|
||||
while value != TSI_BULK_STATUS_IDLE and time.time() - time_waited < max_time_waiting:
|
||||
self.__io.set(TSI_BULK_CAPTURE_CLEAR_W, 0)
|
||||
value = self.__io.get(TSI_BULK_CAPTURE_STATUS_R)[1]
|
||||
while value != ci.TSI_BULK_STATUS_IDLE and time.time() - time_waited < max_time_waiting:
|
||||
self.__io.set(ci.TSI_BULK_CAPTURE_CLEAR_W, 0)
|
||||
value = self.__io.get(ci.TSI_BULK_CAPTURE_STATUS_R)[1]
|
||||
|
||||
def bulk_capture(self, all_size: int, trigger_enabled: Optional[TriggerVarType]) -> list:
|
||||
buffer = []
|
||||
@@ -504,16 +513,16 @@ class Capturer:
|
||||
prev_status = 0
|
||||
last_bulk_capture_time = time.time()
|
||||
for i in range(iterations):
|
||||
event_count = self.__io.get(TSI_EVCAP_COUNT_R, c_uint32)[1]
|
||||
event_count = self.__io.get(ci.TSI_EVCAP_COUNT_R, c_uint32)[1]
|
||||
if event_count > 0:
|
||||
event_number = 0
|
||||
prev_timestamp = 0
|
||||
events_captured = 0
|
||||
while event_count > 0 and events_captured < 500:
|
||||
event_size = self.__io.get(TSI_R_EVCAP_DATA, None, 0)[0]
|
||||
event_size = self.__io.get(ci.TSI_R_EVCAP_DATA, None, 0)[0]
|
||||
if event_size > 0:
|
||||
cap_data = CapturedData()
|
||||
cap_data.data = bytearray(self.__io.get(TSI_R_EVCAP_DATA, c_ubyte, event_size)[1])
|
||||
cap_data.data = bytearray(self.__io.get(ci.TSI_R_EVCAP_DATA, c_ubyte, event_size)[1])
|
||||
cap_data.data = cap_data.data[3:]
|
||||
cap_data.type = CapturedDataType.Event
|
||||
cap_data.timestamp = int.from_bytes(bytes=cap_data.data[:8], byteorder='big')
|
||||
@@ -526,8 +535,8 @@ class Capturer:
|
||||
events_captured += 1
|
||||
event_count -= 1
|
||||
|
||||
bulk_status = self.__io.get(TSI_BULK_CAPTURE_STATUS_R, c_int32)[1]
|
||||
if bulk_status == TSI_BULK_STATUS_IDLE and prev_status == TSI_BULK_STATUS_TRANSFERRING:
|
||||
bulk_status = self.__io.get(ci.TSI_BULK_CAPTURE_STATUS_R, c_int32)[1]
|
||||
if bulk_status == ci.TSI_BULK_STATUS_IDLE and prev_status == ci.TSI_BULK_STATUS_TRANSFERRING:
|
||||
return buffer
|
||||
prev_status = bulk_status
|
||||
|
||||
@@ -538,12 +547,12 @@ class Capturer:
|
||||
if not self.__check_available_bulk_data(TIMEOUT):
|
||||
return buffer
|
||||
|
||||
self.__io.set(TSI_EVCAP_CTRL, 0)
|
||||
self.__io.set(ci.TSI_EVCAP_CTRL, 0)
|
||||
cap_data = CapturedData()
|
||||
cap_data.type = CapturedDataType.Bulk
|
||||
result, data, _ = self.__io.get(TSI_BULK_CAPTURE_DATA_R, c_ubyte, 1024 * 1024)
|
||||
result, data, _ = self.__io.get(ci.TSI_BULK_CAPTURE_DATA_R, c_ubyte, 1024 * 1024)
|
||||
cap_data.data = bytearray(data)
|
||||
if result >= TSI_SUCCESS and len(cap_data.data) > 0:
|
||||
if result >= ci.TSI_SUCCESS and len(cap_data.data) > 0:
|
||||
buffer.append(cap_data)
|
||||
last_bulk_capture_time = time.time()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user