TDOA 之 基站邏輯代碼實現


在前一篇博文里描述了基站的邏輯部分,這里貼出來具體代碼實現。https://www.cnblogs.com/tuzhuke/p/11689881.html

1 Sync 信息部分

case 'S':
            //save seq
            bphero_sync_message[bphero_sync_count].seq_num = msg_f->seqNum;
            //save rx timestamp
            bphero_sync_message[bphero_sync_count].rx_timestamp = get_rx_timestamp_u64();
            //save delayed tx timestamp
            //bphero_sync_message[bphero_sync_count].rx_timestamp = final_msg_get_ts();
            //save shortaddr
            bphero_sync_message[bphero_sync_count].shortaddr = msg_f->sourceAddr[1]<<8|msg_f->sourceAddr[0];

            bphero_sync_count++;
            if(bphero_sync_count == 2)
            {
                //判斷連續兩次Sync信號是否連續
                if(bphero_sync_message[1].seq_num = bphero_sync_message[0].seq_num + 1)//uint8,255+1 = 0
                {
                    //判斷兩個sync信號之間知否有Tag信號
                    if(bphero_tag_num>0)
                    {
                        //將收到的SYNC 信號和TAG 信號全部通過串口送出去
                    }
                }
                //只要接收到兩個SYNC信號,就要清除目前所有信息
                bphero_tag_num = 0;
                bphero_sync_count=0;

2 TAG信息部分

 case 'T':
        //save seq
        bphero_tag_message[bphero_tag_num].seq_num = msg_f->seqNum;
        //save rx timestamp
        bphero_tag_message[bphero_tag_num].rx_timestamp = get_rx_timestamp_u64();
        //save delayed tx timestamp
        // bphero_tag_message[bphero_tag_num].rx_timestamp = final_msg_get_ts();
        //save shortaddr
        bphero_tag_message[bphero_tag_num].shortaddr = msg_f->sourceAddr[1]<<8|msg_f->sourceAddr[0];

        bphero_tag_num++;
        if(bphero_tag_num == MAX_TAG_NODE )
        {
            bphero_tag_num = 0;
        }
        break;             

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM