|
@@ -449,6 +449,8 @@ int main(int argc, char *argv[]) {
|
|
|
string play;
|
|
|
play.reserve(4096);
|
|
|
|
|
|
+ int zmodem = 0;
|
|
|
+
|
|
|
|
|
|
|
|
|
for (;;) {
|
|
@@ -478,11 +480,17 @@ int main(int argc, char *argv[]) {
|
|
|
|
|
|
I'm thinking something like timeouts 30-50 seconds?
|
|
|
And as we get closer, 15-25 seconds.
|
|
|
+
|
|
|
+ if zmodem, buffer will always be empty -- we won't hold anything.
|
|
|
*/
|
|
|
|
|
|
if (buffer.size() == 0) {
|
|
|
|
|
|
- timeout.tv_sec = randrange(10, 20);
|
|
|
+ if (zmodem) {
|
|
|
+ timeout.tv_sec = 5;
|
|
|
+ } else {
|
|
|
+ timeout.tv_sec = randrange(10, 20);
|
|
|
+ };
|
|
|
timeout.tv_usec = 0;
|
|
|
time_idle = 1;
|
|
|
} else {
|
|
@@ -504,7 +512,7 @@ int main(int argc, char *argv[]) {
|
|
|
ZF_LOGI("TIMEOUT");
|
|
|
|
|
|
if (time_idle) {
|
|
|
- if (harry_level())
|
|
|
+ if (harry_level() && !zmodem)
|
|
|
harry_idle_event(STDOUT_FILENO);
|
|
|
} else {
|
|
|
ZF_LOGV("TIMEOUT buffer: %s", logrepr(buffer.c_str()));
|
|
@@ -547,48 +555,72 @@ int main(int argc, char *argv[]) {
|
|
|
ZF_LOGV("Read %d bytes", total);
|
|
|
buffer.append(read_buffer, total);
|
|
|
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
- int pos = buffer.rfind("\r\n");
|
|
|
-
|
|
|
-
|
|
|
- if (pos != string::npos) {
|
|
|
-
|
|
|
-
|
|
|
- pos += 2;
|
|
|
-
|
|
|
-
|
|
|
- play.assign(buffer, 0, pos);
|
|
|
- ZF_LOGI("play %lu size, %lu cap", play.size(), play.capacity());
|
|
|
-
|
|
|
-
|
|
|
- buffer.erase(0, pos);
|
|
|
-
|
|
|
- mangle(STDOUT_FILENO, play);
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
+ if (zmodem) {
|
|
|
+
|
|
|
+ int zend = buffer.find("\x1b[0m");
|
|
|
+ if (zend != string::npos)
|
|
|
+ zmodem = 0;
|
|
|
+ zend = buffer.find("\x1b[1;1H");
|
|
|
+ if (zend != string::npos)
|
|
|
+ zmodem = 0;
|
|
|
+ } else {
|
|
|
+
|
|
|
+ int zstart = buffer.find("**\x18"
|
|
|
+ "B0");
|
|
|
+ if (zstart != string::npos)
|
|
|
+ zmodem = 1;
|
|
|
}
|
|
|
|
|
|
-
|
|
|
-
|
|
|
- if (buffer.size() > BSIZE) {
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
- ZF_LOGI("Buffer %lu bytes, write only...", buffer.size());
|
|
|
+ if (zmodem) {
|
|
|
+ ZF_LOGI("Buffer %lu bytes, zmodem...", buffer.size());
|
|
|
|
|
|
write(STDOUT_FILENO, buffer.data(), buffer.size());
|
|
|
- console_receive(&console, buffer);
|
|
|
+
|
|
|
buffer.clear();
|
|
|
+ } else {
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ int pos = buffer.rfind("\r\n");
|
|
|
+
|
|
|
+
|
|
|
+ if (pos != string::npos) {
|
|
|
+
|
|
|
+
|
|
|
+ pos += 2;
|
|
|
+
|
|
|
+
|
|
|
+ play.assign(buffer, 0, pos);
|
|
|
+ ZF_LOGI("play %lu size, %lu cap", play.size(), play.capacity());
|
|
|
+
|
|
|
+
|
|
|
+ buffer.erase(0, pos);
|
|
|
+
|
|
|
+ mangle(STDOUT_FILENO, play);
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ if (buffer.size() > BSIZE) {
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ ZF_LOGI("Buffer %lu bytes, write only...", buffer.size());
|
|
|
+
|
|
|
+ write(STDOUT_FILENO, buffer.data(), buffer.size());
|
|
|
+ console_receive(&console, buffer);
|
|
|
+ buffer.clear();
|
|
|
+ }
|
|
|
}
|
|
|
-
|
|
|
} else
|
|
|
break;
|
|
|
}
|