View Single Post
  #26 (permalink)  
Old April 1st, 2004, 02:39 PM
CNewbie CNewbie is offline
Authorized User
 
Join Date: Mar 2004
Posts: 23
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Ok Dave Here is the lastest Version. I finally got it to do the rest of the Packet. It will take this:

4840200039407F11237C57BDA3DB80D4B5D4859A3B323B2C31 9024B02301910B1E79024182070006420001B5F90333420003 620D006708F7EE7E8A4C76CC129020

and format it into this:

Code:
Thu Apr 01 13:39:11 2004
48 40 20 00 39 
40
7F 11 23 7C 57 BD A3 DB 80 D4 B5 D4 85 9A 3B 32 3B 2C 31 90 24 B0 23 01 91 0B 1E 79 02 41 82 07 00 06 42 00 01 B5 F9 03 33 42 00 03 62 0D 00 67 08 F7 EE 7E 8A 4C 76 CC 12 
90 20
As you can see, I haven't as of yet been able to figure out how to get it to 16 bytes per line, Maybe you can check my code and see where I am going wrong.

Thanks:

Code:
#include <fstream>
#include <iostream>
#include <cstring>
#include <ctime>
using namespace std;

void TimeHeader();

struct tm *area;
char *tzstr = "TZ=EST5EDT";
char RawPacket[227];

int main()
{ 
    int x = 0;
    int y = 0;
    int z = 0;
    int INSLength;
/**************************************
 Open Files for Reading and Writing
 *************************************/
    fstream Log("Log.txt",ios::in);
    fstream Parse("Parsed.txt",ios::out);
/**************************************
 Get Packet From Stream
 *************************************/
    Log.getline(RawPacket,227);
/**************************************
 Get and Display Time/Date Header
 *************************************/
    TimeHeader();
    Parse << asctime(area);
/**************************************
 Get Packet Length Byte
 *************************************/
INSLength = (RawPacket[8]-'0')*16+(RawPacket[9]-'0'); 
/*************************************
 Display 5 Byte Packet Header
 ************************************/
      do {
            Parse << RawPacket[x] << RawPacket[x+1] << " ";
            x++; x++;y++;
        }while (y!=5);

/*************************************
 Display Packet Acknowledgement Byte
 ************************************/
    Parse << endl << RawPacket[10] << RawPacket[11] << endl;
/*************************************
 Display Rest Of Packet Bytes Based on Length
 ************************************/
    x = 12;y = 0;
      do {
            Parse << RawPacket[x] << RawPacket[x+1] << " ";
            x++; x++;y++;
        }while (y!=INSLength);
/**************************************
 Display 2 Byte Packet Response
 *************************************/
    Parse << endl << RawPacket[x] << RawPacket[x+1] << " " << RawPacket[x+2] << RawPacket[x+3] << " ";
/**************************************
 Close Files
 *************************************/
    Log.close();
    Parse.close();

return 0;
}
/***************************************
 Display Time Header
****************************************/
void TimeHeader()
{
   time_t t;

   putenv(tzstr);
   tzset();

   t = time(NULL);
   area = localtime(&t);
}
Reply With Quote