mirror of
https://github.com/mofeng-git/One-KVM.git
synced 2026-02-01 18:41:54 +08:00
serial fixes
This commit is contained in:
@@ -255,7 +255,7 @@ static void _sendResponse(uint8_t code) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
uint8_t response[8] = {0};
|
uint8_t response[8] = {0};
|
||||||
response[0] = PROTO::MAGIC;
|
response[0] = PROTO::MAGIC_RESP;
|
||||||
if (code & PROTO::PONG::OK) {
|
if (code & PROTO::PONG::OK) {
|
||||||
response[1] = PROTO::PONG::OK;
|
response[1] = PROTO::PONG::OK;
|
||||||
# ifdef HID_DYNAMIC
|
# ifdef HID_DYNAMIC
|
||||||
|
|||||||
@@ -25,6 +25,7 @@
|
|||||||
|
|
||||||
namespace PROTO {
|
namespace PROTO {
|
||||||
const uint8_t MAGIC = 0x33;
|
const uint8_t MAGIC = 0x33;
|
||||||
|
const uint8_t MAGIC_RESP = 0x34;
|
||||||
|
|
||||||
namespace RESP { // Plain responses
|
namespace RESP { // Plain responses
|
||||||
// const uint8_t OK = 0x20; // Legacy
|
// const uint8_t OK = 0x20; // Legacy
|
||||||
|
|||||||
@@ -52,9 +52,13 @@ class _SerialPhyConnection(BasePhyConnection):
|
|||||||
self.__tty.read_all()
|
self.__tty.read_all()
|
||||||
assert self.__tty.write(request) == 8
|
assert self.__tty.write(request) == 8
|
||||||
data = self.__tty.read(4)
|
data = self.__tty.read(4)
|
||||||
if data[0] == 0x34: # New response protocol
|
if len(data) == 4:
|
||||||
data += self.__tty.read(4)
|
if data[0] == 0x34: # New response protocol
|
||||||
return data
|
data += self.__tty.read(4)
|
||||||
|
if len(data) != 8:
|
||||||
|
return b""
|
||||||
|
return data
|
||||||
|
return b""
|
||||||
|
|
||||||
|
|
||||||
class _SerialPhy(BasePhy):
|
class _SerialPhy(BasePhy):
|
||||||
@@ -81,7 +85,10 @@ class _SerialPhy(BasePhy):
|
|||||||
# =====
|
# =====
|
||||||
class Plugin(BaseMcuHid):
|
class Plugin(BaseMcuHid):
|
||||||
def __init__(self, **kwargs: Any) -> None:
|
def __init__(self, **kwargs: Any) -> None:
|
||||||
phy_kwargs: Dict = {key: kwargs.pop(key) for key in self.__get_phy_options()}
|
phy_kwargs: Dict = {
|
||||||
|
(option.unpack_as or key): kwargs.pop(option.unpack_as or key)
|
||||||
|
for (key, option) in self.__get_phy_options().items()
|
||||||
|
}
|
||||||
super().__init__(phy=_SerialPhy(**phy_kwargs), **kwargs)
|
super().__init__(phy=_SerialPhy(**phy_kwargs), **kwargs)
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
|
|||||||
Reference in New Issue
Block a user