| 446 | |
| 447 | |
| 448 | void Transceiver::driveControl() |
| 449 | { |
| 450 | |
| 451 | int MAX_PACKET_LENGTH = 100; |
| 452 | |
| 453 | // check control socket |
| 454 | char buffer[MAX_PACKET_LENGTH]; |
| 455 | int msgLen = -1; |
| 456 | buffer[0] = '\0'; |
| 457 | |
| 458 | msgLen = mControlSocket.read(buffer); |
| 459 | |
| 460 | if (msgLen < 1) { |
| 461 | return; |
| 462 | } |
| 463 | |
| 464 | char cmdcheck[4]; |
| 465 | char command[MAX_PACKET_LENGTH]; |
| 466 | char response[MAX_PACKET_LENGTH]; |
| 467 | |
| 468 | sscanf(buffer,"%3s %s",cmdcheck,command); |
| 469 | |
| 470 | writeClockInterface(); |
| 471 | |
| 472 | if (strcmp(cmdcheck,"CMD")!=0) { |
| 473 | LOG(WARNING) << "bogus message on control interface"; |
| 474 | return; |
| 475 | } |
| 476 | LOG(INFO) << "command is " << buffer; |
| 477 | |
| 478 | if (strcmp(command,"POWEROFF")==0) { |
| 479 | // turn off transmitter/demod |
| 480 | sprintf(response,"RSP POWEROFF 0"); |
| 481 | } |
| 482 | else if (strcmp(command,"POWERON")==0) { |
| 483 | // turn on transmitter/demod |
| 484 | if (!mTxFreq || !mRxFreq) |
| 485 | sprintf(response,"RSP POWERON 1"); |
| 486 | else { |
| 487 | sprintf(response,"RSP POWERON 0"); |
| 488 | if (!mOn) { |
| 489 | // Prepare for thread start |
| 490 | mPower = -20; |
| 491 | mRadioInterface->start(); |
| 492 | |
| 493 | // Start radio interface threads. |
| 494 | mTxServiceLoopThread->start((void * (*)(void*))TxServiceLoopAdapter,(void*) this); |
| 495 | mRxServiceLoopThread->start((void * (*)(void*))RxServiceLoopAdapter,(void*) this); |
| 496 | mTransmitPriorityQueueServiceLoopThread->start((void * (*)(void*))TransmitPriorityQueueServiceLoopAdapter,(void*) this); |
| 497 | writeClockInterface(); |
| 498 | |
| 499 | mOn = true; |
| 500 | } |
| 501 | } |
| 502 | } |
| 503 | else if (strcmp(command,"SETMAXDLY")==0) { |
| 504 | //set expected maximum time-of-arrival |
| 505 | int maxDelay; |
no test coverage detected