Changeset 5490

Show
Ignore:
Timestamp:
10/24/07 09:29:32 (6 years ago)
Author:
jgaeddert
Message:

working on PACKET_RS_512 subheader decoder; still does not pass simple test

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • experimental/components/Packetizer/trunk/Packetizer-metadata/src/PacketizerDSP.cpp

    r5489 r5490  
    534534    // port_id      16 
    535535    // expansion    64 
    536     buf1[0] = (packet_id >> 0)  & 0x0F; 
    537     buf1[1] = (packet_id >> 4)  & 0x0F; 
    538     buf1[2] = (packet_id >> 8)  & 0x0F; 
    539     buf1[3] = (packet_id >> 12) & 0x0F; 
    540  
    541     buf1[4] = (src_id >> 0 ) & 0x0F; 
    542     buf1[5] = (src_id >> 4 ) & 0x0F; 
    543  
    544     buf1[6] = (dst_id >> 0 ) & 0x0F; 
    545     buf1[7] = (dst_id >> 4 ) & 0x0F; 
    546  
    547     buf1[8] = (app_id >> 0 ) & 0x0F; 
    548     buf1[9] = (app_id >> 4 ) & 0x0F; 
    549  
    550     buf1[10] = (port_id >> 0 ) & 0x0F; 
    551     buf1[11] = (port_id >> 4 ) & 0x0F; 
     536    printf("packet_id = %d\n", packet_id); 
     537    buf1[0] = (packet_id >> 0)  & 0xFF; 
     538    buf1[1] = (packet_id >> 8)  & 0xFF; 
     539    buf1[2] = (packet_id >> 16) & 0xFF; 
     540    buf1[3] = (packet_id >> 24) & 0xFF; 
     541    printf("buf1[0] = %d\n", buf1[0]); 
     542    printf("buf1[1] = %d\n", buf1[1]); 
     543    printf("buf1[2] = %d\n", buf1[2]); 
     544    printf("buf1[3] = %d\n", buf1[3]); 
     545    printf("packet_id = %d\n", packet_id); 
     546 
     547    buf1[4] = (src_id >> 0 ) & 0xFF; 
     548    buf1[5] = (src_id >> 8 ) & 0xFF; 
     549 
     550    buf1[6] = (dst_id >> 0 ) & 0xFF; 
     551    buf1[7] = (dst_id >> 8 ) & 0xFF; 
     552 
     553    buf1[8] = (app_id >> 0 ) & 0xFF; 
     554    buf1[9] = (app_id >> 8 ) & 0xFF; 
     555 
     556    buf1[10] = (port_id >> 0 ) & 0xFF; 
     557    buf1[11] = (port_id >> 8 ) & 0xFF; 
    552558 
    553559    buf1[12] = 7; 
     
    561567        crc.PutByte(buf1[i]); 
    562568    UINT32 crc_code = crc.Done(); 
    563  
    564     buf1[16] = (crc_code >> 0 )  & 0x0F; 
    565     buf1[17] = (crc_code >> 4 )  & 0x0F; 
    566     buf1[18] = (crc_code >> 8 )  & 0x0F; 
    567     buf1[19] = (crc_code >> 12 ) & 0x0F; 
     569    std::cout << "crc (encoder): 0x" << std::hex << crc_code << std::endl; 
     570 
     571    buf1[16] = (crc_code >> 0 )  & 0xFF; 
     572    buf1[17] = (crc_code >> 8 )  & 0xFF; 
     573    buf1[18] = (crc_code >> 16 ) & 0xFF; 
     574    buf1[19] = (crc_code >> 24 ) & 0xFF; 
     575    for (unsigned int i=0; i<4; i++) 
     576        printf("crc[%d] = %d\n", i, (unsigned int) (buf1[16+i])); 
    568577 
    569578    // 3. repack 20 8-bit symbols (+2 bits) into 27 6-bit symbols 
     
    587596 
    588597    // 5. unpack to output buffer 
    589     SigProc::repack_bytes(buf1, 6, 27, output, 1, output_length, &num_written); 
     598    SigProc::repack_bytes(buf1, 6, 35, output, 1, output_length, &num_written); 
    590599    num_written += 3; // pad to 213 
    591600    printf("PACKET_RS_512 subheader: num_written: %d (should be 213)\n", num_written); 
     
    777786        crc.PutByte( buf2[i] ); 
    778787    UINT32 crc_code = crc.Done(); 
    779     unsigned long crc_rx(0); 
    780     for (unsigned int i=1; i<4; i++) { 
    781         crc_rx <<= 4; 
    782         crc_rx |= buf2[20-i-1]; 
    783     } 
    784     //printf("crc_rx = %d, crc_code = %d\n", crc_rx, crc_code); 
    785     std::cout << "crc_rc: 0x" << std::hex << crc_rx << ", crc_code = 0x" << crc_code << std::endl; 
     788    UINT32 crc_rx(0); 
     789    for (unsigned int i=0; i<4; i++) 
     790        printf("crc[%d] = %d\n", i, (unsigned char) (buf2[16+i])); 
     791    for (unsigned int i=0; i<4; i++) { 
     792        crc_rx <<= 8; 
     793        crc_rx |= 0xFF & (UINT32) (buf2[20-i-1]); 
     794    } 
     795    crc_rx = 0; 
     796    crc_rx |= (buf2[16] << 0); 
     797    crc_rx |= (buf2[17] << 8); 
     798    crc_rx |= (buf2[18] << 16); 
     799    crc_rx |= (buf2[19] << 24); 
     800    std::cout << "crc_rx: 0x" << std::hex << crc_rx << ", crc_code = 0x" << crc_code << std::endl; 
     801    if (crc_rx != crc_code) { 
     802        printf("ERROR! PACKET_RS_512 subheader did not pass cyclic redundancy check\n"); 
     803        //return false; 
     804    } else { 
     805        printf("PACKET_RS_512 subheader passed cyclic redundancy check\n"); 
     806    } 
    786807 
    787808    // 5. decode 16 8-bit symbols... 
    788      
     809    // variable     num bits 
     810    // ----         ---- 
     811    // packet_id    32 
     812    // src_id       16 
     813    // dst_id       16 
     814    // app_id       16 
     815    // port_id      16 
     816    // expansion    64 
     817    packet_id = 0; 
     818    printf("buf2[0] = %d\n", buf2[0]); 
     819    printf("buf2[1] = %d\n", buf2[1]); 
     820    printf("buf2[2] = %d\n", buf2[2]); 
     821    printf("buf2[3] = %d\n", buf2[3]); 
     822    for (unsigned int i=0; i<4; i++) { 
     823        packet_id <<= 8; 
     824        packet_id |= 0xFF & (unsigned long) (buf2[4-i-1]); 
     825    } 
     826    packet_id = 0; 
     827    packet_id |= (buf2[0] << 0); 
     828    packet_id |= (buf2[1] << 8); 
     829    packet_id |= (buf2[2] << 16); 
     830    packet_id |= (buf2[3] << 24); 
     831 
     832    src_id = 0; 
     833    src_id |= buf2[5]; 
     834    src_id <<= 8; 
     835    src_id |= buf2[4]; 
     836/* 
     837    buf1[6] = (dst_id >> 0 ) & 0x0F; 
     838    buf1[7] = (dst_id >> 4 ) & 0x0F; 
     839 
     840    buf1[8] = (app_id >> 0 ) & 0x0F; 
     841    buf1[9] = (app_id >> 4 ) & 0x0F; 
     842 
     843    buf1[10] = (port_id >> 0 ) & 0x0F; 
     844    buf1[11] = (port_id >> 4 ) & 0x0F; 
     845 
     846    buf1[12] = 7; 
     847    buf1[13] = 7; 
     848    buf1[14] = 7; 
     849    buf1[15] = 7; 
     850*/ 
    789851    return true; 
    790852}