I am trying to get the 240 Link Control Word bits out of the LDU1 frame using this:
void ldu1::decode_lcw() { const size_t LCW_BITS[] = { 410, 411, 412, 413, 414, 415, 416, 417, 418, 419, 420, 421, 422, 423, 424, 425, 426, 427, 428, 429, 432, 433, 434, 435, 436, 437, 438, 439, 440, 441, 442, 443, 444, 445, 446, 447, 448, 449, 450, 451, 600, 601, 602, 603, 604, 605, 606, 607, 608, 609, 610, 611, 612, 613, 614, 615, 616, 617, 618, 619, 620, 621, 622, 623, 624, 625, 626, 627, 628, 629, 630, 631, 632, 633, 634, 635, 636, 637, 638, 639, 788, 789, 792, 793, 794, 795, 796, 797, 798, 799, 800, 801, 802, 803, 804, 805, 806, 807, 808, 809, 810, 811, 812, 813, 814, 815, 816, 817, 818, 819, 820, 821, 822, 823, 824, 825, 826, 827, 828, 829, 978, 979, 980, 981, 982, 983, 984, 985, 986, 987, 988, 989, 990, 991, 992, 993, 994, 995, 996, 997, 998, 999, 1000, 1001, 1002, 1003, 1004, 1005, 1008, 1009, 1010, 1011, 1012, 1013, 1014, 1015, 1016, 1017, 1018, 1019, 1168, 1169, 1170, 1171, 1172, 1173, 1174, 1175, 1176, 1177, 1178, 1179, 1180, 1181, 1182, 1183, 1184, 1185, 1186, 1187, 1188, 1189, 1190, 1191, 1192, 1193, 1194, 1195, 1196, 1197, 1198, 1199, 1200, 1201, 1202, 1203, 1204, 1205, 1206, 1207, 1356, 1357, 1358, 1359, 1360, 1361, 1362, 1363, 1364, 1365, 1368, 1369, 1370, 1371, 1372, 1373, 1374, 1375, 1376, 1377, 1378, 1379, 1380, 1381, 1382, 1383, 1384, 1385, 1386, 1387, 1388, 1389, 1390, 1391, 1392, 1393, 1394, 1395, 1396, 1397, }; int * encoded_lcw = new int[240]; yank(frame_body(), LCW_BITS, 240, encoded_lcw, 0); correct_lcw( encoded_lcw ); delete [] encoded_lcw; }
What am I doing wrong here? the output is obviously wrong:
LDU1 LCW Data-------------------------------------------- ----------------------------------------------------------- Encoded LCW: LCF: 00111011 MFID: 00110000 TGID: 0000000100000000 Source ID: 000100000000000001000100
Hamming decode: LCF: 00111011 MFID: 00110000 TGID: 0000000000000000 Source ID: 000000000000000000000000
RS decode: LCF: 00111011 MFID: 00110000 TGID: 0000000000000000 Source ID: 000000000000000000000000 ------------------------------------------------------------
I am pretty sure there is something wrong with how I am using the yank(), but I have been able to find something else to try. Any help will be much appreciated. Thanks.
I am pretty sure there is something wrong with how I am using the yank(), but I have been able to find something else to try. Any help will be much appreciated. Thanks.
OK so I changed how I am getting the bits and it appears that I am getting the correct bits:
LDU1 LCW Data-------------------------------------------- ----------------------------------------------------------- Encoded LCW: LCF: 00000000 MFID: 00000000 TGID: 0000000000000001 Source ID: 010011000100110101100010
Hamming decode: LCF: 00000000 MFID: 00000000 TGID: 0000000000000001 Source ID: 010011000100110101100010
RS decode: LCF: 00000000 MFID: 00000000 TGID: 0000000000000001 Source ID: 010011000100110101100010 ------------------------------------------------------------
but now op25 dies with this error:
(gdb) frame 0 #0 extract<std::vector<bool, std::allocator<bool> > > (in=..., bits=bits@entry=0xa322bce0, bits_sz=bits_sz@entry=8) at ./op25_yank.h:109 109 x = (x << 1) | (in[bits[i]] ? 1 : 0);
The first argument of extract() takes a vector, so i start by filling a vector typed bit_vector. And then to get that vector I call a function typed cons_bit_vector that returns that vector. This is how i see it is done in abstract_data_unit.cc with the function frame_body(). Can anyone please help me figure out what I am dong wrong here? any help will be much appreciated.
Sorry for the late reply on this but I fear you are returning a reference to a variable that's on the stack (and hence out-of-scope by the time control returns from the call). The bit pattern maybe there in memory but you are making an illegal access.
Lets see the code snippet for the function and we can help.
Lets see the code snippet for the function and we can help.
Hey thanks, i define th vecotr in the .h:
//bit vector to store the errror corrected link control word bit_vector decoded_lcw_vec;
i fill th vector like this:
bit_vector decoded_lcw_vec(corrected_array, corrected_array + sizeof corrected_array / sizeof corrected_array[0]) ;
and I can see the right values are there using cout. i have a function to return the vector:
const_bit_vector& ldu1::get_vec() const { return decoded_lcw_vec; }
and then I use the that funtion as the arguement in extract:
uint16_t ldu1::lcf() const { const size_t LCF_BITS[] = { 0, 1, 2, 3, 4, 5, 6 , 7 }; const size_t LCF_BITS_SZ = sizeof(LCF_BITS) / sizeof(LCF_BITS[0]); const uint16_t lcf = extract(get_vec(), LCF_BITS, LCF_BITS_SZ); return lcf;
}
Thanks!
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1
If this is the case what can be done?
On 12/09/2013 06:19 PM, Steve Glass wrote:
Sorry for the late reply on this but I fear you are returning a reference to a variable that's on the stack (and hence out-of-scope by the time control returns from the call). The bit pattern maybe there in memory but you are making an illegal access.
Lets see the code snippet for the function and we can help.
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1
On 12/11/2013 01:27 PM, Matt D wrote:
If this is the case what can be done?
On 12/09/2013 06:19 PM, Steve Glass wrote:
Sorry for the late reply on this but I fear you are returning a reference to a variable that's on the stack (and hence out-of-scope by the time control returns from the call). The bit pattern maybe there in memory but you are making an illegal access.
Lets see the code snippet for the function and we can help.
OK, so the problem has got to be that I put the type 'bit_vector' in front of the 'decoded_lcw_vec' in the .cc file. But if I don't put the type there I get a compile error, which is the reason I put the type there in the first place. If I use an array and declare it private in the .h then the program works and i get error corrected values in the UI. should i just stick with this or is there some reason I should be using the bit_vector type?