]> Nishi Git Mirror - dataworks.git/commitdiff
i got hayes working
authornishi <nishi@d4a5a174-5a4a-5b4b-b672-37683c10d7d5>
Thu, 13 Jun 2024 03:36:24 +0000 (03:36 +0000)
committernishi <nishi@d4a5a174-5a4a-5b4b-b672-37683c10d7d5>
Thu, 13 Jun 2024 03:36:24 +0000 (03:36 +0000)
git-svn-id: file:///raid/svn-main/nishi-dataworks/trunk@290 d4a5a174-5a4a-5b4b-b672-37683c10d7d5

RemoteClient/hayes.c
Server/hayes.c

index bffa914168271aa4d4bde7cf0e0f6604bde0a36d..b5f4a491ba4b3f3cc81861860c47c025320ea3e7 100644 (file)
@@ -28,8 +28,8 @@
 /* -------------------------------------------------------------------------- */
 /* --- END LICENSE --- */
 
-#include <stdio.h>
 #include <stdbool.h>
+#include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
 
@@ -47,6 +47,8 @@ bool connected;
 
 bool option(const char* str, const char* shortopt, const char* longopt);
 
+void disconnect(int sock);
+
 int get_ioport() {
 #ifdef PC98
        if(port == 0) return 0x30;
@@ -64,7 +66,6 @@ int get_ioport() {
        return 0;
 }
 
-
 void write_serial(const char* str) {
        const char* ptr = str;
        while(1) {
@@ -141,7 +142,7 @@ int rcli_init(void) {
                fprintf(stderr, "Specify serial port\n");
                return 1;
        }
-       if(dial == NULL){
+       if(dial == NULL) {
                fprintf(stderr, "Specify where to dial\n");
                return 1;
        }
@@ -159,9 +160,30 @@ int rcli_init(void) {
                write_serial("ATDT");
                write_serial(dial);
                write_serial("\r");
-               printf("%s\n", modem_response());
-               printf("%s\n", modem_response());
+               while(true) {
+                       resp = modem_response();
+                       int i;
+                       for(i = 0; resp[i] != 0; i++) {
+                               if(resp[i] == ' ') {
+                                       resp[i] = 0;
+                                       break;
+                               }
+                       }
+                       if(__dw_strcaseequ(resp, "CONNECT")) {
+                               printf("Connected\n");
+                               break;
+                       }
+               }
                return 0;
        }
+       disconnect(0);
        return 1;
 }
+
+void disconnect(int sock) {
+       while((inp(get_ioport() + 5) & 0x20) == 0)
+               ;
+       delay(100);
+       while(inp(get_ioport() + 6) & (1 << 7)) outp(get_ioport() + 4, 0);
+       connected = false;
+}
index 9321eef4a006d76435e12ccd9196f4d3fb92c01a..62c6b8037d1643b8e350ccb5643c0c18fe10ecde 100644 (file)
@@ -389,7 +389,8 @@ void writeline(int sock, const char* str) {
 }
 
 void disconnect(int sock) {
-       while((inp(get_ioport() + 5) & 0x20) == 0);
+       while((inp(get_ioport() + 5) & 0x20) == 0)
+               ;
        delay(100);
        while(inp(get_ioport() + 6) & (1 << 7)) outp(get_ioport() + 4, 0);
        connected = false;