From 5821e9952795f9b22e0d23bee2bcfcb265a82205 Mon Sep 17 00:00:00 2001 From: nishi Date: Thu, 13 Jun 2024 03:36:24 +0000 Subject: [PATCH] i got hayes working git-svn-id: file:///raid/svn-main/nishi-dataworks/trunk@290 d4a5a174-5a4a-5b4b-b672-37683c10d7d5 --- RemoteClient/hayes.c | 32 +++++++++++++++++++++++++++----- Server/hayes.c | 3 ++- 2 files changed, 29 insertions(+), 6 deletions(-) diff --git a/RemoteClient/hayes.c b/RemoteClient/hayes.c index bffa914..b5f4a49 100644 --- a/RemoteClient/hayes.c +++ b/RemoteClient/hayes.c @@ -28,8 +28,8 @@ /* -------------------------------------------------------------------------- */ /* --- END LICENSE --- */ -#include #include +#include #include #include @@ -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; +} diff --git a/Server/hayes.c b/Server/hayes.c index 9321eef..62c6b80 100644 --- a/Server/hayes.c +++ b/Server/hayes.c @@ -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; -- 2.43.0