mirror of
https://github.com/jonathanhogg/scopething
synced 2025-07-14 03:02:09 +01:00
Fix breaks from changes in SerialStream initialisation; default to first matching USB device; return sample times from capture()
This commit is contained in:
@ -3,6 +3,7 @@ import asyncio
|
||||
import logging
|
||||
import os
|
||||
import serial
|
||||
from serial.tools.list_ports import comports
|
||||
|
||||
|
||||
Log = logging.getLogger('streams')
|
||||
@ -10,9 +11,16 @@ Log = logging.getLogger('streams')
|
||||
|
||||
class SerialStream:
|
||||
|
||||
@classmethod
|
||||
def stream_matching(cls, vid, pid, **kwargs):
|
||||
for port in comports():
|
||||
if port.vid == vid and port.pid == pid:
|
||||
return SerialStream(port.device, **kwargs)
|
||||
|
||||
def __init__(self, device, loop=None, **kwargs):
|
||||
self._device = device
|
||||
self._connection = serial.Serial(self._device, timeout=0, write_timeout=0, **kwargs)
|
||||
Log.debug("Opened SerialStream on {}".format(device))
|
||||
self._loop = loop if loop is not None else asyncio.get_event_loop()
|
||||
self._input_buffer = bytes()
|
||||
self._output_buffer = bytes()
|
||||
|
Reference in New Issue
Block a user