当前位置: 首页>>代码示例>>C++>>正文


C++ SerialPort::Out方法代码示例

本文整理汇总了C++中SerialPort::Out方法的典型用法代码示例。如果您正苦于以下问题:C++ SerialPort::Out方法的具体用法?C++ SerialPort::Out怎么用?C++ SerialPort::Out使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在SerialPort的用法示例。


在下文中一共展示了SerialPort::Out方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: SonarChipWrite

/*!
 * \brief write to the chip
 * \param serial serial port object
 * \param timeout_mS communications timeout in milliseconds
 * \return true if successful
 */
bool SonarChipWrite(
    SerialPort &serial,
    unsigned timeout_mS)
{
    sbuf[0] = I2C_CMD;
    sbuf[1] = 0x40;
    if ((write_x & 3) == 3)
        sbuf[2] = 0xfe;
    else
        sbuf[2] = 0xff;
    write_x++;

    CurrentTransmissionType = TRANSMISSION_CHIP_WRITE;

    if (serial.Out(sbuf, 3, timeout_mS) > 0)
        return true;
    else
        return false;
}
开发者ID:NIFTi-Fraunhofer,项目名称:nifti_uav,代码行数:25,代码来源:sonar.cpp

示例2: SetSensorAddress

/*!
 * \brief sets the address of a sensor
 * \param serial serial port object
 * \param sensor_address address
 * \param timeout_mS communications timeout in milliseconds
 * \return true if successful
 */
bool SetSensorAddress(
    SerialPort &serial,
    unsigned char sensor_address,
    unsigned timeout_mS)
{
    if ((sensor_address <= 0xfe) && (sensor_address >= 0xe0)) {
        sbuf[0] = CM01_CMD;
        sbuf[1] = 0x02;
        sbuf[2] = sensor_address;
        sbuf[3] = 0;

        CurrentTransmissionType = TRANSMISSION_SET_ADDRESS;
        if (serial.Out(sbuf, 4, timeout_mS) > 0)
            return true;
        else
            return false;
    }
    else {
        ROS_ERROR("SRF08 invalid sensor address: %d", (int)sensor_address);
        return false;
    }
}
开发者ID:NIFTi-Fraunhofer,项目名称:nifti_uav,代码行数:29,代码来源:sonar.cpp

示例3: SonarRead

/*!
 * \brief sends a request to read the time of flight of a previous ping
 * \param serial serial port object
 * \param sensor_address address
 * \param timeout_mS communications timeout in milliseconds
 * \return true if successful
 */
bool SonarRead(
    SerialPort &serial,
    unsigned char sensor_address,
    unsigned timeout_mS)
{
    if ((sensor_address <= 0xfe) && (sensor_address >= 0xe0)) {                      
        sbuf[0] = I2C_CMD;  // send sonar read command
        sbuf[1] = (unsigned char)(sensor_address+1);
        sbuf[2] = 0x00;
        sbuf[3] = 0x04;

        CurrentTransmissionType = TRANSMISSION_READ;
        if (serial.Out(sbuf, 4, timeout_mS) > 0)
            return true;
        else
            return false;
    }
    else {
        ROS_ERROR("SRF08 invalid sensor address: %d",(int)sensor_address);
        return false;
    }
}
开发者ID:NIFTi-Fraunhofer,项目名称:nifti_uav,代码行数:29,代码来源:sonar.cpp

示例4: SonarGainLimit

/*!
 * \brief sets the sensor gain
 * \param serial serial port object
 * \param sensor_address address
 * \param timeout_mS communications timeout in milliseconds
 * \return true if successful
 */
bool SonarGainLimit(
    SerialPort &serial,
    unsigned char sensor_address,
    unsigned timeout_mS)
{
    if ((sensor_address <= 0xfe) && (sensor_address >=0xe0)) {                      
        sbuf[0] = I2C_CMD; // send gain limit
        sbuf[1] = sensor_address;
        sbuf[2] = 0x01;
        sbuf[3] = 0x01;
        sbuf[4] = 20;
               
        CurrentTransmissionType = TRANSMISSION_GAIN;
        if (serial.Out(sbuf, 5, timeout_mS) > 0)
            return true;
        else
            return false;
    }
    else {
        ROS_ERROR("SRF08 invalid sensor address: %d",(int)sensor_address);
        return false;
    }
}
开发者ID:NIFTi-Fraunhofer,项目名称:nifti_uav,代码行数:30,代码来源:sonar.cpp

示例5: SonarPing

/*!
 * \brief sends out a ping
 * \param serial serial port object
 * \param sensor_address address
 * \param timeout_mS communications timeout in milliseconds
 * \return true if successful
 */
bool SonarPing(
    SerialPort &serial,
    unsigned char sensor_address,
    unsigned timeout_mS)
{
    if ((sensor_address <= 0xfe) && (sensor_address >=0xe0)) {                      
        sbuf[0] = I2C_CMD;  // send sonar rangeing (uS) command
        sbuf[1] = sensor_address;
        sbuf[2] = 0x00;
        sbuf[3] = 0x01;
        sbuf[4] = 0x52;
               
        CurrentTransmissionType = TRANSMISSION_PING;

        if (serial.Out(sbuf, 5, timeout_mS) > 0)
            return true;
        else
            return false;
    }
    else {
        ROS_ERROR("SRF08 invalid sensor address: %d",(int)sensor_address);
        return false;
    }
}
开发者ID:NIFTi-Fraunhofer,项目名称:nifti_uav,代码行数:31,代码来源:sonar.cpp


注:本文中的SerialPort::Out方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。