From 490fee106114f80cae25ec431c6892ba503c3d14 Mon Sep 17 00:00:00 2001 From: short <> Date: Tue, 19 Mar 2002 01:01:59 +0000 Subject: [PATCH] Untested patch for Ir (NOT IrDA!) connections - activate by "--ir" option before the command itself --- common/devices/device.c | 8 ++++++++ common/gsm-api.c | 6 +++++- common/newmodules/n6110.c | 31 ++++++++++++++++--------------- common/protocol/fbus.c | 9 +++++++-- do | 2 +- gnokii/gnokii.c | 27 +++++++++++++++++---------- include/devices/device.h | 2 +- 7 files changed, 55 insertions(+), 30 deletions(-) diff --git a/common/devices/device.c b/common/devices/device.c index b002239..1868393 100644 --- a/common/devices/device.c +++ b/common/devices/device.c @@ -436,9 +436,12 @@ bool StartConnection (char *port_device, bool with_odd_parity, GSM_ConnectionTyp strcpy(text,"Connection "); switch (con) { case GCT_FBUS :strcpy(text+strlen(text),"FBUS");break; + case GCT_Infrared:strcpy(text+strlen(text),"infrared");break; #ifndef UCLINUX + case GCT_Irda :strcpy(text+strlen(text),"irda sockets");break; case GCT_MBUS :strcpy(text+strlen(text),"MBUS");break; case GCT_DLR3 :strcpy(text+strlen(text),"DLR3");break; + case GCT_Tekram :strcpy(text+strlen(text),"Tekram");break; case GCT_AT :strcpy(text+strlen(text),"AT");break; default :strcpy(text+strlen(text),"unknown");break; #endif /* UCLINUX */ @@ -600,9 +603,14 @@ bool StartConnection (char *port_device, bool with_odd_parity, GSM_ConnectionTyp strcpy(text,"Connection "); switch (con) { case GCT_FBUS :strcpy(text+strlen(text),"FBUS");break; + case GCT_Infrared:strcpy(text+strlen(text),"infrared");break; +#ifndef UCLINUX + case GCT_Irda :strcpy(text+strlen(text),"irda sockets");break; case GCT_MBUS :strcpy(text+strlen(text),"MBUS");break; case GCT_DLR3 :strcpy(text+strlen(text),"DLR3");break; + case GCT_Tekram :strcpy(text+strlen(text),"Tekram");break; case GCT_AT :strcpy(text+strlen(text),"AT");break; +#endif /* UCLINUX */ default :strcpy(text+strlen(text),"unknown");break; } strcpy(text+strlen(text),"\n"); diff --git a/common/gsm-api.c b/common/gsm-api.c index 00f1ee3..620a8a0 100644 --- a/common/gsm-api.c +++ b/common/gsm-api.c @@ -261,9 +261,11 @@ bool CheckModel (GSM_Information InfoToCheck, char *model, GSM_ConnectionType co if (strstr(InfoToCheck.MBUSModels, model) != NULL) { if (connection==GCT_MBUS) found_match=true; } +#endif /* UCLINUX */ if (strstr(InfoToCheck.InfraredModels, model) != NULL) { if (connection==GCT_Infrared) found_match=true; } +#ifndef UCLINUX if (strstr(InfoToCheck.DLR3Models, model) != NULL) { if (connection==GCT_DLR3) found_match=true; } @@ -541,8 +543,8 @@ GSM_Error GSM_Initialise(char *model, char *device, char *initlength, GSM_Connec if (found_match) { switch (connection) { case GCT_FBUS : Protocol = &FBUS_Functions; break; -#ifndef UCLINUX case GCT_Infrared: Protocol = &FBUS_Functions; break; +#ifndef UCLINUX case GCT_Tekram : Protocol = &FBUS_Functions; break; case GCT_DLR3 : Protocol = &FBUS_Functions; break; case GCT_MBUS : Protocol = &MBUS_Functions; break; @@ -691,7 +693,9 @@ GSM_ConnectionType GetConnectionTypeFromString(char *Connection) { #ifndef UCLINUX if (!strcmp(Connection, "irda")) connection=GCT_Irda; +#endif /* UCLINUX */ if (!strcmp(Connection, "infrared")) connection=GCT_Infrared; +#ifndef UCLINUX if (!strcmp(Connection, "mbus")) connection=GCT_MBUS; if (!strcmp(Connection, "dlr3")) connection=GCT_DLR3; if (!strcmp(Connection, "fbus3110")) connection=GCT_FBUS3110; diff --git a/common/newmodules/n6110.c b/common/newmodules/n6110.c index a459961..26225db 100644 --- a/common/newmodules/n6110.c +++ b/common/newmodules/n6110.c @@ -642,9 +642,7 @@ GSM_Error N6110_Initialise(char *port_device, char *initlength, void (*rlp_callback)(RLP_F96Frame *frame)) { unsigned char init_char = N6110_SYNC_BYTE; -#ifndef UCLINUX unsigned char end_init_char = N6110_IR_END_SYNC_BYTE; -#endif /* UCLINUX */ int count; int InitLength; @@ -674,8 +672,8 @@ GSM_Error N6110_Initialise(char *port_device, char *initlength, #endif /* UCLINUX */ case GCT_FBUS: -#ifndef UCLINUX case GCT_Infrared: +#ifndef UCLINUX case GCT_Tekram: #endif /* UCLINUX */ InitLength = atoi(initlength); @@ -684,15 +682,16 @@ GSM_Error N6110_Initialise(char *port_device, char *initlength, InitLength = 250; /* This is the usual value, lower may work. */ } + if (CurrentConnectionType==GCT_Infrared #ifndef UCLINUX - if (CurrentConnectionType==GCT_Infrared || - CurrentConnectionType==GCT_Tekram) { + || CurrentConnectionType==GCT_Tekram +#endif /* UCLINUX */ + ) { #ifdef DEBUG fprintf(stdout,_("Setting infrared for FBUS communication...\n")); #endif device_changespeed(9600); } -#endif /* UCLINUX */ #ifdef DEBUG fprintf(stdout,_("Writing init chars....")); @@ -702,32 +701,34 @@ GSM_Error N6110_Initialise(char *port_device, char *initlength, /* Send init string to phone, this is a bunch of 0x55 characters. Timing is empirical. */ for (count = 0; count < InitLength; count ++) { + if (CurrentConnectionType!=GCT_Infrared #ifndef UCLINUX - if (CurrentConnectionType!=GCT_Infrared && - CurrentConnectionType!=GCT_Tekram) + && CurrentConnectionType!=GCT_Tekram #endif /* UCLINUX */ - usleep(100); + ) usleep(100); Protocol->WritePhone(1,&init_char); } + if (CurrentConnectionType==GCT_Infrared #ifndef UCLINUX - if (CurrentConnectionType==GCT_Infrared || - CurrentConnectionType==GCT_Tekram) { + || CurrentConnectionType==GCT_Tekram +#endif /* UCLINUX */ + ) { Protocol->WritePhone(1,&end_init_char); usleep(200000); } -#endif /* UCLINUX */ #ifdef DEBUG fprintf(stdout,_("Done\n")); #endif + if (CurrentConnectionType==GCT_Infrared #ifndef UCLINUX - if (CurrentConnectionType==GCT_Infrared || - CurrentConnectionType==GCT_Tekram) { + || CurrentConnectionType==GCT_Tekram +#endif /* UCLINUX */ + ) { device_changespeed(115200); } -#endif /* UCLINUX */ N6110_SendStatusRequest(); diff --git a/common/protocol/fbus.c b/common/protocol/fbus.c index 99e1d52..a8ff0e9 100644 --- a/common/protocol/fbus.c +++ b/common/protocol/fbus.c @@ -289,8 +289,11 @@ void FBUS_RX_StateMachine(unsigned char rx_byte) { case FBUS_RX_Sync: if ((CurrentConnectionType==GCT_FBUS && rx_byte == FBUS_FRAME_ID) || - 0/*((CurrentConnectionType==GCT_Infrared || - CurrentConnectionType==GCT_Tekram) && rx_byte == FBUS_IR_FRAME_ID)*/) { + ((CurrentConnectionType==GCT_Infrared +#ifndef UCLINUX + || CurrentConnectionType==GCT_Tekram +#endif /* UCLINUX */ + ) && rx_byte == FBUS_IR_FRAME_ID)) { BufferCount = 0; @@ -595,9 +598,11 @@ static bool FBUS_OpenSerial(void) CurrentConnectionType=GCT_FBUS; break; +#endif /* UCLINUX */ case GCT_Infrared: /* It's more complicated and not done here */ break; +#ifndef UCLINUX case GCT_Tekram: /* It's more complicated and not done here */ diff --git a/do b/do index 793bde3..e981d4f 100755 --- a/do +++ b/do @@ -24,7 +24,7 @@ if [ -n "$target_m68k" ];then fi fi export CPPFLAGS="-DUCLINUX=1 $CPPFLAGS" -./configure --with-cfg-model=5110 --with-cfg-port=/dev/"$cfg_port" --without-x \ +./configure --with-cfg-model=6150 --with-cfg-port=/dev/"$cfg_port" --without-x \ `if [ -n "$enable_debug" ];then echo "--enable-debug --enable-xdebug";fi` make clean make diff --git a/gnokii/gnokii.c b/gnokii/gnokii.c index 25f66ec..ca1a7ea 100644 --- a/gnokii/gnokii.c +++ b/gnokii/gnokii.c @@ -731,7 +731,15 @@ static int usage(void) fprintf(stdout, _(" usage: gnokii [--help] [--version]\n" )); + +#ifdef UCLINUX + fprintf(stdout, _( +" gnokii --ir [...]\n" + )); +#endif /* UCLINUX */ + #ifndef UCLINUX + fprintf(stdout, _( " gnokii --monitor [-noloop|-nl]\n" )); #endif /* UCLINUX */ @@ -1038,7 +1046,7 @@ int main(int argc, char *argv[]) { int c, i, rc = -1; - int nargc = argc-2; + int nargc; char **nargv; /* Every option should be in this array. */ @@ -1264,6 +1272,12 @@ int main(int argc, char *argv[]) if (CFG_ReadConfig(&model, &Port, &Initlength, &Connection, &BinDir, false) < 0) { exit(-1); } + if (argc>1 && !strcmp(argv[1],"--ir")) { + argc--; + argv[1]=argv[0]; + argv++; + Connection="infrared"; + } /* Handle command line arguments. */ @@ -1284,6 +1298,7 @@ int main(int argc, char *argv[]) if((nargv = malloc(sizeof(char *) * argc)) != NULL) { + nargc = argc-2; for(i = 2; i < argc; i++) nargv[i-2] = argv[i]; nargv[argc-2] = NULL; /* required by gnokiid() for execv(3) */ @@ -4254,11 +4269,6 @@ static void gnokiid_SIGCHLD(int signo) static int gnokiid(int argc, char *argv[]) { bool DebugMode; /* When true, run in debug mode */ - char *Model; /* Model from .gnokiirc file. */ - char *Port; /* Port from .gnokiirc file */ - char *Initlength; /* Init length from .gnokiirc file */ - char *Connection; /* Connection type from .gnokiirc file */ - char *BinDir; /* Directory of the mgnokiidev command */ /* evaluate for presence of "--debug" argument in parameter */ DebugMode = false; @@ -4276,10 +4286,7 @@ static int gnokiid(int argc, char *argv[]) fprintf (stderr, _("Initializing gnokiid mode...\n")); #endif - if (CFG_ReadConfig(&Model, &Port, &Initlength, &Connection, &BinDir, true) < 0) - return(-1); - - if (VM_Initialise(Model, Port, Initlength, GCT_FBUS, BinDir, DebugMode, true, ""/*SynchronizeTime*/) == false) + if (VM_Initialise(model, Port, Initlength, GetConnectionTypeFromString(Connection), BinDir, DebugMode, true, ""/*SynchronizeTime*/) == false) return (-1); if (argc>0) { diff --git a/include/devices/device.h b/include/devices/device.h index cebb68c..98be957 100644 --- a/include/devices/device.h +++ b/include/devices/device.h @@ -22,8 +22,8 @@ IR (only with 61x0 models) and MBUS (61x0, 640, 6160) */ typedef enum { GCT_FBUS, /* FBUS connection. */ -#ifndef UCLINUX GCT_Infrared, /* FBUS over direct infrared connection - 61xx. */ +#ifndef UCLINUX GCT_Irda, /* FBUS over Irda sockets - 7110, 6210, etc. */ GCT_MBUS, /* MBUS */ GCT_DLR3, /* FBUS over DLR3 cable */ -- 1.8.3.1