• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ err_SetMsg函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中err_SetMsg函数的典型用法代码示例。如果您正苦于以下问题:C++ err_SetMsg函数的具体用法?C++ err_SetMsg怎么用?C++ err_SetMsg使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



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

示例1: RBAPI

RBAPI(bool) com_FlushWFIFO(int com) {
    #if defined(RB_MSVC_WIN32) || defined(RB_MSVC_WINCE)
        if (FlushFileBuffers(COM_info[com].fp) == FALSE)
        {
            err_SetMsg(ERROR_COM_FAIL, "FlushFileBuffers() fails");
            return false;
        }
    #elif defined(RB_LINUX)
        if (COM_duplex[com] != COM_HDUPLEX_RTS)
        {
            if (tcdrain(COM_info[com].fp) < 0)
            {
                err_SetMsg(ERROR_COM_FAIL, "tcdrain() fails");
                return false;
            }
        }
        else  // tcdrain() is too slow in the purpose of switching RTS to read servos in readtime
        {
            //use "ioctl(fd, FIONWRITE, &nBytes)" to wait write-FIFO empty...
        }
    #endif
    
    if (COM_duplex[com] == COM_HDUPLEX_RTS)  // ensure that all bytes in 16550 FIFO have been sent
        while((io_inpb(COM_baseaddr[com] + 5) & 0x60) != 0x60);
    
    return true;
}
开发者ID:mhk2010,项目名称:roboard-hexapod,代码行数:27,代码来源:com.cpp


示例2: RBAPI

RBAPI(bool) i2cslave_Write(int dev, unsigned char val) {
    unsigned long nowtime;

    if (I2C_action[dev] != I2CACT_SLAVEWRITEREQ)
    {
        err_SetMsg(ERROR_I2CWRONGUSAGE, "slave must write data only when being requested");
        return false;
    }
    
    i2cslave_ClearSlaveWREQ(dev);
    i2c_WriteDataREG(dev, val);

    for (nowtime=0; nowtime<100000L; nowtime++) //trick for performance; timer_nowtime() is time-consuming in some OS
        if (i2c_CheckTXDone(dev) == true) goto TX_SUCCESS;

    nowtime = timer_nowtime();
    while ((i2c_CheckTXDone(dev) == false) && ((timer_nowtime() - nowtime) < I2C_TIMEOUT));

    if (i2c_CheckTXDone(dev) == false)
    {
        err_SetMsg(ERROR_I2CFAIL, "the I2C module doesn't respond");
        I2C_action[dev] = I2CACT_IDLE;
        return false;
    }

TX_SUCCESS:
    i2c_ClearTXDone(dev);
    I2C_action[dev] = I2CACT_SLAVE;
    return true;
}
开发者ID:brucetsao,项目名称:RoBoIO,代码行数:30,代码来源:i2c.cpp


示例3: check_RX_done

_RB_INLINE bool check_RX_done(int dev) {
    unsigned long nowtime;
    unsigned char statreg;

    for (nowtime=0; nowtime<100000L; nowtime++) //trick for speed; timer_nowtime() is time-consuming in some OS
        if (i2c_CheckRXRdy(dev) == true) goto RX_SUCCESS;

    nowtime = timer_nowtime();
    while ((i2c_CheckRXRdy(dev) == false) && ((timer_nowtime() - nowtime) < I2C_TIMEOUT));

RX_SUCCESS:
    statreg = i2c_ReadStatREG(dev); //ugly code for speed:p
    i2c_ClearRXRdy(dev);

    if ((statreg & 0x08) != 0) //if (i2cmaster_CheckARLoss(dev) == true)
    {
        err_SetMsg(ERROR_I2CARLOSS, "arbitration loss for I2C bus");
        i2cmaster_ClearARLoss(dev);
        return false;
    }
    if ((statreg & 0x01) == 0) //if (i2c_IsMaster(dev) == false)
    {
        err_SetMsg(ERROR_I2CFAIL, "I2C%d module isn't in Master Mode", dev);
        return false;
    }
    if ((statreg & 0x40) == 0) //if (i2c_CheckRXRdy(dev) == false)
    {
        err_SetMsg(ERROR_I2CFAIL, "I2C%d module doesn't respond", dev);
        return false;
    }

    return true;
}
开发者ID:brucetsao,项目名称:RoBoIO,代码行数:33,代码来源:i2c.cpp


示例4: RBAPI

RBAPI(bool) spi_Init2(unsigned baseaddr, int clkmode) {
    int i;

	if(spi_InUse() == true)
	{
		err_SetMsg(ERROR_SPI_INUSE, "SPI was already opened");
		return false;
	}
	
	if ((SPI_ioSection = io_Init()) == -1) return false;

	//NOTE: base address should be selected carefully to avoid conflicts with other devices!
	if (baseaddr != 0xffff)
        spi_SetBaseAddress(baseaddr);
	else
	{
        baseaddr = spi_SetDefaultBaseAddress();
        if ((baseaddr == 0x0000) || (baseaddr == 0xffff)) spi_SetBaseAddress(0xfc00);
    }

    spidx_DisableCS();
    spi_ClearErrors();

    // enable FIFO and set clock divisor
    //if (spi_SetControlREG(0x10 + SPI_CLKMODE[clkmode]) == false)
    if (spi_SetControlREG(0x10 + get_spidivisor(clkmode)) == false)
    {
        spi_Close();
        err_SetMsg(ERROR_SPI_INITFAIL, "fail to write SPI Control Register");
        return false;
    }
    
    // clear the input buffer if it is not empty
    for (i=0; i<20; i++)
    {
        if (spi_InputReady() == false) break;
        if (spidx_Read() == 0xffff)
        {
            spi_Close();
            err_SetMsg(ERROR_SPI_INITFAIL, "fail to clear SPI input buffer");
            return false;
        }
    }

    // switch GPIO3[3:0] to external SPI interface
    OLD_SPIGPIO3FLAG = read_sb_reg(SB_MULTIFUNC_REG);
    write_sb_reg(SB_MULTIFUNC_REG, OLD_SPIGPIO3FLAG | 1L);
    OLD_SPIGPIO3FLAG = OLD_SPIGPIO3FLAG & 1L;

    return true;
}
开发者ID:brucetsao,项目名称:RoBoIO,代码行数:51,代码来源:spi.cpp


示例5: RBAPI

RBAPI(unsigned) ad79x8_RawRead(void) {
    unsigned val1, val2;

    #ifdef ROBOIO
        if (roboio_GetRBVer() == RB_110)
        {
            io_outpb(GPIO2_DIR, io_inpb(GPIO2_DIR) | 0x20);
            io_outpb(GPIO2_DATA, io_inpb(GPIO2_DATA) & 0xdf);
        }
    #endif
    spi_EnableCS();

    val1 = spi_Read2();
    val2 = spi_Read2();

    spi_DisableCS();
    #ifdef ROBOIO
        if (roboio_GetRBVer() == RB_110)
        {
            io_outpb(GPIO2_DIR, io_inpb(GPIO2_DIR) | 0x20);
            io_outpb(GPIO2_DATA, io_inpb(GPIO2_DATA) | 0x20);
        }
    #endif

    if ((val1 == 0xffff) || (val2 == 0xffff))
    {
        err_SetMsg(ERROR_ADCFAIL, "fail to read ADC because SPI fails");
        return AD79x8_READFAIL;
    }

    return (val1 << 8) + val2;
}
开发者ID:brucetsao,项目名称:RoBoIO,代码行数:32,代码来源:ad79x8.cpp


示例6: i2csw_Write

static bool i2csw_Write(int dev, unsigned char val) {
    int i, databit;

    // send data byte
    for(i=0; i<8; i++)
    {
        databit = ((val & 0x80) == 0)? 0 : 1;
        set_pins(dev, 0, databit); delay_us(I2CSW_delay[dev]);  // set data bit
        set_pins(dev, 1, databit); delay_us(I2CSW_delay[dev]);  // send a clock
        set_pins(dev, 0, databit);
        val = val << 1;
    }
    
    // read ACK
    set_pins(dev, 0, 1); delay_us(I2CSW_delay[dev]);  // set SDA as input
    set_pins(dev, 1, 1); delay_us(I2CSW_delay[dev]);  // send a clock
    if (read_sda(dev) == 1)
    {
		err_SetMsg(ERROR_I2CACKERR, "receive no ACK after transmitting");
        return false;
    }
    set_pins(dev, 0, 1);
    
    return true;
}
开发者ID:brucetsao,项目名称:RoBoIO,代码行数:25,代码来源:i2c.cpp


示例7: i2csw_Start

static bool i2csw_Start(int dev, unsigned char addr, unsigned char rwbit, bool restart) {
    int i, databit;
    
    if (restart == false)
    {   // send START signal
        set_pins(dev, 1, 1); delay_us(I2CSW_delay[dev]);  // SCL = 1, SDA = 1
        set_pins(dev, 1, 0); delay_us(I2CSW_delay[dev]);  // SCL = 1, SDA = 0
        set_pins(dev, 0, 0);                              // SCL = 0, SDA = 0
    }
    else
    if (I2C_swMode[dev] == I2CSW_LEGO)
    {   // send LEGO NXT's I2C RESTART signal
        set_pins(dev, 0, 0); delay_us(I2CSW_delay[dev]);  // SCL = 0, SDA = 0
        set_pins(dev, 1, 0); delay_us(I2CSW_delay[dev]);  // SCL = 1, SDA = 0
        set_pins(dev, 1, 1); delay_us(I2CSW_delay[dev]);  // SCL = 1, SDA = 1

        set_pins(dev, 0, 1); delay_us(I2CSW_delay[dev]);  // LEGO NXT special: SCL = 0, SDA = 1
        
        set_pins(dev, 1, 1); delay_us(I2CSW_delay[dev]);  // SCL = 1, SDA = 1
        set_pins(dev, 1, 0); delay_us(I2CSW_delay[dev]);  // SCL = 1, SDA = 0
        set_pins(dev, 0, 0);                              // SCL = 0, SDA = 0
    }
    else
    {   // send normal I2C RESTART signal
        set_pins(dev, 0, 0); delay_us(I2CSW_delay[dev]);  // SCL = 0, SDA = 0
        set_pins(dev, 0, 1); delay_us(I2CSW_delay[dev]);  // SCL = 0, SDA = 1
        set_pins(dev, 1, 1); delay_us(I2CSW_delay[dev]);  // SCL = 1, SDA = 1
        set_pins(dev, 1, 0); delay_us(I2CSW_delay[dev]);  // SCL = 1, SDA = 0
        set_pins(dev, 0, 0);                              // SCL = 0, SDA = 0
    }

    // send data byte
    addr = (addr << 1) | rwbit;
    for(i=0; i<8; i++)
    {
        databit = ((addr & 0x80) == 0)? 0 : 1;
        set_pins(dev, 0, databit); delay_us(I2CSW_delay[dev]);  // set data bit
        set_pins(dev, 1, databit); delay_us(I2CSW_delay[dev]);  // send a clock
        set_pins(dev, 0, databit);
        addr = addr << 1;
    }
    
    // read ACK
    set_pins(dev, 0, 1); delay_us(I2CSW_delay[dev]);  // set SDA as input
    set_pins(dev, 1, 1); delay_us(I2CSW_delay[dev]);  // send a clock
    if (read_sda(dev) == 1)
    {
		err_SetMsg(ERROR_I2CACKERR, "receive no ACK after transmitting");
        return false;
    }
    set_pins(dev, 0, 1);
    
    return true;
}
开发者ID:brucetsao,项目名称:RoBoIO,代码行数:54,代码来源:i2c.cpp


示例8: i2cmaster_Start1

_RB_INLINE bool i2cmaster_Start1(int dev, unsigned char addr, unsigned char rwbit) {
    if (i2c_IsMaster(dev) == false)
    {
        err_SetMsg(ERROR_I2CWRONGUSAGE, "can't start a transaction in Slave state");
        return false;
    }

    i2cmaster_WriteAddrREG(dev, addr, rwbit);

    //Remarks: if I2C master sends "Start" twice sequently, ARLoss will occur according to H/W design
    return check_TX_done(dev);
}
开发者ID:brucetsao,项目名称:RoBoIO,代码行数:12,代码来源:i2c.cpp


示例9: DMP_INLINE

DMP_INLINE(bool) check_TX_done(int dev) {
    unsigned long nowtime;
    unsigned char statreg;

    for (nowtime=0; nowtime<100000L; nowtime++) //trick for speed; timer_nowtime() is time-consuming in some OS
        if (i2c_CheckTXDone(dev) == true) goto TX_SUCCESS;

    nowtime = timer_nowtime();
    while ((i2c_CheckTXDone(dev) == false) && ((timer_nowtime() - nowtime) < I2C_TIMEOUT));

TX_SUCCESS:
    statreg = i2c_ReadStatREG(dev); //ugly code for speed:p
    i2c_ClearTXDone(dev);

    if ((statreg & 0x08) != 0) //if (i2cmaster_CheckARLoss(dev) == true)
    {
        err_SetMsg(ERROR_I2CARLOSS, "arbitration loss for I2C bus");
        i2cmaster_ClearARLoss(dev);
    }
    if ((statreg & 0x10) != 0) //if (i2cmaster_CheckAckErr(dev) == true)
    {
        err_SetMsg(ERROR_I2CACKERR, "receive no ACK after transmitting");
        i2cmaster_ClearAckErr(dev);
    }
    if ((statreg & (0x10 + 0x08)) != 0) return false;

    if ((statreg & 0x01) == 0) //if (i2c_IsMaster(dev) == false)
    {
        err_SetMsg(ERROR_I2CFAIL, "I2C%d module isn't in Master Mode", dev);
        return false;
    }
    if ((statreg & 0x20) == 0) //if (i2c_CheckTXDone(dev) == false)
    {
        err_SetMsg(ERROR_I2CFAIL, "I2C%d module doesn't respond", dev);
        return false;
    }
    
    return true;
}
开发者ID:drbokko,项目名称:86Duino,代码行数:39,代码来源:i2c.cpp


示例10: RBAPI

RBAPI(bool) i2cmaster_Write(int dev, unsigned char val) {
    if (I2C_action[dev] != I2CACT_MASTERWRITE)
    {
        err_SetMsg(ERROR_I2CWRONGUSAGE, "must start a correct transaction before writing data");
        return false;
    }

    i2c_WriteDataREG(dev, val);

    if (check_TX_done(dev) == true) return true;

    I2C_action[dev] = I2CACT_IDLE;
    return false;
}
开发者ID:pongraczi,项目名称:roboio,代码行数:14,代码来源:i2c.cpp


示例11: i2cmaster_Start1

_RB_INLINE bool i2cmaster_Start1(int dev, unsigned char addr, unsigned char rwbit) {
    if (i2c_IsMaster(dev) == false)
    {
        err_SetMsg(ERROR_I2CWRONGUSAGE, "can't start a transaction in Slave state");
        return false;
    }

    i2cmaster_WriteAddrREG(dev, addr, rwbit);

    //Remarks: if I2C master sends "Start" twice sequently, ARLoss will occur according to H/W design
    if (check_TX_done(dev) == false) return false;
    
    I2C_action[dev] = (rwbit == I2C_WRITE)? I2CACT_MASTERWRITE : I2CACT_MASTERREAD;
    I2C_curAddr = addr;
    return true;
}
开发者ID:pongraczi,项目名称:roboio,代码行数:16,代码来源:i2c.cpp


示例12: DMPAPI

DMPAPI(bool) i2c_Reset(int dev) {
    unsigned long nowtime;
    
    io_outpb(I2C_EXCTRL_REG(dev), io_inpb(I2C_EXCTRL_REG(dev)) | 0x80);

    nowtime = timer_nowtime();
    while (((io_inpb(I2C_EXCTRL_REG(dev)) & 0x80) != 0) && ((timer_nowtime() - nowtime) < I2C_TIMEOUT));

    if ((io_inpb(I2C_EXCTRL_REG(dev)) & 0x80) != 0)
    {
        err_SetMsg(ERROR_I2CFAIL, "fail to reset I2C module %d", dev);
        return false;
    }
    
    //Remarks: due to Vortex86DX's poor I2C design, RESET bit may become 0 when dummy clocks are still being output
    delay_ms(20L); //lazy trick to tackle the above issue
    return true;
}
开发者ID:drbokko,项目名称:86Duino,代码行数:18,代码来源:i2cex.cpp


示例13: check_STOP_done

_RB_INLINE bool check_STOP_done(int dev) {
    unsigned long nowtime;

    for (nowtime=0; nowtime<100000L; nowtime++) //trick for speed; timer_nowtime() is time-consuming in some OS
        if (i2cmaster_CheckStopBit(dev) == false) goto STOP_SUCCESS;

    nowtime = timer_nowtime();
    while ((i2cmaster_CheckStopBit(dev) == true) && ((timer_nowtime() - nowtime) < I2C_TIMEOUT));

    if (i2cmaster_CheckStopBit(dev) == true)
    {
        err_SetMsg(ERROR_I2CFAIL, "fail to stop the transaction");
        return false;
    }

STOP_SUCCESS:
    return true;
}
开发者ID:brucetsao,项目名称:RoBoIO,代码行数:18,代码来源:i2c.cpp



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ err_capture函数代码示例发布时间:2022-05-30
下一篇:
C++ errRep函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap