mirror of
https://github.com/davidhalter/typeshed.git
synced 2025-12-07 20:54:28 +08:00
Add stubs for the pyserial package (#9347)
This commit is contained in:
73
stubs/pyserial/@tests/stubtest_allowlist.txt
Normal file
73
stubs/pyserial/@tests/stubtest_allowlist.txt
Normal file
@@ -0,0 +1,73 @@
|
||||
# Error: failed to import
|
||||
# =======================
|
||||
serial.__main__ # SystemExit
|
||||
serial.serialcli # (IronPython) ModuleNotFoundError: No module named 'System'
|
||||
serial.serialjava # No Java Communications API implementation found
|
||||
|
||||
# Error: is inconsistent
|
||||
# ======================
|
||||
# These are positional only argument in the stub because they inherit from io.RawIOBase
|
||||
# but at runtime they are normal arguments that don't have consistent names.
|
||||
serial.Serial.read
|
||||
serial.Serial.write
|
||||
serial.SerialBase.readinto
|
||||
serial.serialutil.SerialBase.readinto
|
||||
serial.rfc2217.Serial.read
|
||||
serial.rfc2217.Serial.write
|
||||
serial.rs485.RS485.write
|
||||
serial.urlhandler.protocol_cp2110.Serial.read
|
||||
serial.urlhandler.protocol_cp2110.Serial.write
|
||||
serial.urlhandler.protocol_loop.Serial.read
|
||||
serial.urlhandler.protocol_loop.Serial.write
|
||||
serial.urlhandler.protocol_rfc2217.Serial.read
|
||||
serial.urlhandler.protocol_rfc2217.Serial.write
|
||||
serial.urlhandler.protocol_socket.Serial.read
|
||||
serial.urlhandler.protocol_socket.Serial.write
|
||||
serial.urlhandler.protocol_spy.Serial.read
|
||||
serial.urlhandler.protocol_spy.Serial.write
|
||||
|
||||
# Error: is not present in stub
|
||||
# =============================
|
||||
# Python 2 compatibility
|
||||
serial.basestring
|
||||
serial.serialutil.basestring
|
||||
serial.serialutil.iterbytes
|
||||
serial.serialutil.to_bytes
|
||||
|
||||
# Deprecated aliases
|
||||
serial.SerialBase.applySettingsDict
|
||||
serial.SerialBase.flushInput
|
||||
serial.SerialBase.flushOutput
|
||||
serial.SerialBase.getCD
|
||||
serial.SerialBase.getCTS
|
||||
serial.SerialBase.getDSR
|
||||
serial.SerialBase.getRI
|
||||
serial.SerialBase.getSettingsDict
|
||||
serial.SerialBase.inWaiting
|
||||
serial.SerialBase.interCharTimeout
|
||||
serial.SerialBase.isOpen
|
||||
serial.SerialBase.sendBreak
|
||||
serial.SerialBase.setDTR
|
||||
serial.SerialBase.setPort
|
||||
serial.SerialBase.setRTS
|
||||
serial.SerialBase.writeTimeout
|
||||
serial.serialutil.SerialBase.applySettingsDict
|
||||
serial.serialutil.SerialBase.flushInput
|
||||
serial.serialutil.SerialBase.flushOutput
|
||||
serial.serialutil.SerialBase.getCD
|
||||
serial.serialutil.SerialBase.getCTS
|
||||
serial.serialutil.SerialBase.getDSR
|
||||
serial.serialutil.SerialBase.getRI
|
||||
serial.serialutil.SerialBase.getSettingsDict
|
||||
serial.serialutil.SerialBase.inWaiting
|
||||
serial.serialutil.SerialBase.interCharTimeout
|
||||
serial.serialutil.SerialBase.isOpen
|
||||
serial.serialutil.SerialBase.sendBreak
|
||||
serial.serialutil.SerialBase.setDTR
|
||||
serial.serialutil.SerialBase.setPort
|
||||
serial.serialutil.SerialBase.setRTS
|
||||
serial.serialutil.SerialBase.writeTimeout
|
||||
|
||||
# Private aliases
|
||||
serial.serialposix.plat
|
||||
serial.tools.list_ports_posix.plat
|
||||
17
stubs/pyserial/@tests/stubtest_allowlist_darwin.txt
Normal file
17
stubs/pyserial/@tests/stubtest_allowlist_darwin.txt
Normal file
@@ -0,0 +1,17 @@
|
||||
# Error: failed to import
|
||||
# =======================
|
||||
serial.serialwin32 # Windows only
|
||||
serial.win32 # Windows only
|
||||
serial.tools.list_ports_linux # Linux only
|
||||
serial.tools.list_ports_windows # Windows only
|
||||
|
||||
# Error: is inconsistent
|
||||
# ======================
|
||||
# These are positional only argument in the stub because they inherit from io.RawIOBase
|
||||
# but at runtime they are normal arguments that don't have consistent names.
|
||||
serial.PosixPollSerial.read
|
||||
serial.VTIMESerial.read
|
||||
serial.serialposix.Serial.read
|
||||
serial.serialposix.Serial.write
|
||||
serial.serialposix.PosixPollSerial.read
|
||||
serial.serialposix.VTIMESerial.read
|
||||
17
stubs/pyserial/@tests/stubtest_allowlist_linux.txt
Normal file
17
stubs/pyserial/@tests/stubtest_allowlist_linux.txt
Normal file
@@ -0,0 +1,17 @@
|
||||
# Error: failed to import
|
||||
# =======================
|
||||
serial.serialwin32 # Windows only
|
||||
serial.win32 # Windows only
|
||||
serial.tools.list_ports_osx # Mac only
|
||||
serial.tools.list_ports_windows # Windows only
|
||||
|
||||
# Error: is inconsistent
|
||||
# ======================
|
||||
# These are positional only argument in the stub because they inherit from io.RawIOBase
|
||||
# but at runtime they are normal arguments that don't have consistent names.
|
||||
serial.PosixPollSerial.read
|
||||
serial.VTIMESerial.read
|
||||
serial.serialposix.Serial.read
|
||||
serial.serialposix.Serial.write
|
||||
serial.serialposix.PosixPollSerial.read
|
||||
serial.serialposix.VTIMESerial.read
|
||||
12
stubs/pyserial/@tests/stubtest_allowlist_win32.txt
Normal file
12
stubs/pyserial/@tests/stubtest_allowlist_win32.txt
Normal file
@@ -0,0 +1,12 @@
|
||||
# Error: failed to import
|
||||
# =======================
|
||||
serial.serialposix # Posix only
|
||||
serial.tools.list_ports_osx # Mac only
|
||||
serial.tools.list_ports_linux # Linux only
|
||||
|
||||
# Error: is inconsistent
|
||||
# ======================
|
||||
# These are positional only argument in the stub because they inherit from io.RawIOBase
|
||||
# but at runtime they are normal arguments that don't have consistent names.
|
||||
serial.serialwin32.Serial.read
|
||||
serial.serialwin32.Serial.write
|
||||
10
stubs/pyserial/METADATA.toml
Normal file
10
stubs/pyserial/METADATA.toml
Normal file
@@ -0,0 +1,10 @@
|
||||
version = "3.5.*"
|
||||
|
||||
[tool.stubtest]
|
||||
# Skip stubtest because it crashes with `SystemExit` when trying to import `serial.__main__`.
|
||||
# This has been fixed in https://github.com/python/mypy/pull/14284.
|
||||
# TODO: Remove skip once mypy 1.0 is released with the fix.
|
||||
skip = true
|
||||
ignore_missing_stub = false
|
||||
platforms = ["linux", "win32", "darwin"]
|
||||
extras = ["cp2110"]
|
||||
30
stubs/pyserial/serial/__init__.pyi
Normal file
30
stubs/pyserial/serial/__init__.pyi
Normal file
@@ -0,0 +1,30 @@
|
||||
import sys
|
||||
|
||||
from serial.serialutil import *
|
||||
|
||||
if sys.platform == "win32":
|
||||
from serial.serialwin32 import Serial as Serial
|
||||
else:
|
||||
from serial.serialposix import PosixPollSerial as PosixPollSerial, Serial as Serial, VTIMESerial as VTIMESerial
|
||||
# TODO: java? cli? These platforms raise flake8-pyi Y008. Should they be included with a noqa?
|
||||
|
||||
__version__: str
|
||||
VERSION: str
|
||||
protocol_handler_packages: list[str]
|
||||
|
||||
def serial_for_url(
|
||||
url: str | None,
|
||||
baudrate: int = ...,
|
||||
bytesize: int = ...,
|
||||
parity: str = ...,
|
||||
stopbits: float = ...,
|
||||
timeout: float | None = ...,
|
||||
xonxoff: bool = ...,
|
||||
rtscts: bool = ...,
|
||||
write_timeout: float | None = ...,
|
||||
dsrdtr: bool = ...,
|
||||
inter_byte_timeout: float | None = ...,
|
||||
exclusive: float | None = ...,
|
||||
*,
|
||||
do_not_open: bool = ...,
|
||||
) -> Serial: ...
|
||||
1
stubs/pyserial/serial/__main__.pyi
Normal file
1
stubs/pyserial/serial/__main__.pyi
Normal file
@@ -0,0 +1 @@
|
||||
from serial.tools import miniterm as miniterm
|
||||
184
stubs/pyserial/serial/rfc2217.pyi
Normal file
184
stubs/pyserial/serial/rfc2217.pyi
Normal file
@@ -0,0 +1,184 @@
|
||||
import logging
|
||||
from collections.abc import Callable, Generator
|
||||
from typing import Any
|
||||
|
||||
from serial.serialutil import SerialBase
|
||||
|
||||
LOGGER_LEVELS: dict[str, int]
|
||||
SE: bytes
|
||||
NOP: bytes
|
||||
DM: bytes
|
||||
BRK: bytes
|
||||
IP: bytes
|
||||
AO: bytes
|
||||
AYT: bytes
|
||||
EC: bytes
|
||||
EL: bytes
|
||||
GA: bytes
|
||||
SB: bytes
|
||||
WILL: bytes
|
||||
WONT: bytes
|
||||
DO: bytes
|
||||
DONT: bytes
|
||||
IAC: bytes
|
||||
IAC_DOUBLED: bytes
|
||||
BINARY: bytes
|
||||
ECHO: bytes
|
||||
SGA: bytes
|
||||
COM_PORT_OPTION: bytes
|
||||
SET_BAUDRATE: bytes
|
||||
SET_DATASIZE: bytes
|
||||
SET_PARITY: bytes
|
||||
SET_STOPSIZE: bytes
|
||||
SET_CONTROL: bytes
|
||||
NOTIFY_LINESTATE: bytes
|
||||
NOTIFY_MODEMSTATE: bytes
|
||||
FLOWCONTROL_SUSPEND: bytes
|
||||
FLOWCONTROL_RESUME: bytes
|
||||
SET_LINESTATE_MASK: bytes
|
||||
SET_MODEMSTATE_MASK: bytes
|
||||
PURGE_DATA: bytes
|
||||
SERVER_SET_BAUDRATE: bytes
|
||||
SERVER_SET_DATASIZE: bytes
|
||||
SERVER_SET_PARITY: bytes
|
||||
SERVER_SET_STOPSIZE: bytes
|
||||
SERVER_SET_CONTROL: bytes
|
||||
SERVER_NOTIFY_LINESTATE: bytes
|
||||
SERVER_NOTIFY_MODEMSTATE: bytes
|
||||
SERVER_FLOWCONTROL_SUSPEND: bytes
|
||||
SERVER_FLOWCONTROL_RESUME: bytes
|
||||
SERVER_SET_LINESTATE_MASK: bytes
|
||||
SERVER_SET_MODEMSTATE_MASK: bytes
|
||||
SERVER_PURGE_DATA: bytes
|
||||
RFC2217_ANSWER_MAP: dict[bytes, bytes]
|
||||
SET_CONTROL_REQ_FLOW_SETTING: bytes
|
||||
SET_CONTROL_USE_NO_FLOW_CONTROL: bytes
|
||||
SET_CONTROL_USE_SW_FLOW_CONTROL: bytes
|
||||
SET_CONTROL_USE_HW_FLOW_CONTROL: bytes
|
||||
SET_CONTROL_REQ_BREAK_STATE: bytes
|
||||
SET_CONTROL_BREAK_ON: bytes
|
||||
SET_CONTROL_BREAK_OFF: bytes
|
||||
SET_CONTROL_REQ_DTR: bytes
|
||||
SET_CONTROL_DTR_ON: bytes
|
||||
SET_CONTROL_DTR_OFF: bytes
|
||||
SET_CONTROL_REQ_RTS: bytes
|
||||
SET_CONTROL_RTS_ON: bytes
|
||||
SET_CONTROL_RTS_OFF: bytes
|
||||
SET_CONTROL_REQ_FLOW_SETTING_IN: bytes
|
||||
SET_CONTROL_USE_NO_FLOW_CONTROL_IN: bytes
|
||||
SET_CONTROL_USE_SW_FLOW_CONTOL_IN: bytes
|
||||
SET_CONTROL_USE_HW_FLOW_CONTOL_IN: bytes
|
||||
SET_CONTROL_USE_DCD_FLOW_CONTROL: bytes
|
||||
SET_CONTROL_USE_DTR_FLOW_CONTROL: bytes
|
||||
SET_CONTROL_USE_DSR_FLOW_CONTROL: bytes
|
||||
LINESTATE_MASK_TIMEOUT: int
|
||||
LINESTATE_MASK_SHIFTREG_EMPTY: int
|
||||
LINESTATE_MASK_TRANSREG_EMPTY: int
|
||||
LINESTATE_MASK_BREAK_DETECT: int
|
||||
LINESTATE_MASK_FRAMING_ERROR: int
|
||||
LINESTATE_MASK_PARTIY_ERROR: int
|
||||
LINESTATE_MASK_OVERRUN_ERROR: int
|
||||
LINESTATE_MASK_DATA_READY: int
|
||||
MODEMSTATE_MASK_CD: int
|
||||
MODEMSTATE_MASK_RI: int
|
||||
MODEMSTATE_MASK_DSR: int
|
||||
MODEMSTATE_MASK_CTS: int
|
||||
MODEMSTATE_MASK_CD_CHANGE: int
|
||||
MODEMSTATE_MASK_RI_CHANGE: int
|
||||
MODEMSTATE_MASK_DSR_CHANGE: int
|
||||
MODEMSTATE_MASK_CTS_CHANGE: int
|
||||
PURGE_RECEIVE_BUFFER: bytes
|
||||
PURGE_TRANSMIT_BUFFER: bytes
|
||||
PURGE_BOTH_BUFFERS: bytes
|
||||
RFC2217_PARITY_MAP: dict[str, int]
|
||||
RFC2217_REVERSE_PARITY_MAP: dict[int, str]
|
||||
RFC2217_STOPBIT_MAP: dict[int | float, int]
|
||||
RFC2217_REVERSE_STOPBIT_MAP: dict[int, int | float]
|
||||
M_NORMAL: int
|
||||
M_IAC_SEEN: int
|
||||
M_NEGOTIATE: int
|
||||
REQUESTED: str
|
||||
ACTIVE: str
|
||||
INACTIVE: str
|
||||
REALLY_INACTIVE: str
|
||||
|
||||
class TelnetOption:
|
||||
connection: Serial
|
||||
name: str
|
||||
option: bytes
|
||||
send_yes: bytes
|
||||
send_no: bytes
|
||||
ack_yes: bytes
|
||||
ack_no: bytes
|
||||
state: str
|
||||
active: bool
|
||||
activation_callback: Callable[[], Any]
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
connection: Serial,
|
||||
name: str,
|
||||
option: bytes,
|
||||
send_yes: bytes,
|
||||
send_no: bytes,
|
||||
ack_yes: bytes,
|
||||
ack_no: bytes,
|
||||
initial_state: str,
|
||||
activation_callback: Callable[[], Any] | None = ...,
|
||||
) -> None: ...
|
||||
def process_incoming(self, command: bytes) -> None: ...
|
||||
|
||||
class TelnetSubnegotiation:
|
||||
connection: Serial
|
||||
name: str
|
||||
option: bytes
|
||||
value: bytes | None
|
||||
ack_option: bytes
|
||||
state: str
|
||||
def __init__(self, connection: Serial, name: str, option: bytes, ack_option: bytes | None = ...) -> None: ...
|
||||
def set(self, value: bytes) -> None: ...
|
||||
def is_ready(self) -> bool: ...
|
||||
@property
|
||||
def active(self) -> bool: ...
|
||||
def wait(self, timeout: float = ...) -> None: ...
|
||||
def check_answer(self, suboption: bytes) -> None: ...
|
||||
|
||||
class Serial(SerialBase):
|
||||
logger: logging.Logger | None
|
||||
def open(self) -> None: ...
|
||||
def from_url(self, url: str) -> tuple[str, int]: ...
|
||||
@property
|
||||
def in_waiting(self) -> int: ...
|
||||
def reset_input_buffer(self) -> None: ...
|
||||
def reset_output_buffer(self) -> None: ...
|
||||
@property
|
||||
def cts(self) -> bool: ...
|
||||
@property
|
||||
def dsr(self) -> bool: ...
|
||||
@property
|
||||
def ri(self) -> bool: ...
|
||||
@property
|
||||
def cd(self) -> bool: ...
|
||||
def telnet_send_option(self, action: bytes, option: bytes) -> None: ...
|
||||
def rfc2217_send_subnegotiation(self, option: bytes, value: bytes = ...) -> None: ...
|
||||
def rfc2217_send_purge(self, value: bytes) -> None: ...
|
||||
def rfc2217_set_control(self, value: bytes) -> None: ...
|
||||
def rfc2217_flow_server_ready(self) -> None: ...
|
||||
def get_modem_state(self) -> int: ...
|
||||
|
||||
class PortManager:
|
||||
serial: Serial
|
||||
connection: Serial
|
||||
logger: logging.Logger | None
|
||||
mode: int
|
||||
suboption: bytes | None
|
||||
telnet_command: bytes | None
|
||||
modemstate_mask: int
|
||||
last_modemstate: int | None
|
||||
linstate_mask: int
|
||||
def __init__(self, serial_port: Serial, connection: Serial, logger: logging.Logger | None = ...) -> None: ...
|
||||
def telnet_send_option(self, action: bytes, option: bytes) -> None: ...
|
||||
def rfc2217_send_subnegotiation(self, option: bytes, value: bytes = ...) -> None: ...
|
||||
def check_modem_lines(self, force_notification: bool = ...) -> None: ...
|
||||
def escape(self, data: bytes) -> Generator[bytes, None, None]: ...
|
||||
def filter(self, data: bytes) -> Generator[bytes, None, None]: ...
|
||||
18
stubs/pyserial/serial/rs485.pyi
Normal file
18
stubs/pyserial/serial/rs485.pyi
Normal file
@@ -0,0 +1,18 @@
|
||||
import serial
|
||||
|
||||
class RS485Settings:
|
||||
rts_level_for_tx: bool
|
||||
rts_level_for_rx: bool
|
||||
loopback: bool
|
||||
delay_before_tx: float | None
|
||||
delay_before_rx: float | None
|
||||
def __init__(
|
||||
self,
|
||||
rts_level_for_tx: bool = ...,
|
||||
rts_level_for_rx: bool = ...,
|
||||
loopback: bool = ...,
|
||||
delay_before_tx: float | None = ...,
|
||||
delay_before_rx: float | None = ...,
|
||||
) -> None: ...
|
||||
|
||||
class RS485(serial.Serial): ...
|
||||
22
stubs/pyserial/serial/serialcli.pyi
Normal file
22
stubs/pyserial/serial/serialcli.pyi
Normal file
@@ -0,0 +1,22 @@
|
||||
from typing import Any
|
||||
|
||||
from serial.serialutil import *
|
||||
|
||||
sab: Any # IronPython object
|
||||
|
||||
def as_byte_array(string: bytes) -> Any: ... # IronPython object
|
||||
|
||||
class Serial(SerialBase):
|
||||
def open(self) -> None: ...
|
||||
@property
|
||||
def in_waiting(self) -> int: ...
|
||||
def reset_input_buffer(self) -> None: ...
|
||||
def reset_output_buffer(self) -> None: ...
|
||||
@property
|
||||
def cts(self) -> bool: ...
|
||||
@property
|
||||
def dsr(self) -> bool: ...
|
||||
@property
|
||||
def ri(self) -> bool: ...
|
||||
@property
|
||||
def cd(self) -> bool: ...
|
||||
27
stubs/pyserial/serial/serialjava.pyi
Normal file
27
stubs/pyserial/serial/serialjava.pyi
Normal file
@@ -0,0 +1,27 @@
|
||||
from collections.abc import Iterable
|
||||
from typing import Any
|
||||
|
||||
from serial.serialutil import *
|
||||
|
||||
def my_import(name: str) -> Any: ... # Java object
|
||||
def detect_java_comm(names: Iterable[str]) -> Any: ... # Java object
|
||||
|
||||
comm: Any # Java object
|
||||
|
||||
def device(portnumber: int) -> str: ...
|
||||
|
||||
class Serial(SerialBase):
|
||||
sPort: Any # Java object
|
||||
def open(self) -> None: ...
|
||||
@property
|
||||
def in_waiting(self) -> int: ...
|
||||
def reset_input_buffer(self) -> None: ...
|
||||
def reset_output_buffer(self) -> None: ...
|
||||
@property
|
||||
def cts(self) -> bool: ...
|
||||
@property
|
||||
def dsr(self) -> bool: ...
|
||||
@property
|
||||
def ri(self) -> bool: ...
|
||||
@property
|
||||
def cd(self) -> bool: ...
|
||||
90
stubs/pyserial/serial/serialposix.pyi
Normal file
90
stubs/pyserial/serial/serialposix.pyi
Normal file
@@ -0,0 +1,90 @@
|
||||
import sys
|
||||
from typing_extensions import Never
|
||||
|
||||
from serial.serialutil import SerialBase
|
||||
|
||||
class PlatformSpecificBase:
|
||||
BAUDRATE_CONSTANTS: dict[int, int]
|
||||
def set_low_latency_mode(self, low_latency_settings: bool) -> None: ...
|
||||
|
||||
CMSPAR: int
|
||||
if sys.platform == "linux":
|
||||
TCGETS2: int
|
||||
TCSETS2: int
|
||||
BOTHER: int
|
||||
TIOCGRS485: int
|
||||
TIOCSRS485: int
|
||||
SER_RS485_ENABLED: int
|
||||
SER_RS485_RTS_ON_SEND: int
|
||||
SER_RS485_RTS_AFTER_SEND: int
|
||||
SER_RS485_RX_DURING_TX: int
|
||||
|
||||
class PlatformSpecific(PlatformSpecificBase): ...
|
||||
|
||||
elif sys.platform == "cygwin":
|
||||
class PlatformSpecific(PlatformSpecificBase): ...
|
||||
|
||||
elif sys.platform == "darwin":
|
||||
IOSSIOSPEED: int
|
||||
|
||||
class PlatformSpecific(PlatformSpecificBase):
|
||||
osx_version: list[str]
|
||||
TIOCSBRK: int
|
||||
TIOCCBRK: int
|
||||
|
||||
else:
|
||||
class PlatformSpecific(PlatformSpecificBase): ...
|
||||
|
||||
TIOCMGET: int
|
||||
TIOCMBIS: int
|
||||
TIOCMBIC: int
|
||||
TIOCMSET: int
|
||||
TIOCM_DTR: int
|
||||
TIOCM_RTS: int
|
||||
TIOCM_CTS: int
|
||||
TIOCM_CAR: int
|
||||
TIOCM_RNG: int
|
||||
TIOCM_DSR: int
|
||||
TIOCM_CD: int
|
||||
TIOCM_RI: int
|
||||
TIOCINQ: int
|
||||
TIOCOUTQ: int
|
||||
TIOCM_zero_str: bytes
|
||||
TIOCM_RTS_str: bytes
|
||||
TIOCM_DTR_str: bytes
|
||||
TIOCSBRK: int
|
||||
TIOCCBRK: int
|
||||
|
||||
class Serial(SerialBase, PlatformSpecific):
|
||||
fd: int | None
|
||||
pipe_abort_read_w: int | None
|
||||
pipe_abort_read_r: int | None
|
||||
pipe_abort_write_w: int | None
|
||||
pipe_abort_write_r: int | None
|
||||
def open(self) -> None: ...
|
||||
@property
|
||||
def in_waiting(self) -> int: ...
|
||||
def cancel_read(self) -> None: ...
|
||||
def cancel_write(self) -> None: ...
|
||||
def reset_input_buffer(self) -> None: ...
|
||||
def reset_output_buffer(self) -> None: ...
|
||||
def send_break(self, duration: float = ...) -> None: ...
|
||||
@property
|
||||
def cts(self) -> bool: ...
|
||||
@property
|
||||
def dsr(self) -> bool: ...
|
||||
@property
|
||||
def ri(self) -> bool: ...
|
||||
@property
|
||||
def cd(self) -> bool: ...
|
||||
@property
|
||||
def out_waiting(self) -> int: ...
|
||||
def set_input_flow_control(self, enable: bool = ...) -> None: ...
|
||||
def set_output_flow_control(self, enable: bool = ...) -> None: ...
|
||||
def nonblocking(self) -> None: ...
|
||||
|
||||
class PosixPollSerial(Serial): ...
|
||||
|
||||
class VTIMESerial(Serial):
|
||||
@property
|
||||
def cancel_read(self) -> Never: ...
|
||||
136
stubs/pyserial/serial/serialutil.pyi
Normal file
136
stubs/pyserial/serial/serialutil.pyi
Normal file
@@ -0,0 +1,136 @@
|
||||
import io
|
||||
from collections.abc import Callable, Generator
|
||||
from typing import Any
|
||||
from typing_extensions import Final
|
||||
|
||||
from serial.rs485 import RS485Settings
|
||||
|
||||
XON: Final = b"\x11"
|
||||
XOFF: Final = b"\x13"
|
||||
CR: Final = b"\r"
|
||||
LF: Final = b"\n"
|
||||
PARITY_NONE: Final = "N"
|
||||
PARITY_EVEN: Final = "E"
|
||||
PARITY_ODD: Final = "O"
|
||||
PARITY_MARK: Final = "M"
|
||||
PARITY_SPACE: Final = "S"
|
||||
STOPBITS_ONE: Final = 1
|
||||
STOPBITS_ONE_POINT_FIVE: float
|
||||
STOPBITS_TWO: Final = 2
|
||||
FIVEBITS: Final = 5
|
||||
SIXBITS: Final = 6
|
||||
SEVENBITS: Final = 7
|
||||
EIGHTBITS: Final = 8
|
||||
PARITY_NAMES: dict[str, str]
|
||||
|
||||
class SerialException(OSError): ...
|
||||
class SerialTimeoutException(SerialException): ...
|
||||
|
||||
class PortNotOpenError(SerialException):
|
||||
def __init__(self) -> None: ...
|
||||
|
||||
class Timeout:
|
||||
TIME: Callable[[], float]
|
||||
is_infinite: bool
|
||||
is_non_blocking: bool
|
||||
duration: float
|
||||
target_time: float
|
||||
def __init__(self, duration: float) -> None: ...
|
||||
def expired(self) -> bool: ...
|
||||
def time_left(self) -> float: ...
|
||||
def restart(self, duration: float) -> None: ...
|
||||
|
||||
class SerialBase(io.RawIOBase):
|
||||
BAUDRATES: tuple[int, ...]
|
||||
BYTESIZES: tuple[int, ...]
|
||||
PARITIES: tuple[str, ...]
|
||||
STOPBITS: tuple[int, float, int]
|
||||
is_open: bool
|
||||
portstr: str | None
|
||||
name: str | None
|
||||
def __init__(
|
||||
self,
|
||||
port: str | None = ...,
|
||||
baudrate: int = ...,
|
||||
bytesize: int = ...,
|
||||
parity: str = ...,
|
||||
stopbits: float = ...,
|
||||
timeout: float | None = ...,
|
||||
xonxoff: bool = ...,
|
||||
rtscts: bool = ...,
|
||||
write_timeout: float | None = ...,
|
||||
dsrdtr: bool = ...,
|
||||
inter_byte_timeout: float | None = ...,
|
||||
exclusive: float | None = ...,
|
||||
) -> None: ...
|
||||
def read(self, __size: int = ...) -> bytes: ... # same as io.RawIOBase.read but always returns bytes
|
||||
@property
|
||||
def port(self) -> str | None: ...
|
||||
@port.setter
|
||||
def port(self, port: str | None) -> None: ...
|
||||
@property
|
||||
def baudrate(self) -> int: ...
|
||||
@baudrate.setter
|
||||
def baudrate(self, baudrate: int) -> None: ...
|
||||
@property
|
||||
def bytesize(self) -> int: ...
|
||||
@bytesize.setter
|
||||
def bytesize(self, bytesize: int) -> None: ...
|
||||
@property
|
||||
def exclusive(self) -> bool | None: ...
|
||||
@exclusive.setter
|
||||
def exclusive(self, exclusive: bool | None) -> None: ...
|
||||
@property
|
||||
def parity(self) -> str: ...
|
||||
@parity.setter
|
||||
def parity(self, parity: str) -> None: ...
|
||||
@property
|
||||
def stopbits(self) -> float: ...
|
||||
@stopbits.setter
|
||||
def stopbits(self, stopbits: float) -> None: ...
|
||||
@property
|
||||
def timeout(self) -> float | None: ...
|
||||
@timeout.setter
|
||||
def timeout(self, timeout: float | None) -> None: ...
|
||||
@property
|
||||
def write_timeout(self) -> float | None: ...
|
||||
@write_timeout.setter
|
||||
def write_timeout(self, timeout: float | None) -> None: ...
|
||||
@property
|
||||
def inter_byte_timeout(self) -> float | None: ...
|
||||
@inter_byte_timeout.setter
|
||||
def inter_byte_timeout(self, ic_timeout: float | None) -> None: ...
|
||||
@property
|
||||
def xonxoff(self) -> bool: ...
|
||||
@xonxoff.setter
|
||||
def xonxoff(self, xonxoff: bool) -> None: ...
|
||||
@property
|
||||
def rtscts(self) -> bool: ...
|
||||
@rtscts.setter
|
||||
def rtscts(self, rtscts: bool) -> None: ...
|
||||
@property
|
||||
def dsrdtr(self) -> bool: ...
|
||||
@dsrdtr.setter
|
||||
def dsrdtr(self, dsrdtr: bool | None = ...) -> None: ...
|
||||
@property
|
||||
def rts(self) -> bool: ...
|
||||
@rts.setter
|
||||
def rts(self, value: bool) -> None: ...
|
||||
@property
|
||||
def dtr(self) -> bool: ...
|
||||
@dtr.setter
|
||||
def dtr(self, value: bool) -> None: ...
|
||||
@property
|
||||
def break_condition(self) -> bool: ...
|
||||
@break_condition.setter
|
||||
def break_condition(self, value: bool) -> None: ...
|
||||
@property
|
||||
def rs485_mode(self) -> RS485Settings | None: ...
|
||||
@rs485_mode.setter
|
||||
def rs485_mode(self, rs485_settings: RS485Settings | None) -> None: ...
|
||||
def get_settings(self) -> dict[str, Any]: ...
|
||||
def apply_settings(self, d: dict[str, Any]) -> None: ...
|
||||
def send_break(self, duration: float = ...) -> None: ...
|
||||
def read_all(self) -> bytes | None: ...
|
||||
def read_until(self, expected: bytes = ..., size: int | None = ...) -> bytes: ...
|
||||
def iread_until(self, expected: bytes = ..., size: int | None = ...) -> Generator[bytes, None, None]: ...
|
||||
22
stubs/pyserial/serial/serialwin32.pyi
Normal file
22
stubs/pyserial/serial/serialwin32.pyi
Normal file
@@ -0,0 +1,22 @@
|
||||
from serial.serialutil import SerialBase
|
||||
|
||||
class Serial(SerialBase):
|
||||
def open(self) -> None: ...
|
||||
@property
|
||||
def in_waiting(self) -> int: ...
|
||||
def reset_input_buffer(self) -> None: ...
|
||||
def reset_output_buffer(self) -> None: ...
|
||||
@property
|
||||
def cts(self) -> bool: ...
|
||||
@property
|
||||
def dsr(self) -> bool: ...
|
||||
@property
|
||||
def ri(self) -> bool: ...
|
||||
@property
|
||||
def cd(self) -> bool: ...
|
||||
def set_buffer_size(self, rx_size: int = ..., tx_size: int | None = ...) -> None: ...
|
||||
def set_output_flow_control(self, enable: bool = ...) -> None: ...
|
||||
@property
|
||||
def out_waiting(self) -> int: ...
|
||||
def cancel_read(self) -> None: ...
|
||||
def cancel_write(self) -> None: ...
|
||||
44
stubs/pyserial/serial/threaded/__init__.pyi
Normal file
44
stubs/pyserial/serial/threaded/__init__.pyi
Normal file
@@ -0,0 +1,44 @@
|
||||
import threading
|
||||
from _typeshed import ReadableBuffer, Self
|
||||
from collections.abc import Callable
|
||||
|
||||
from serial import Serial
|
||||
|
||||
class Protocol:
|
||||
def connection_made(self, transport: ReaderThread) -> None: ...
|
||||
def data_received(self, data: bytes) -> None: ...
|
||||
def connection_lost(self, exc: BaseException | None) -> None: ...
|
||||
|
||||
class Packetizer(Protocol):
|
||||
TERMINATOR: bytes
|
||||
buffer: bytearray
|
||||
transport: ReaderThread | None
|
||||
def handle_packet(self, packet: bytes) -> None: ...
|
||||
|
||||
class FramedPacket(Protocol):
|
||||
START: bytes
|
||||
STOP: bytes
|
||||
packet: bytearray
|
||||
in_packet: bool
|
||||
transport: ReaderThread | None
|
||||
def handle_packet(self, packet: bytes) -> None: ...
|
||||
def handle_out_of_packet_data(self, data: bytes) -> None: ...
|
||||
|
||||
class LineReader(Packetizer):
|
||||
ENCODING: str
|
||||
UNICODE_HANDLING: str
|
||||
def handle_line(self, line: str) -> None: ...
|
||||
def write_line(self, text: str) -> None: ...
|
||||
|
||||
class ReaderThread(threading.Thread):
|
||||
serial: Serial
|
||||
protocol_factory: Callable[[], Protocol]
|
||||
alive: bool
|
||||
protocol: Protocol
|
||||
def __init__(self, serial_instance: Serial, protocol_factory: Callable[[], Protocol]) -> None: ...
|
||||
def stop(self) -> None: ...
|
||||
def write(self, data: ReadableBuffer) -> int: ...
|
||||
def close(self) -> None: ...
|
||||
def connect(self: Self) -> tuple[Self, Protocol]: ...
|
||||
def __enter__(self) -> Protocol: ...
|
||||
def __exit__(self, __exc_type: object, __exc_val: object, __exc_tb: object) -> None: ...
|
||||
0
stubs/pyserial/serial/tools/__init__.pyi
Normal file
0
stubs/pyserial/serial/tools/__init__.pyi
Normal file
23
stubs/pyserial/serial/tools/hexlify_codec.pyi
Normal file
23
stubs/pyserial/serial/tools/hexlify_codec.pyi
Normal file
@@ -0,0 +1,23 @@
|
||||
import codecs
|
||||
from _typeshed import ReadableBuffer
|
||||
|
||||
HEXDIGITS: str
|
||||
|
||||
def hex_encode(data: str, errors: str = ...) -> tuple[bytes, int]: ...
|
||||
def hex_decode(data: bytes, errors: str = ...) -> tuple[str, int]: ...
|
||||
|
||||
class Codec(codecs.Codec):
|
||||
def encode(self, data: str, errors: str = ...) -> tuple[bytes, int]: ...
|
||||
def decode(self, data: bytes, errors: str = ...) -> tuple[str, int]: ...
|
||||
|
||||
class IncrementalEncoder(codecs.IncrementalEncoder):
|
||||
state: int
|
||||
def encode(self, data: str, final: bool = ...) -> bytes: ...
|
||||
|
||||
class IncrementalDecoder(codecs.IncrementalDecoder):
|
||||
def decode(self, data: ReadableBuffer, final: bool = ...) -> str: ...
|
||||
|
||||
class StreamWriter(Codec, codecs.StreamWriter): ...
|
||||
class StreamReader(Codec, codecs.StreamReader): ...
|
||||
|
||||
def getregentry() -> codecs.CodecInfo: ...
|
||||
11
stubs/pyserial/serial/tools/list_ports.pyi
Normal file
11
stubs/pyserial/serial/tools/list_ports.pyi
Normal file
@@ -0,0 +1,11 @@
|
||||
import re
|
||||
import sys
|
||||
from collections.abc import Generator
|
||||
|
||||
if sys.platform == "win32":
|
||||
from serial.tools.list_ports_windows import comports as comports
|
||||
else:
|
||||
from serial.tools.list_ports_posix import comports as comports
|
||||
|
||||
def grep(regexp: str | re.Pattern[str], include_links: bool = ...) -> Generator[tuple[str, str, str], None, None]: ...
|
||||
def main() -> None: ...
|
||||
32
stubs/pyserial/serial/tools/list_ports_common.pyi
Normal file
32
stubs/pyserial/serial/tools/list_ports_common.pyi
Normal file
@@ -0,0 +1,32 @@
|
||||
from collections.abc import Collection
|
||||
from typing import Any
|
||||
|
||||
def numsplit(text: str) -> list[str | int]: ...
|
||||
|
||||
class ListPortInfo:
|
||||
device: str
|
||||
name: str
|
||||
description: str
|
||||
hwid: str
|
||||
# USB specific data: the attributes below are specific to USB devices only and should be marked
|
||||
# as Optional. Since the majority of the serial devices nowadays are USB devices, typing them
|
||||
# as Optional will be unnecessarily annoying. We type them with as a Union of their original
|
||||
# type and Any so that obvious typing errors like ListPortInfo.pid + "str" are flagged.
|
||||
# As desired, this will cause a false negative if the value is ever None, but may also cause
|
||||
# other false negatives from the Any proliferating.
|
||||
# Original discussion at https://github.com/python/typeshed/pull/9347#issuecomment-1358245865.
|
||||
vid: int | Any
|
||||
pid: int | Any
|
||||
serial_number: str | Any
|
||||
location: str | Any
|
||||
manufacturer: str | Any
|
||||
product: str | Any
|
||||
interface: str | Any
|
||||
def __init__(self, device: str, skip_link_detection: bool = ...) -> None: ...
|
||||
def usb_description(self) -> str: ...
|
||||
def usb_info(self) -> str: ...
|
||||
def apply_usb_info(self) -> None: ...
|
||||
def __lt__(self, other: ListPortInfo) -> bool: ...
|
||||
def __getitem__(self, index: int) -> str: ...
|
||||
|
||||
def list_links(devices: Collection[str]) -> list[str]: ...
|
||||
14
stubs/pyserial/serial/tools/list_ports_linux.pyi
Normal file
14
stubs/pyserial/serial/tools/list_ports_linux.pyi
Normal file
@@ -0,0 +1,14 @@
|
||||
import sys
|
||||
|
||||
from serial.tools.list_ports_common import ListPortInfo
|
||||
|
||||
if sys.platform == "linux":
|
||||
class SysFS(ListPortInfo):
|
||||
usb_device_path: str | None
|
||||
device_path: str | None
|
||||
subsystem: str | None
|
||||
usb_interface_path: str | None
|
||||
def __init__(self, device: str) -> None: ...
|
||||
def read_line(self, *args: str) -> str | None: ...
|
||||
|
||||
def comports(include_links: bool = ...) -> list[SysFS]: ...
|
||||
36
stubs/pyserial/serial/tools/list_ports_osx.pyi
Normal file
36
stubs/pyserial/serial/tools/list_ports_osx.pyi
Normal file
@@ -0,0 +1,36 @@
|
||||
import ctypes
|
||||
import sys
|
||||
|
||||
from serial.tools.list_ports_common import ListPortInfo
|
||||
|
||||
if sys.platform == "darwin":
|
||||
iokit: ctypes.CDLL
|
||||
cf: ctypes.CDLL
|
||||
kIOMasterPortDefault: int
|
||||
kCFAllocatorDefault: ctypes.c_void_p
|
||||
kCFStringEncodingMacRoman: int
|
||||
kCFStringEncodingUTF8: int
|
||||
kUSBVendorString: str
|
||||
kUSBSerialNumberString: str
|
||||
io_name_size: int
|
||||
KERN_SUCCESS: int
|
||||
kern_return_t = ctypes.c_int
|
||||
kCFNumberSInt8Type: int
|
||||
kCFNumberSInt16Type: int
|
||||
kCFNumberSInt32Type: int
|
||||
kCFNumberSInt64Type: int
|
||||
|
||||
def get_string_property(device_type: ctypes._CData, property: str) -> str | None: ...
|
||||
def get_int_property(device_type: ctypes._CData, property: str, cf_number_type: int) -> int | None: ...
|
||||
def IORegistryEntryGetName(device: ctypes._CData) -> str | None: ...
|
||||
def IOObjectGetClass(device: ctypes._CData) -> bytes: ...
|
||||
def GetParentDeviceByType(device: ctypes._CData, parent_type: str) -> ctypes._CData | None: ...
|
||||
def GetIOServicesByType(service_type: str) -> list[ctypes._CData]: ...
|
||||
def location_to_string(locationID: int) -> str: ...
|
||||
|
||||
# `SuitableSerialInterface` has required attributes `id: int` and `name: str` but they are not defined on the class
|
||||
class SuitableSerialInterface: ...
|
||||
|
||||
def scan_interfaces() -> list[SuitableSerialInterface]: ...
|
||||
def search_for_locationID_in_interfaces(serial_interfaces: list[SuitableSerialInterface], locationID: int) -> str | None: ...
|
||||
def comports(include_links: bool = ...) -> list[ListPortInfo]: ...
|
||||
11
stubs/pyserial/serial/tools/list_ports_posix.pyi
Normal file
11
stubs/pyserial/serial/tools/list_ports_posix.pyi
Normal file
@@ -0,0 +1,11 @@
|
||||
import sys
|
||||
|
||||
from serial.tools.list_ports_common import ListPortInfo
|
||||
|
||||
if sys.platform != "win32":
|
||||
if sys.platform == "linux":
|
||||
from serial.tools.list_ports_linux import comports as comports
|
||||
elif sys.platform == "darwin":
|
||||
from serial.tools.list_ports_osx import comports as comports
|
||||
else:
|
||||
def comports(include_links: bool = ...) -> list[ListPortInfo]: ...
|
||||
67
stubs/pyserial/serial/tools/list_ports_windows.pyi
Normal file
67
stubs/pyserial/serial/tools/list_ports_windows.pyi
Normal file
@@ -0,0 +1,67 @@
|
||||
import ctypes
|
||||
import sys
|
||||
from collections.abc import Generator
|
||||
from ctypes.wintypes import DWORD
|
||||
|
||||
from serial.tools.list_ports_common import ListPortInfo
|
||||
|
||||
if sys.platform == "win32":
|
||||
|
||||
def ValidHandle(
|
||||
value: type[ctypes._CData] | None, func: ctypes._FuncPointer, arguments: tuple[ctypes._CData, ...]
|
||||
) -> ctypes._CData: ...
|
||||
|
||||
NULL: int
|
||||
HDEVINFO = ctypes.c_void_p
|
||||
LPCTSTR = ctypes.c_wchar_p
|
||||
PCTSTR = ctypes.c_wchar_p
|
||||
PTSTR = ctypes.c_wchar_p
|
||||
LPDWORD: ctypes._Pointer[DWORD]
|
||||
PDWORD: ctypes._Pointer[DWORD]
|
||||
LPBYTE = ctypes.c_void_p
|
||||
PBYTE = ctypes.c_void_p
|
||||
ACCESS_MASK = DWORD
|
||||
REGSAM = ACCESS_MASK
|
||||
|
||||
class GUID(ctypes.Structure): ...
|
||||
class SP_DEVINFO_DATA(ctypes.Structure): ...
|
||||
PSP_DEVINFO_DATA: type[ctypes._Pointer[SP_DEVINFO_DATA]]
|
||||
PSP_DEVICE_INTERFACE_DETAIL_DATA = ctypes.c_void_p
|
||||
setupapi: ctypes.WinDLL
|
||||
SetupDiDestroyDeviceInfoList: ctypes._NamedFuncPointer
|
||||
SetupDiClassGuidsFromName: ctypes._NamedFuncPointer
|
||||
SetupDiEnumDeviceInfo: ctypes._NamedFuncPointer
|
||||
SetupDiGetClassDevs: ctypes._NamedFuncPointer
|
||||
SetupDiGetDeviceRegistryProperty: ctypes._NamedFuncPointer
|
||||
SetupDiGetDeviceInstanceId: ctypes._NamedFuncPointer
|
||||
SetupDiOpenDevRegKey: ctypes._NamedFuncPointer
|
||||
advapi32: ctypes.WinDLL
|
||||
RegCloseKey: ctypes._NamedFuncPointer
|
||||
RegQueryValueEx: ctypes._NamedFuncPointer
|
||||
cfgmgr32: ctypes.WinDLL
|
||||
CM_Get_Parent: ctypes._NamedFuncPointer
|
||||
CM_Get_Device_IDW: ctypes._NamedFuncPointer
|
||||
CM_MapCrToWin32Err: ctypes._NamedFuncPointer
|
||||
DIGCF_PRESENT: int
|
||||
DIGCF_DEVICEINTERFACE: int
|
||||
INVALID_HANDLE_VALUE: int
|
||||
ERROR_INSUFFICIENT_BUFFER: int
|
||||
ERROR_NOT_FOUND: int
|
||||
SPDRP_HARDWAREID: int
|
||||
SPDRP_FRIENDLYNAME: int
|
||||
SPDRP_LOCATION_PATHS: int
|
||||
SPDRP_MFG: int
|
||||
DICS_FLAG_GLOBAL: int
|
||||
DIREG_DEV: int
|
||||
KEY_READ: int
|
||||
MAX_USB_DEVICE_TREE_TRAVERSAL_DEPTH: int
|
||||
|
||||
def get_parent_serial_number(
|
||||
child_devinst: ctypes._CData,
|
||||
child_vid: int | None,
|
||||
child_pid: int | None,
|
||||
depth: int = ...,
|
||||
last_serial_number: str | None = ...,
|
||||
) -> str: ...
|
||||
def iterate_comports() -> Generator[ListPortInfo, None, None]: ...
|
||||
def comports(include_links: bool = ...) -> list[ListPortInfo]: ...
|
||||
111
stubs/pyserial/serial/tools/miniterm.pyi
Normal file
111
stubs/pyserial/serial/tools/miniterm.pyi
Normal file
@@ -0,0 +1,111 @@
|
||||
import codecs
|
||||
import sys
|
||||
import threading
|
||||
from _typeshed import Self
|
||||
from collections.abc import Iterable
|
||||
from typing import Any, BinaryIO, TextIO
|
||||
|
||||
from serial import Serial
|
||||
|
||||
def key_description(character: str) -> str: ...
|
||||
|
||||
class ConsoleBase:
|
||||
byte_output: BinaryIO
|
||||
output: codecs.StreamWriter | TextIO
|
||||
def __init__(self) -> None: ...
|
||||
def setup(self) -> None: ...
|
||||
def cleanup(self) -> None: ...
|
||||
def getkey(self) -> None: ...
|
||||
def write_bytes(self, byte_string: bytes) -> None: ...
|
||||
def write(self, text: str) -> None: ...
|
||||
def cancel(self) -> None: ...
|
||||
def __enter__(self: Self) -> Self: ...
|
||||
def __exit__(self, *args: object, **kwargs: object) -> None: ...
|
||||
|
||||
if sys.platform == "win32":
|
||||
class Out:
|
||||
fd: int
|
||||
def __init__(self, fd: int) -> None: ...
|
||||
def flush(self) -> None: ...
|
||||
def write(self, s: bytes) -> None: ...
|
||||
|
||||
class Console(ConsoleBase):
|
||||
fncodes: dict[str, str]
|
||||
navcodes: dict[str, str]
|
||||
|
||||
else:
|
||||
class Console(ConsoleBase):
|
||||
fd: int
|
||||
old: list[Any] # return type of termios.tcgetattr()
|
||||
enc_stdin: TextIO
|
||||
|
||||
class Transform:
|
||||
def rx(self, text: str) -> str: ...
|
||||
def tx(self, text: str) -> str: ...
|
||||
def echo(self, text: str) -> str: ...
|
||||
|
||||
class CRLF(Transform): ...
|
||||
class CR(Transform): ...
|
||||
class LF(Transform): ...
|
||||
|
||||
class NoTerminal(Transform):
|
||||
REPLACEMENT_MAP: dict[int, int]
|
||||
|
||||
class NoControls(NoTerminal):
|
||||
REPLACEMENT_MAP: dict[int, int]
|
||||
|
||||
class Printable(Transform): ...
|
||||
|
||||
class Colorize(Transform):
|
||||
input_color: str
|
||||
echo_color: str
|
||||
|
||||
class DebugIO(Transform): ...
|
||||
|
||||
EOL_TRANSFORMATIONS: dict[str, type[Transform]]
|
||||
TRANSFORMATIONS: dict[str, type[Transform]]
|
||||
|
||||
def ask_for_port() -> str: ...
|
||||
|
||||
class Miniterm:
|
||||
console: Console
|
||||
serial: Serial
|
||||
echo: bool
|
||||
raw: bool
|
||||
input_encoding: str
|
||||
output_encoding: str
|
||||
eol: str
|
||||
filters: Iterable[str]
|
||||
exit_character: str
|
||||
menu_character: str
|
||||
alive: bool | None
|
||||
receiver_thread: threading.Thread | None
|
||||
rx_decoder: codecs.IncrementalDecoder | None
|
||||
tx_decoder: codecs.IncrementalDecoder | None
|
||||
tx_encoder: codecs.IncrementalEncoder | None
|
||||
def __init__(self, serial_instance: Serial, echo: bool = ..., eol: str = ..., filters: Iterable[str] = ...) -> None: ...
|
||||
transmitter_thread: threading.Thread
|
||||
def start(self) -> None: ...
|
||||
def stop(self) -> None: ...
|
||||
def join(self, transmit_only: bool = ...) -> None: ...
|
||||
def close(self) -> None: ...
|
||||
tx_transformations: list[Transform]
|
||||
rx_transformations: list[Transform]
|
||||
def update_transformations(self) -> None: ...
|
||||
def set_rx_encoding(self, encoding: str, errors: str = ...) -> None: ...
|
||||
def set_tx_encoding(self, encoding: str, errors: str = ...) -> None: ...
|
||||
def dump_port_settings(self) -> None: ...
|
||||
def reader(self) -> None: ...
|
||||
def writer(self) -> None: ...
|
||||
def handle_menu_key(self, c: str) -> None: ...
|
||||
def upload_file(self) -> None: ...
|
||||
def change_filter(self) -> None: ...
|
||||
def change_encoding(self) -> None: ...
|
||||
def change_baudrate(self) -> None: ...
|
||||
def change_port(self) -> None: ...
|
||||
def suspend_port(self) -> None: ...
|
||||
def get_help_text(self) -> str: ...
|
||||
|
||||
def main(
|
||||
default_port: str | None = ..., default_baudrate: int = ..., default_rts: int | None = ..., default_dtr: int | None = ...
|
||||
) -> None: ...
|
||||
0
stubs/pyserial/serial/urlhandler/__init__.pyi
Normal file
0
stubs/pyserial/serial/urlhandler/__init__.pyi
Normal file
3
stubs/pyserial/serial/urlhandler/protocol_alt.pyi
Normal file
3
stubs/pyserial/serial/urlhandler/protocol_alt.pyi
Normal file
@@ -0,0 +1,3 @@
|
||||
from serial import Serial
|
||||
|
||||
def serial_class_for_url(url: str) -> tuple[str, Serial]: ...
|
||||
9
stubs/pyserial/serial/urlhandler/protocol_cp2110.pyi
Normal file
9
stubs/pyserial/serial/urlhandler/protocol_cp2110.pyi
Normal file
@@ -0,0 +1,9 @@
|
||||
from serial.serialutil import SerialBase
|
||||
|
||||
class Serial(SerialBase):
|
||||
def open(self) -> None: ...
|
||||
def from_url(self, url: str) -> bytes: ...
|
||||
@property
|
||||
def in_waiting(self) -> int: ...
|
||||
def reset_input_buffer(self) -> None: ...
|
||||
def reset_output_buffer(self) -> None: ...
|
||||
4
stubs/pyserial/serial/urlhandler/protocol_hwgrep.pyi
Normal file
4
stubs/pyserial/serial/urlhandler/protocol_hwgrep.pyi
Normal file
@@ -0,0 +1,4 @@
|
||||
import serial
|
||||
|
||||
class Serial(serial.Serial):
|
||||
def from_url(self, url: str) -> str: ...
|
||||
29
stubs/pyserial/serial/urlhandler/protocol_loop.pyi
Normal file
29
stubs/pyserial/serial/urlhandler/protocol_loop.pyi
Normal file
@@ -0,0 +1,29 @@
|
||||
import logging
|
||||
import queue
|
||||
|
||||
from serial.serialutil import SerialBase
|
||||
|
||||
LOGGER_LEVELS: dict[str, int]
|
||||
|
||||
class Serial(SerialBase):
|
||||
buffer_size: int
|
||||
queue: queue.Queue[bytes | None] | None
|
||||
logger: logging.Logger | None
|
||||
def open(self) -> None: ...
|
||||
def from_url(self, url: str) -> None: ...
|
||||
@property
|
||||
def in_waiting(self) -> int: ...
|
||||
def cancel_read(self) -> None: ...
|
||||
def cancel_write(self) -> None: ...
|
||||
def reset_input_buffer(self) -> None: ...
|
||||
def reset_output_buffer(self) -> None: ...
|
||||
@property
|
||||
def out_waiting(self) -> int: ...
|
||||
@property
|
||||
def cts(self) -> bool: ...
|
||||
@property
|
||||
def dsr(self) -> bool: ...
|
||||
@property
|
||||
def ri(self) -> bool: ...
|
||||
@property
|
||||
def cd(self) -> bool: ...
|
||||
1
stubs/pyserial/serial/urlhandler/protocol_rfc2217.pyi
Normal file
1
stubs/pyserial/serial/urlhandler/protocol_rfc2217.pyi
Normal file
@@ -0,0 +1 @@
|
||||
from serial.rfc2217 import Serial as Serial
|
||||
23
stubs/pyserial/serial/urlhandler/protocol_socket.pyi
Normal file
23
stubs/pyserial/serial/urlhandler/protocol_socket.pyi
Normal file
@@ -0,0 +1,23 @@
|
||||
import logging
|
||||
|
||||
from serial.serialutil import SerialBase
|
||||
|
||||
LOGGER_LEVELS: dict[str, int]
|
||||
POLL_TIMEOUT: float
|
||||
|
||||
class Serial(SerialBase):
|
||||
logger: logging.Logger | None
|
||||
def open(self) -> None: ...
|
||||
def from_url(self, url: str) -> tuple[str, int]: ...
|
||||
@property
|
||||
def in_waiting(self) -> int: ...
|
||||
def reset_input_buffer(self) -> None: ...
|
||||
def reset_output_buffer(self) -> None: ...
|
||||
@property
|
||||
def cts(self) -> bool: ...
|
||||
@property
|
||||
def dsr(self) -> bool: ...
|
||||
@property
|
||||
def ri(self) -> bool: ...
|
||||
@property
|
||||
def cd(self) -> bool: ...
|
||||
34
stubs/pyserial/serial/urlhandler/protocol_spy.pyi
Normal file
34
stubs/pyserial/serial/urlhandler/protocol_spy.pyi
Normal file
@@ -0,0 +1,34 @@
|
||||
from collections.abc import Generator
|
||||
from typing import TextIO
|
||||
|
||||
import serial
|
||||
|
||||
def sixteen(data: bytes) -> Generator[tuple[str, str] | tuple[None, None], None, None]: ...
|
||||
def hexdump(data: bytes) -> Generator[tuple[int, str], None, None]: ...
|
||||
|
||||
class _Formatter:
|
||||
def rx(self, data: bytes) -> None: ...
|
||||
def tx(self, data: bytes) -> None: ...
|
||||
def control(self, name: str, value: str) -> None: ...
|
||||
|
||||
class FormatRaw(_Formatter):
|
||||
output: TextIO
|
||||
color: bool
|
||||
rx_color: str
|
||||
tx_color: str
|
||||
def __init__(self, output: TextIO, color: bool) -> None: ...
|
||||
|
||||
class FormatHexdump(_Formatter):
|
||||
start_time: float
|
||||
output: TextIO
|
||||
color: bool
|
||||
rx_color: str
|
||||
tx_color: str
|
||||
control_color: str
|
||||
def __init__(self, output: TextIO, color: bool) -> None: ...
|
||||
def write_line(self, timestamp: float, label: str, value: str, value2: str = ...) -> None: ...
|
||||
|
||||
class Serial(serial.Serial):
|
||||
formatter: FormatRaw | FormatHexdump | None
|
||||
show_all: bool
|
||||
def from_url(self, url: str) -> str: ...
|
||||
99
stubs/pyserial/serial/win32.pyi
Normal file
99
stubs/pyserial/serial/win32.pyi
Normal file
@@ -0,0 +1,99 @@
|
||||
import sys
|
||||
from ctypes import Structure, Union, _NamedFuncPointer, _Pointer, c_int64, c_ulong, c_void_p
|
||||
from ctypes.wintypes import DWORD
|
||||
from typing_extensions import TypeAlias
|
||||
|
||||
if sys.platform == "win32":
|
||||
def is_64bit() -> bool: ...
|
||||
|
||||
ULONG_PTR: TypeAlias = c_int64 | c_ulong
|
||||
|
||||
class _SECURITY_ATTRIBUTES(Structure): ...
|
||||
LPSECURITY_ATTRIBUTES: type[_Pointer[_SECURITY_ATTRIBUTES]]
|
||||
CreateEvent: _NamedFuncPointer
|
||||
CreateFile: _NamedFuncPointer
|
||||
|
||||
class _OVERLAPPED(Structure): ...
|
||||
OVERLAPPED: TypeAlias = _OVERLAPPED
|
||||
|
||||
class _COMSTAT(Structure): ...
|
||||
COMSTAT: TypeAlias = _COMSTAT
|
||||
|
||||
class _DCB(Structure): ...
|
||||
DCB: TypeAlias = _DCB
|
||||
|
||||
class _COMMTIMEOUTS(Structure): ...
|
||||
COMMTIMEOUTS: TypeAlias = _COMMTIMEOUTS
|
||||
|
||||
GetLastError: _NamedFuncPointer
|
||||
LPOVERLAPPED: type[_Pointer[_OVERLAPPED]]
|
||||
LPDWORD: type[_Pointer[DWORD]]
|
||||
GetOverlappedResult: _NamedFuncPointer
|
||||
ResetEvent: _NamedFuncPointer
|
||||
LPCVOID = c_void_p
|
||||
WriteFile: _NamedFuncPointer
|
||||
LPVOID = c_void_p
|
||||
ReadFile: _NamedFuncPointer
|
||||
CloseHandle: _NamedFuncPointer
|
||||
ClearCommBreak: _NamedFuncPointer
|
||||
LPCOMSTAT: type[_Pointer[_COMSTAT]]
|
||||
ClearCommError: _NamedFuncPointer
|
||||
SetupComm: _NamedFuncPointer
|
||||
EscapeCommFunction: _NamedFuncPointer
|
||||
GetCommModemStatus: _NamedFuncPointer
|
||||
LPDCB: type[_Pointer[_DCB]]
|
||||
GetCommState: _NamedFuncPointer
|
||||
LPCOMMTIMEOUTS: type[_Pointer[_COMMTIMEOUTS]]
|
||||
GetCommTimeouts: _NamedFuncPointer
|
||||
PurgeComm: _NamedFuncPointer
|
||||
SetCommBreak: _NamedFuncPointer
|
||||
SetCommMask: _NamedFuncPointer
|
||||
SetCommState: _NamedFuncPointer
|
||||
SetCommTimeouts: _NamedFuncPointer
|
||||
WaitForSingleObject: _NamedFuncPointer
|
||||
WaitCommEvent: _NamedFuncPointer
|
||||
CancelIoEx: _NamedFuncPointer
|
||||
|
||||
ONESTOPBIT: int
|
||||
TWOSTOPBITS: int
|
||||
NOPARITY: int
|
||||
ODDPARITY: int
|
||||
EVENPARITY: int
|
||||
RTS_CONTROL_HANDSHAKE: int
|
||||
RTS_CONTROL_ENABLE: int
|
||||
DTR_CONTROL_HANDSHAKE: int
|
||||
DTR_CONTROL_ENABLE: int
|
||||
MS_DSR_ON: int
|
||||
EV_RING: int
|
||||
EV_PERR: int
|
||||
EV_ERR: int
|
||||
SETXOFF: int
|
||||
EV_RXCHAR: int
|
||||
GENERIC_WRITE: int
|
||||
PURGE_TXCLEAR: int
|
||||
FILE_FLAG_OVERLAPPED: int
|
||||
EV_DSR: int
|
||||
MAXDWORD: int
|
||||
EV_RLSD: int
|
||||
ERROR_IO_PENDING: int
|
||||
MS_CTS_ON: int
|
||||
EV_EVENT1: int
|
||||
EV_RX80FULL: int
|
||||
PURGE_RXABORT: int
|
||||
FILE_ATTRIBUTE_NORMAL: int
|
||||
PURGE_TXABORT: int
|
||||
SETXON: int
|
||||
OPEN_EXISTING: int
|
||||
MS_RING_ON: int
|
||||
EV_TXEMPTY: int
|
||||
EV_RXFLAG: int
|
||||
MS_RLSD_ON: int
|
||||
GENERIC_READ: int
|
||||
EV_EVENT2: int
|
||||
EV_CTS: int
|
||||
EV_BREAK: int
|
||||
PURGE_RXCLEAR: int
|
||||
|
||||
class N11_OVERLAPPED4DOLLAR_48E(Union): ...
|
||||
class N11_OVERLAPPED4DOLLAR_484DOLLAR_49E(Structure): ...
|
||||
PVOID: TypeAlias = c_void_p
|
||||
Reference in New Issue
Block a user