Logo Search packages:      
Sourcecode: icomlib version File versions  Download package

bool PCP::PCPSetSpeed ( tcflag_t  speed  ) 

Sets the speed for current session.

Parameters:
speed baudrate as defined in termios.h
First we check to see if the baudrate passed in speed is right, if not then we just quietly return false. Then we decode speed and set PCPInitSpeed to pcrcmd_t version.

Then we tell the radio to switch speeds and set baudrate on the port by destroying PComm and reinitiating it with the new baud setting

Warning: follow these procedures to use this function.

  • create the object (at last known baudrate).
  • call init
  • call power up
  • call this function
  • delete the object
  • create the object with the new speed setting

Returns:
true or false based on success.
See also:
PCPGetSpeed PCPGetSpeed_t pcrcmd_t pcrdef.h PCPComm

Definition at line 173 of file pcp.cpp.

References PCPComm, PRadInf::PCPInitSpeed, PRadInf::PCPPort, PCPRadio, PRadInf::PCPSpeed, and PComm::PCTell().

{
    if ( (B300<=speed)&&(speed<=B38400) ) {
      memset(PCPRadio->PCPInitSpeed, '\0', sizeof(PCPRadio->PCPInitSpeed));
        switch (speed) {
                case B38400:
                        // you probably want to set the speed
                        // to fastest available, so let's put
                        // this here first
                        strncpy(PCPRadio->PCPInitSpeed, PCRBD38400,
                                sizeof(PCPRadio->PCPInitSpeed)-1);
                        break;
                case B19200:
                        strncpy(PCPRadio->PCPInitSpeed, PCRBD19200,
                                sizeof(PCPRadio->PCPInitSpeed)-1);
                        break;
                case B300:
                        strncpy(PCPRadio->PCPInitSpeed, PCRBD300,
                                sizeof(PCPRadio->PCPInitSpeed)-1);
                        break;
                case B1200:
                        strncpy(PCPRadio->PCPInitSpeed, PCRBD1200,
                                sizeof(PCPRadio->PCPInitSpeed)-1);
                        break;
                case B2400:
                        strncpy(PCPRadio->PCPInitSpeed, PCRBD2400,
                                sizeof(PCPRadio->PCPInitSpeed)-1);
                        break;
                default:
                        // if all else fails, we'll always
                        // have paris! ~=^)
                        strncpy(PCPRadio->PCPInitSpeed, PCRBD9600,
                                sizeof(PCPRadio->PCPInitSpeed)-1);
        }
      PCPComm->PCTell(PCPRadio->PCPInitSpeed);
        delete PCPComm;
        PCPComm = new PComm(PCPRadio->PCPPort, speed, "PCPComm_R");
// investigate possible responses, i dont think one is given.
//    PCPCheckResponse();
            PCPRadio->PCPSpeed = speed;
            return true;
    }

    return false;
}


Generated by  Doxygen 1.6.0   Back to index