datacalls decoding patches
authorshort <>
Sat, 9 Mar 2002 22:51:58 +0000 (22:51 +0000)
committershort <>
Sat, 9 Mar 2002 22:51:58 +0000 (22:51 +0000)
common/devices/unixserial.c
common/files/cfgreader.c
common/misc.c
common/newmodules/n6110.c
common/protocol/fbus.c
gnokii/gnokii.c
include/config.h.in.in
include/protocol/fbus.h

index bc7e37e..7ad6128 100644 (file)
@@ -81,8 +81,10 @@ int serial_open(__const char *__file, int __oflag) {
   if(retcode==-1) {
     perror("Gnokii serial_open:tcgetattr");
     /* Don't call serial_close since serial_termios is not valid */
   if(retcode==-1) {
     perror("Gnokii serial_open:tcgetattr");
     /* Don't call serial_close since serial_termios is not valid */
+#if 0
     close(__fd);
     return(-1);
     close(__fd);
     return(-1);
+#endif
   }
   
   return __fd;
   }
   
   return __fd;
@@ -108,7 +110,7 @@ int serial_opendevice(__const char *__file, int __with_odd_parity, int __with_as
 
   /* Open device */
 
 
   /* Open device */
 
-  fd = serial_open(__file, O_RDWR | O_NOCTTY | O_NONBLOCK);
+  fd = serial_open(__file, O_RDONLY | O_NOCTTY | O_NONBLOCK);
 
   if (fd < 0) 
     return fd;
 
   if (fd < 0) 
     return fd;
@@ -119,8 +121,10 @@ int serial_opendevice(__const char *__file, int __with_odd_parity, int __with_as
   retcode = fcntl(fd, F_SETOWN, getpid());
   if (retcode == -1){
     perror("Gnokii serial_opendevice: fnctl(F_SETOWN)");
   retcode = fcntl(fd, F_SETOWN, getpid());
   if (retcode == -1){
     perror("Gnokii serial_opendevice: fnctl(F_SETOWN)");
+#if 0
     serial_close(fd);
     return(-1);
     serial_close(fd);
     return(-1);
+#endif
   }
 #endif
 
   }
 #endif
 
@@ -130,8 +134,10 @@ int serial_opendevice(__const char *__file, int __with_odd_parity, int __with_as
     retcode=fcntl(fd, F_SETFL, FASYNC);
     if (retcode == -1){
       perror("Gnokii serial_opendevice: fnctl(F_SETFL)");
     retcode=fcntl(fd, F_SETFL, FASYNC);
     if (retcode == -1){
       perror("Gnokii serial_opendevice: fnctl(F_SETFL)");
+#if 0
       serial_close(fd);
       return(-1);
       serial_close(fd);
       return(-1);
+#endif
     }
   }
   
     }
   }
   
@@ -161,15 +167,19 @@ int serial_opendevice(__const char *__file, int __with_odd_parity, int __with_as
   retcode=tcflush(fd, TCIFLUSH);
   if (retcode == -1) {
     perror("Gnokii serial_opendevice: tcflush");
   retcode=tcflush(fd, TCIFLUSH);
   if (retcode == -1) {
     perror("Gnokii serial_opendevice: tcflush");
+#if 0
     serial_close(fd);
     return(-1);
     serial_close(fd);
     return(-1);
+#endif
   }
 
   retcode=tcsetattr(fd, TCSANOW, &tp);
   if (retcode == -1){
     perror("Gnokii serial_opendevice: tcsetattr");
   }
 
   retcode=tcsetattr(fd, TCSANOW, &tp);
   if (retcode == -1){
     perror("Gnokii serial_opendevice: tcsetattr");
+#if 0
     serial_close(fd);
     return(-1);
     serial_close(fd);
     return(-1);
+#endif
   }
 
   return fd;
   }
 
   return fd;
@@ -260,7 +270,10 @@ size_t serial_read(int __fd, __ptr_t __buf, size_t __nbytes) {
 
 size_t serial_write(int __fd, __const __ptr_t __buf, size_t __n) {
        
 
 size_t serial_write(int __fd, __const __ptr_t __buf, size_t __n) {
        
+#if 0
        return (write(__fd, __buf, __n));
        return (write(__fd, __buf, __n));
+#endif
+       return __n;
 }
 
 #endif  /* WIN32 */
 }
 
 #endif  /* WIN32 */
index 9908cc1..fc087f6 100644 (file)
@@ -254,7 +254,7 @@ struct CFG_Header *CFG_FindGnokiirc()
 #else
         homedir = getenv("HOME");
         if (homedir) strncpy(rcfile, homedir, 200);
 #else
         homedir = getenv("HOME");
         if (homedir) strncpy(rcfile, homedir, 200);
-        strncat(rcfile, "/.gnokiirc", 200);
+        strncat(rcfile, "/.mygnokiirc", 200);
 #endif
 
         /* Try opening .gnokirc from users home directory first */
 #endif
 
         /* Try opening .gnokirc from users home directory first */
index b17a93e..53306bc 100644 (file)
@@ -83,6 +83,8 @@ void hexdump(u16 MessageLength, u8 *MessageBuffer)
   char hex1[10];
   char hex2[10];
  
   char hex1[10];
   char hex2[10];
  
+printf("NK: ");
   for (count = 0; count < MessageLength; count ++)
   {
     n++;
   for (count = 0; count < MessageLength; count ++)
   {
     n++;
index 324b401..bd70285 100644 (file)
@@ -5322,7 +5322,7 @@ void N6110_RX_HandleRLPMessage(u8 *MessageBuffer)
   /* We do not need RLP frame parsing to be done when we do not have callback
      specified. */
   if (CurrentRLP_RXCallback == NULL)
   /* We do not need RLP frame parsing to be done when we do not have callback
      specified. */
   if (CurrentRLP_RXCallback == NULL)
-    exit;
+    return;
     
   /* Anybody know the official meaning of the first two bytes?
      Nokia 6150 sends junk frames starting D9 01, and real frames starting
     
   /* Anybody know the official meaning of the first two bytes?
      Nokia 6150 sends junk frames starting D9 01, and real frames starting
index 87e98fe..34c0507 100644 (file)
@@ -60,6 +60,8 @@ u8 MessageBuffer[FBUS_MAX_RECEIVE_LENGTH * 6],MultiMessageBuffer[FBUS_MAX_RECEIV
 
 u8        RequestSequenceNumber = 0x00;
 
 
 u8        RequestSequenceNumber = 0x00;
 
+int fbus_decoding=0;
+
 #ifdef DEBUG   
 char *N61_PrintDevice(int Device)
 {
 #ifdef DEBUG   
 char *N61_PrintDevice(int Device)
 {
@@ -78,11 +80,12 @@ char *N61_PrintDevice(int Device)
 void N61_RX_DisplayMessage()
 {
 #ifdef DEBUG
 void N61_RX_DisplayMessage()
 {
 #ifdef DEBUG
+  hexdump(MessageLength-2,MessageBuffer);
+
   fprintf(stdout, _("Msg Dest: %s\n"), N61_PrintDevice(MessageDestination));
   fprintf(stdout, _("Msg Source: %s\n"), N61_PrintDevice(MessageSource));
   fprintf(stdout, _("Msg Type: %02x\n"), MessageType);
   fprintf(stdout, _("Msg Dest: %s\n"), N61_PrintDevice(MessageDestination));
   fprintf(stdout, _("Msg Source: %s\n"), N61_PrintDevice(MessageSource));
   fprintf(stdout, _("Msg Type: %02x\n"), MessageType);
-
-  hexdump(MessageLength-2,MessageBuffer);
+  fprintf(stdout, _("Msg Seq: %d\n"), MessageBuffer[MessageLength-1] & 0x0f);
 #endif
 
   AppendLog(MessageBuffer,MessageLength-2,true);
 #endif
 
   AppendLog(MessageBuffer,MessageLength-2,true);
@@ -207,6 +210,9 @@ int FBUS_SendAck(u8 message_type, u8 message_seq) {
 
   unsigned char request[6];
 
 
   unsigned char request[6];
 
+  if (fbus_decoding)
+    return 0;
+
   request[0] = message_type;
   request[1] = message_seq;
 
   request[0] = message_type;
   request[1] = message_seq;
 
@@ -233,7 +239,9 @@ void FBUS_Terminate(void)
 
 void FBUS_RX_StateMachine(unsigned char rx_byte) {
 
 
 void FBUS_RX_StateMachine(unsigned char rx_byte) {
 
+#if 0
   static struct timeval time_now, time_last, time_diff;
   static struct timeval time_now, time_last, time_diff;
+#endif
   
   static int checksum[2];
   
   
   static int checksum[2];
   
@@ -263,6 +271,7 @@ void FBUS_RX_StateMachine(unsigned char rx_byte) {
 
   case FBUS_RX_Discarding:
 
 
   case FBUS_RX_Discarding:
 
+#if 0
 #ifndef VC6
     gettimeofday(&time_now, NULL);
     timersub(&time_now, &time_last, &time_diff);
 #ifndef VC6
     gettimeofday(&time_now, NULL);
     timersub(&time_now, &time_last, &time_diff);
@@ -272,13 +281,21 @@ void FBUS_RX_StateMachine(unsigned char rx_byte) {
     }
     /* else fall through to... */
 #endif
     }
     /* else fall through to... */
 #endif
+#endif
 
 
-  case FBUS_RX_Sync:
+  case FBUS_RX_Sync: {
+static int discarded=0,discarded55=0;
 
       if ((CurrentConnectionType==GCT_FBUS && rx_byte == FBUS_FRAME_ID) ||
           ((CurrentConnectionType==GCT_Infrared ||
           CurrentConnectionType==GCT_Tekram) && rx_byte == FBUS_IR_FRAME_ID)) {
 
 
       if ((CurrentConnectionType==GCT_FBUS && rx_byte == FBUS_FRAME_ID) ||
           ((CurrentConnectionType==GCT_Infrared ||
           CurrentConnectionType==GCT_Tekram) && rx_byte == FBUS_IR_FRAME_ID)) {
 
+       if (discarded) {
+         printf("[discarded %d bytes, %d were NOT 0x55]\n",discarded,discarded-discarded55);
+         discarded=0;
+         discarded55=0;
+         }
+
         BufferCount = 0;
 
        RX_State = FBUS_RX_GetDestination;
         BufferCount = 0;
 
        RX_State = FBUS_RX_GetDestination;
@@ -289,11 +306,16 @@ void FBUS_RX_StateMachine(unsigned char rx_byte) {
       } else {
         /* Lost frame sync */
         RX_State = FBUS_RX_Discarding;
       } else {
         /* Lost frame sync */
         RX_State = FBUS_RX_Discarding;
+#if 0
 #ifndef VC6
         gettimeofday(&time_last, NULL);
 #endif
 #ifndef VC6
         gettimeofday(&time_last, NULL);
 #endif
+#endif
+       discarded++;
+       if (rx_byte == 0x55)
+         discarded55++;
       }    
       }    
-    break;
+    break;
 
   case FBUS_RX_GetDestination:
 
 
   case FBUS_RX_GetDestination:
 
@@ -385,6 +407,7 @@ void FBUS_RX_StateMachine(unsigned char rx_byte) {
 
       /* Is the checksum correct? */
       if (checksum[0] == checksum[1]) {
 
       /* Is the checksum correct? */
       if (checksum[0] == checksum[1]) {
+u8 msgseq;
          
         if (RX_Multiple) {
 
          
         if (RX_Multiple) {
 
@@ -406,7 +429,7 @@ void FBUS_RX_StateMachine(unsigned char rx_byte) {
            }
            MultiMessageLength=MultiMessageLength+MessageLength-2;
 
            }
            MultiMessageLength=MultiMessageLength+MessageLength-2;
 
-            FBUS_SendAck(MessageType, MessageBuffer[MessageLength-1] & 0x0f);          
+           msgseq=MessageBuffer[MessageLength-1] & 0x0f;
                
             if ((MessageLength > 1) && (MessageBuffer[MessageLength-2] != 0x01))
             {
                
             if ((MessageLength > 1) && (MessageBuffer[MessageLength-2] != 0x01))
             {
@@ -420,15 +443,22 @@ void FBUS_RX_StateMachine(unsigned char rx_byte) {
               /* Do not debug Ack and RLP frames to detail. */
               if (MessageType != FBUS_FRTYPE_ACK && MessageType != 0xf1)
                 N61_RX_DisplayMessage();
               /* Do not debug Ack and RLP frames to detail. */
               if (MessageType != FBUS_FRTYPE_ACK && MessageType != 0xf1)
                 N61_RX_DisplayMessage();
+             else {
+               if (MessageType == FBUS_FRTYPE_ACK)
+                 puts("[ignoring print of ACK]");
+               else
+                 puts("[ignoring print of RLP]");
+               }
 
               GSM->DispatchMessage(MessageLength-2, MessageBuffer, MessageType);
             }
 
 
               GSM->DispatchMessage(MessageLength-2, MessageBuffer, MessageType);
             }
 
+            FBUS_SendAck(MessageType, msgseq);
+
          } else {
 
             /* We do not want to send ACK of ACKs and ACK of RLP frames. */
             if (MessageType != FBUS_FRTYPE_ACK && MessageType != 0xf1) {
          } else {
 
             /* We do not want to send ACK of ACKs and ACK of RLP frames. */
             if (MessageType != FBUS_FRTYPE_ACK && MessageType != 0xf1) {
-              FBUS_SendAck(MessageType, MessageBuffer[MessageLength-1] & 0x0f);
 
               if ((MessageLength > 1) && (MessageBuffer[MessageLength-2] != 0x01))
               {
 
               if ((MessageLength > 1) && (MessageBuffer[MessageLength-2] != 0x01))
               {
@@ -438,13 +468,16 @@ void FBUS_RX_StateMachine(unsigned char rx_byte) {
 #endif
                 RX_State = FBUS_RX_Sync;
               }
 #endif
                 RX_State = FBUS_RX_Sync;
               }
+
+             msgseq=MessageBuffer[MessageLength-1] & 0x0f;
+             FBUS_SendAck(MessageType, msgseq);
             }
          }
         } else {
             }
          }
         } else {
+         msgseq=MessageBuffer[MessageLength-1] & 0x0f;
 
           /* We do not want to send ACK of ACKs and ACK of RLP frames. */
           if (MessageType != FBUS_FRTYPE_ACK && MessageType != 0xf1) {
 
           /* We do not want to send ACK of ACKs and ACK of RLP frames. */
           if (MessageType != FBUS_FRTYPE_ACK && MessageType != 0xf1) {
-            FBUS_SendAck(MessageType, MessageBuffer[MessageLength-1] & 0x0f);
 
             if ((MessageLength > 1) && (MessageBuffer[MessageLength-2] != 0x01))
             {
 
             if ((MessageLength > 1) && (MessageBuffer[MessageLength-2] != 0x01))
             {
@@ -458,17 +491,23 @@ void FBUS_RX_StateMachine(unsigned char rx_byte) {
            }
          }
 
            }
          }
 
-          if (!RX_Multiple && MessageDestination!=FBUS_DEVICE_PHONE ) {
+          if (!RX_Multiple /* && MessageDestination!=FBUS_DEVICE_PHONE */ ) {
             /* Do not debug Ack and RLP frames to detail. */
             if (MessageType != FBUS_FRTYPE_ACK && MessageType != 0xf1)
               N61_RX_DisplayMessage();
             /* Do not debug Ack and RLP frames to detail. */
             if (MessageType != FBUS_FRTYPE_ACK && MessageType != 0xf1)
               N61_RX_DisplayMessage();
+           else {
+             if (MessageType == FBUS_FRTYPE_ACK)
+               puts("[ignoring print of ACK]");
+             else
+               puts("[ignoring print of RLP]");
+             }
 
             GSM->DispatchMessage(MessageLength-2, MessageBuffer, MessageType);
           }
 
 #ifdef DEBUG
           /* When make debug and message is to phone display it */
 
             GSM->DispatchMessage(MessageLength-2, MessageBuffer, MessageType);
           }
 
 #ifdef DEBUG
           /* When make debug and message is to phone display it */
-         if (MessageDestination==FBUS_DEVICE_PHONE) {
+         if (MessageDestination==FBUS_DEVICE_PHONE && !fbus_decoding) {
             for (i=MessageLength;i>=0;i--)
               MessageBuffer[i+6]=MessageBuffer[i];
             MessageBuffer[0]=FBUS_FRAME_ID;
             for (i=MessageLength;i>=0;i--)
               MessageBuffer[i+6]=MessageBuffer[i];
             MessageBuffer[0]=FBUS_FRAME_ID;
@@ -482,7 +521,12 @@ void FBUS_RX_StateMachine(unsigned char rx_byte) {
            NULL_TX_DisplayMessage(MessageLength, MessageBuffer);
           }
 #endif   
            NULL_TX_DisplayMessage(MessageLength, MessageBuffer);
           }
 #endif   
+          if (MessageType != FBUS_FRTYPE_ACK && MessageType != 0xf1)
+           FBUS_SendAck(MessageType, msgseq);
        }
        }
+#ifdef DEBUG
+       putchar('\n');
+#endif
       } else {
 #ifdef DEBUG
           fprintf(stdout, _("Bad checksum %02x (should be %02x), msg len=%i !\n"),checksum[0],checksum[1],MessageLength);
       } else {
 #ifdef DEBUG
           fprintf(stdout, _("Bad checksum %02x (should be %02x), msg len=%i !\n"),checksum[0],checksum[1],MessageLength);
index c8db700..4da6169 100644 (file)
@@ -66,6 +66,8 @@
 #include "files/gsm-filetypes.h"
 #include "gnokii.h"
 
 #include "files/gsm-filetypes.h"
 #include "gnokii.h"
 
+#include "protocol/fbus.h"
+
 #ifdef USE_NLS
   #include <locale.h>
 #endif
 #ifdef USE_NLS
   #include <locale.h>
 #endif
@@ -7513,20 +7515,31 @@ int decodefile(int argc, char *argv[])
  int i = 0;
 
   /* base model comes from gnokiirc */
  int i = 0;
 
   /* base model comes from gnokiirc */
+#if 0
   strcat(model,"decode");
   strcat(model,"decode");
+#else
+  strcpy(model,"5190sniff");
+  fbus_decoding=1;
+#endif
 
  /* Initialise the GSM interface. */
  fbusinit(NULL);
 
 
  /* Initialise the GSM interface. */
  fbusinit(NULL);
 
- printf ("open InPutFile: %s\n", argv[0]);
+ printf ("open InPutFile: %s\n\n\n", argv[0]);
  if ( (infile = fopen( argv[0], "rb")) == NULL ) {
    printf ("Failed to open InPutFile: %s\n", argv[0]);
    exit (1); }
 
  while ( (nr_read = fread(in_buffer, 1, 16, infile)) > 0 ) {
  if ( (infile = fopen( argv[0], "rb")) == NULL ) {
    printf ("Failed to open InPutFile: %s\n", argv[0]);
    exit (1); }
 
  while ( (nr_read = fread(in_buffer, 1, 16, infile)) > 0 ) {
+static int last=0;
+       if (ftell(infile)>last+1000) {
+               last=ftell(infile);
+               printf("ftell=%d\n",last);
+               }
   for (i=0; i < nr_read; i++)
      Protocol->StateMachine(in_buffer[i]);
   }
   for (i=0; i < nr_read; i++)
      Protocol->StateMachine(in_buffer[i]);
   }
+   puts("gnokii/decodefile() done");
 
    return 0;
 }
 
    return 0;
 }
index a5dae23..e9310a6 100644 (file)
 /* Define if you compile for M$ Windows */
 #undef WIN32
 
 /* Define if you compile for M$ Windows */
 #undef WIN32
 
+
+/* "decode" brach hacks:
+ */
+#define _XOPEN_SOURCE 1
+
+#include <unistd.h>
+#undef usleep
+#define usleep(x)
+
+
 #endif /* __CONFIG_H__ */
 #endif /* __CONFIG_H__ */
index 1340262..a8d3c97 100644 (file)
@@ -49,6 +49,8 @@ enum FBUS_RX_States {
   FBUS_RX_GetMessage
 };
 
   FBUS_RX_GetMessage
 };
 
+extern int fbus_decoding;
+
 GSM_Error FBUS_Initialise(char *port_device, char *initlength,
                           GSM_ConnectionType connection,
                           void (*rlp_callback)(RLP_F96Frame *frame));
 GSM_Error FBUS_Initialise(char *port_device, char *initlength,
                           GSM_ConnectionType connection,
                           void (*rlp_callback)(RLP_F96Frame *frame));