| 717 | } |
| 718 | |
| 719 | bool Transceiver::driveTransmitPriorityQueue(unsigned ARFCN) |
| 720 | { |
| 721 | |
| 722 | char buffer[gSlotLen+50]; |
| 723 | |
| 724 | // check data socket |
| 725 | size_t msgLen = mDataSocket[ARFCN]->read(buffer); |
| 726 | |
| 727 | ScopedLock lock(mTransmitPriorityQueueLock); |
| 728 | |
| 729 | if (msgLen!=gSlotLen+1+4+1) { |
| 730 | LOG(ERR) << "badly formatted packet on GSM->TRX interface"; |
| 731 | return false; |
| 732 | } |
| 733 | |
| 734 | int timeSlot = (int) buffer[0]; |
| 735 | int fillerFlag = timeSlot & SET_FILLER_FRAME; // Magic flag says this is a filler burst. |
| 736 | timeSlot = timeSlot & 0x7; |
| 737 | uint64_t frameNum = 0; |
| 738 | for (int i = 0; i < 4; i++) |
| 739 | frameNum = (frameNum << 8) | (0x0ff & buffer[i+1]); |
| 740 | |
| 741 | |
| 742 | /* |
| 743 | if (GSM::Time(frameNum,timeSlot) > mTransmitDeadlineClock + GSM::Time(51,0)) { |
| 744 | // stale burst |
| 745 | //LOG(DEBUG) << "FAST! "<< GSM::Time(frameNum,timeSlot); |
| 746 | //writeClockInterface(); |
| 747 | }*/ |
| 748 | |
| 749 | /* |
| 750 | DAB -- Just let these go through the demod. |
| 751 | if (GSM::Time(frameNum,timeSlot) < mTransmitDeadlineClock) { |
| 752 | // stale burst from GSM core |
| 753 | LOG(NOTICE) << "STALE packet on GSM->TRX interface at time "<< GSM::Time(frameNum,timeSlot); |
| 754 | return false; |
| 755 | } |
| 756 | */ |
| 757 | |
| 758 | // periodically update GSM core clock |
| 759 | //LOG(DEBUG) << "mTransmitDeadlineClock " << mTransmitDeadlineClock |
| 760 | // << " mLastClockUpdateTime " << mLastClockUpdateTime; |
| 761 | if (mTransmitDeadlineClock > mLastClockUpdateTime + GSM::Time(216,0)) |
| 762 | writeClockInterface(); |
| 763 | |
| 764 | |
| 765 | LOG(DEBUG) << "rcvd. burst at: " << GSM::Time(frameNum,timeSlot) <<LOGVAR(fillerFlag); |
| 766 | |
| 767 | int RSSI = (int) buffer[5]; |
| 768 | static BitVector newBurst(gSlotLen); |
| 769 | BitVector::iterator itr = newBurst.begin(); |
| 770 | char *bufferItr = buffer+6; |
| 771 | while (itr < newBurst.end()) |
| 772 | *itr++ = *bufferItr++; |
| 773 | |
| 774 | GSM::Time currTime = GSM::Time(frameNum,timeSlot); |
| 775 | |
| 776 | radioVector *newVec = fixRadioVector(newBurst,RSSI,currTime,ARFCN); |