extern char** argv;
int port = -1;
-bool connected;
+bool connected = false;
bool option(const char* str, const char* shortopt, const char* longopt);
}
if(__dw_strcaseequ(resp, "CONNECT")) {
printf("Connected\n");
+ connected = true;
break;
}
}
return 0;
}
- disconnect(0);
- return 1;
+ return 0;
}
void disconnect(int sock) {
while(inp(get_ioport() + 6) & (1 << 7)) outp(get_ioport() + 4, 0);
connected = false;
}
+
+char* readline_sock(void) {
+ char* resp = modem_response();
+ if(__dw_strcaseequ(resp, "NO CARRIER")) {
+ connected = false;
+ free(resp);
+ }
+ return connected ? resp : NULL;
+}
+
+void writeline(const char* str) {
+ char* w = __dw_strcat(str, "\r\n");
+ write_serial(w);
+ free(w);
+}
char** argv;
int rcli_init(void);
+char* readline_sock(void);
+void writeline(const char*);
bool option(const char* str, const char* shortopt, const char* longopt) {
char* dos_shortopt = __dw_strcat("/", shortopt);
argv = _argv;
int st = rcli_init();
if(st != 0) return st;
+ while(1) {
+ char* resp = readline_sock();
+ if(resp == NULL) {
+ break;
+ }
+ printf("!%s!\n", resp);
+ free(resp);
+ }
+ return 0;
}