commented kvmd/kvmd#80 (#102)

Co-authored-by: Maxim Devaev <mdevaev@gmail.com>
This commit is contained in:
tomaszduda23 2022-07-15 16:22:26 +09:00 committed by GitHub
parent 4b87851119
commit 48f4792861
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 56 additions and 51 deletions

View File

@ -28,6 +28,7 @@ def _patch(path: str, patch_path: str) -> None:
assert exists(path) assert exists(path)
flag_path: str = join(path, f".{basename(patch_path)}.done") flag_path: str = join(path, f".{basename(patch_path)}.done")
if not exists(flag_path): if not exists(flag_path):
# TODO check for failure
env.Execute(f"patch -p1 -d {path} < {patch_path}") env.Execute(f"patch -p1 -d {path} < {patch_path}")
env.Execute(lambda *_, **__: open(flag_path, "w").close()) env.Execute(lambda *_, **__: open(flag_path, "w").close())

View File

@ -1,17 +1,24 @@
diff -u -r a/cores/arduino/main.cpp b/cores/arduino/main.cpp diff --git a/cores/arduino/main.cpp b/cores/arduino/main.cpp
--- a/cores/arduino/main.cpp 2019-05-16 15:52:01.000000000 +0300 index 434cd40..7aba76f 100644
+++ b/cores/arduino/main.cpp 2020-11-17 18:56:01.243474508 +0300 --- a/cores/arduino/main.cpp
@@ -30,6 +30,7 @@ +++ b/cores/arduino/main.cpp
void setupUSB() __attribute__((weak)); @@ -36,15 +36,15 @@ int main(void)
void setupUSB() { }
+/* initVariant();
int main(void)
{ -#if defined(USBCON)
init(); - USBDevice.attach();
@@ -49,4 +50,5 @@ -#endif
+// #if defined(USBCON)
+// USBDevice.attach();
+// #endif
setup();
for (;;) {
loop();
- if (serialEventRun) serialEventRun();
+ // if (serialEventRun) serialEventRun();
}
return 0; return 0;
}
+*/

View File

@ -303,9 +303,7 @@ static void _sendResponse(uint8_t code) {
# endif # endif
} }
int main() { void setup() {
init(); // Embedded
initVariant(); // Arduino
_initOutputs(); _initOutputs();
# ifdef AUM # ifdef AUM
@ -314,41 +312,40 @@ int main() {
# ifdef CMD_SERIAL # ifdef CMD_SERIAL
CMD_SERIAL.begin(CMD_SERIAL_SPEED); CMD_SERIAL.begin(CMD_SERIAL_SPEED);
unsigned long last = micros();
uint8_t buffer[8];
uint8_t index = 0;
# elif defined(CMD_SPI) # elif defined(CMD_SPI)
spiBegin(); spiBegin();
# endif # endif
}
while (true) {
# ifdef AUM void loop() {
aumProxyUsbVbus(); # ifdef AUM
# endif aumProxyUsbVbus();
# endif
_kbd->periodic();
_kbd->periodic();
# ifdef CMD_SERIAL
if (CMD_SERIAL.available() > 0) { # ifdef CMD_SERIAL
buffer[index] = (uint8_t)CMD_SERIAL.read(); static unsigned long last = micros();
if (index == 7) { static uint8_t buffer[8];
_sendResponse(_handleRequest(buffer)); static uint8_t index = 0;
index = 0; if (CMD_SERIAL.available() > 0) {
} else /*if (buffer[0] == PROTO::MAGIC)*/ { // FIXME: See kvmd/kvmd#80 buffer[index] = (uint8_t)CMD_SERIAL.read();
last = micros(); if (index == 7) {
++index; _sendResponse(_handleRequest(buffer));
} index = 0;
} else if (index > 0) { } else /*if (buffer[0] == PROTO::MAGIC)*/ { // FIXME: See kvmd/kvmd#80
if (is_micros_timed_out(last, CMD_SERIAL_TIMEOUT)) { last = micros();
_sendResponse(PROTO::RESP::TIMEOUT_ERROR); ++index;
index = 0; }
} } else if (index > 0) {
} if (is_micros_timed_out(last, CMD_SERIAL_TIMEOUT)) {
# elif defined(CMD_SPI) _sendResponse(PROTO::RESP::TIMEOUT_ERROR);
if (spiReady()) { index = 0;
_sendResponse(_handleRequest(spiGet())); }
} }
# endif # elif defined(CMD_SPI)
} if (spiReady()) {
return 0; _sendResponse(_handleRequest(spiGet()));
}
# endif
} }