Function not executing

my function, decode_lcw() is not executing and i can not figure out why.

Here is my code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
std::string
ldu1::snapshot() 
{ 
     pickle p; 
     p.add("duid", duid_str()); // calls a function that calls decode_lcw()
     p.add("nac", nac_str());   // same for all these so these calls is 
     p.add("mfid", mfid_str()); // what should call the decode_lcw 
     p.add("tgid", tgid_str());  // see these function definitions below
     p.add("source", source_str());  // for a couple of examples
     return p.to_string();
}

//240 Link Control Word bits
uint16_t*
ldu1::decode_lcw() 
{
   const size_t LCW_BITS[] = {
      410,  411,  412,  413,  414,  415,  416,  417,  418,  419,  420,  421,
      422,  . . . .................
   };
   const uint16_t LCW_BITS_SZ = sizeof(LCW_BITS) / sizeof(LCW_BITS[0]);
   uint16_t * encoded_lcw = new uint16_t[240];
   yank(frame_body(), LCW_BITS, LCW_BITS_SZ, encoded_lcw, 0);
      int i;
      printf("encoded lcw\n");
      for(i=0;i<72;i++)
      printf("%d",encoded_lcw[i]);
      fflush(stdout);
      printf("\n");
   uint16_t * rs_codewords = new uint16_t[144];
   decode_hamming( encoded_lcw, rs_codewords );
   delete [] encoded_lcw;
   uint16_t * decoded_lcw = new uint16_t[72];
   decode_reed_solomon( rs_codewords, decoded_lcw );
   delete [] rs_codewords;
   return decoded_lcw;
      printf("decoded lcw\n");
      for(i=0;i<72;i++)
      printf("%d",decoded_lcw[i]);
      fflush(stdout);
      printf("\n");
}


string 
ldu1::mfid_str() 
{
   const size_t MFID_BITS[] = {
      8, 9, 10, 11, 12, 13, 14, 15
   };
   const size_t MFID_BITS_SZ = sizeof(MFID_BITS) / sizeof(MFID_BITS_SZ);
   uint8_t mfid = extract(decode_lcw(), MFID_BITS, MFID_BITS_SZ);
   return lookup(mfid, MFIDS, MFIDS_SZ);
}

string
ldu1::tgid_str() 
{
   const size_t TGID_BITS[] = {
      32, 33, 34, 35, 36, 37, 38, 39,
      40, 41, 42, 43, 44, 45, 46, 47,
   };
   const size_t TGID_BITS_SZ = sizeof(TGID_BITS) / sizeof(TGID_BITS[0]);
   const uint16_t tgid = extract(decode_lcw(), TGID_BITS, TGID_BITS_SZ);
   ostringstream os;
   os << hex << showbase << setfill('0') << setw(4) << tgid;
   return os.str();
} 


This is not working the way i would have imagined. Any guidance will be much appreciated. Thanks!
Think about the effect of line 36 to lines 37-41. Doesn't your compiler comment on the same issue?
no it compiles complaint free. what is wrong here?? clearly i dont get it. i was trying to lay eyes on the array. i did that same code above as well. what should i change here? Thanks!
Last edited on
What happens on line 36?
supposed to return a pointer to that array. but i dont think it is.
supposed to return a pointer to that array.

And what happens when a function returns?

but i dont think it is.

Why don't you think it's returning the pointer?

because i am not getting any data in the pickle in the snapshot() . also lines 24 to 29 should be putting at least something in the terminal but i don't get anything.
That suggests that you're not calling decode_lcw() at all, which means you have a problem further up the call chain that we can't see.

I recommend you step through your program with a debugger, to see which statements it's executing and why.
right problem is i don't have debugger. i guess i just use gcc for that. i would have thought that the call to, for example, the call on line 7
 
p.add("mfid", mfid_str());

i thought that would call decode_lcw because of the call on line 52:
 
uint8_t mfid = extract(decode_lcw(), MFID_BITS, MFID_BITS_SZ);


apparently i am mistaken. is there something obvious here i am missing??
If you are using gcc, then I suspect you have access to gdb as a debugger. You should take a look at it.
its not a run time error here? i don't need to dump a core file.
Topic archived. No new replies allowed.