• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 442
  • Last Modified:

srec file.

I have needs for an 'srec' file.  To do this, I thought perhaps I could first create a binary file, then convert the file to srec using a 'tool' called objcopyppc.

So now:

int main()
 {
  char mbyte[ 1048576];
  std::ofstream ofile( "bigfile.bin" );
  int i = 0;
  int m = 0;
  std::cout << "how many MiB shall I write? ";
  std::cin >> m;

  for( i = 0; i < m; ++i )
       ofile.write( (char*)mbyte, sizeof mbyte );

  return 0;
 }

I'll need to tweak the code above to ask the user to select a pattern. ie.  Choose betwen all zeros, or all ones or a counting pattern (1, 2, 3, .. ).
Conversly is it possible to just write code that'll generate the srec file withouth going through all this.  



0
forums_mp
Asked:
forums_mp
1 Solution
 
smpoojaryCommented:
Update your code
std::ofstream ofile( "bigfile.bin" ,ios::out | ios::binary); //Otherwise file considers as text file

intialize mbyte with data

strcpy(mbyte,"111111111111111111111111111111111111111111111");

I don't know what you are going to do. Means I don't know about srec ....
-Mahesh
0
 
forums_mpAuthor Commented:

Actually, I discovered that what I needed to do was a lot simpler than what I proposed in my initial post.   So revisiting.  I need to create a 64 MiB file with all ones or zeros.   I'm working with 'two environments'.  Visual Studio. NET and Tornado.  

So now step 1.

Within visual studio, I create this simple program that'll create a 28 Byte size file.  

# include<iostream>
# include<iomanip>

#define MAX  7

int main( void )
{
   std::cout << std::endl; std::cout << std::endl;
   std::cout << "# include<iostream> " << std::endl;
   std::cout << "# define MAX  " << MAX << std::endl;
   std::cout << std::endl; std::cout << std::endl;

   std::cout << " int huge_array[" << MAX << "] = {" << std::endl;
   for (int idx(0); idx < MAX - 1; ++idx)
         std::cout << std::setw(15)
                   << "   0xFFFFFFFF, " 
//                   << "   0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF  "
                         << std::endl;

   std::cout << "   0xFFFFFFFF " << std::endl;
   std::cout << " } " << std::endl;
   std::cout << std::endl; std::cout << std::endl;
   std::cout << " int main() " << std::endl;
   std::cout << " { " << std::endl;
   std::cout << " } " << std::endl;
}

Lets assume executable is test.exe.  

Step 2.

From the command line I do:
 c:\test_project\Debug\test.exe >  test.c

Now test.c looks like:

# include<iostream>
# define MAX  7


 int huge_array[7] = {
   0xFFFFFFFF,
   0xFFFFFFFF,
   0xFFFFFFFF,
   0xFFFFFFFF,
   0xFFFFFFFF,
   0xFFFFFFFF,
   0xFFFFFFFF
 }

 int main()
 {
 }

Step 3.

I move over to tornado and execute/run test.c.  I end up with an object file (.o) thats 28 bytes.
I then use that 28 byte file to create my srec file.

You see, the Visual studio approach is a way for me to 'cheat' in terms of creatign the array.  i.e instead of typing huge_array's parameters by hand, I just use cout.   Now here's the trouble spot.  For a 64 MiB file MAX needs to be (16777216).   When I do
c:\test_project\Debug\test.exe >  test.c.  This takes time.  Furthermore, when I opt to open test.c within tornado or any text editor etc.  I get memory errors (pc has no memory).  

I'm not sure what to do here?
0
 
NetminderCommented:
Closed, 75 points refunded.
Netminder
Site Admin
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Cloud Class® Course: Microsoft Office 2010

This course will introduce you to the interfaces and features of Microsoft Office 2010 Word, Excel, PowerPoint, Outlook, and Access. You will learn about the features that are shared between all products in the Office suite, as well as the new features that are product specific.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now