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

C++ setWriteError函数代码示例

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

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



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

示例1: setWriteError

size_t WiFiClient::write(const uint8_t *buf, size_t size) {
  if (_sock >= MAX_SOCK_NUM)
  {
	  setWriteError();
	  return 0;
  }
  if (size==0)
  {
	  setWriteError();
      return 0;
  }


  if (!ServerDrv::sendData(_sock, buf, size))
  {
	  setWriteError();
      return 0;
  }
  if (!ServerDrv::checkDataSent(_sock))
  {
	  setWriteError();
      return 0;
  }

  return size;
}
开发者ID:4bcat,项目名称:Arduino,代码行数:26,代码来源:WiFiClient.cpp


示例2: setWriteError

size_t WiFiClient::write(const uint8_t *buf, size_t size)
{
	sint16 err;

	if (_socket < 0 || size == 0) {
		setWriteError();
		return 0;
	}

	// Network led ON.
	m2m_periph_gpio_set_val(M2M_PERIPH_GPIO16, 0);

	m2m_wifi_handle_events(NULL);

	while ((err = send(_socket, (void *)buf, size, 0)) < 0) {
		// Exit on fatal error, retry if buffer not ready.
		if (err != SOCK_ERR_BUFFER_FULL) {
			setWriteError();
			m2m_periph_gpio_set_val(M2M_PERIPH_GPIO16, 1);
			return 0;
		}
		m2m_wifi_handle_events(NULL);
	}
	
	// Network led OFF.
	m2m_periph_gpio_set_val(M2M_PERIPH_GPIO16, 1);
			
	return size;
}
开发者ID:cmasenas,项目名称:WiFi101,代码行数:29,代码来源:WiFiClient.cpp


示例3: setWriteError

size_t Keyboard_::write(uint8_t c)
{
	// Keydown
	{
		KeyReport keys = {0};
		if (_keyMap)
			_keyMap->charToKey(c,&keys);
		else
		{
			if (c >= 128) {
				setWriteError();
				return 0;
			}
			c = pgm_read_byte(_asciimap + c);
			if (!c) {
				setWriteError();
				return 0;
			}
			if (c & 0x80)
			{
				keys.modifiers |= KEY_MODIFIER_LEFT_SHIFT;
				c &= 0x7F;
			}
			keys.keys[0] = c;
		}
		sendReport(&keys);
	}
	//	Keyup
	{
		KeyReport keys = {0};
		sendReport(&keys);
	}
	return 1;
}
开发者ID:0x00f,项目名称:Energia,代码行数:34,代码来源:HID.cpp


示例4: setWriteError

size_t EthernetClient::write(const uint8_t *buf, size_t size) {
  if (_sock == MAX_SOCK_NUM) {
    setWriteError();
    return 0;
  }
  if (!send(_sock, buf, size)) {
    setWriteError();
    return 0;
  }
  return size;
}
开发者ID:arcadien,项目名称:ArduinoSkeleton,代码行数:11,代码来源:EthernetClient.cpp


示例5: setWriteError

size_t File::write(const uint8_t *buf, size_t size) {
  size_t t;
  if (!_file) {
    setWriteError();
    return 0;
  }
  _file->clearWriteError();
  t = _file->write(buf, size);
  if (_file->getWriteError()) {
    setWriteError();
    return 0;
  }
  return t;
}
开发者ID:AllAboutEE,项目名称:photon-sd-card-library,代码行数:14,代码来源:File.cpp


示例6: setWriteError

size_t EthernetClient::write(const uint8_t *buf, size_t size)
{
	if (sockindex >= MAX_SOCK_NUM) return 0;
	if (Ethernet.socketSend(sockindex, buf, size)) return size;
	setWriteError();
	return 0;
}
开发者ID:FernandoGarcia,项目名称:Ferduino_with_webcontrol_beta,代码行数:7,代码来源:EthernetClient.cpp


示例7: open

size_t USBSerial::write(uint8_t c)
{
        /* only try to send bytes if the high-level CDC connection itself 
         is open (not just the pipe) - the OS should set lineState when the port
         is opened and clear lineState when the port is closed.
         bytes sent before the user opens the connection or after
         the connection is closed are lost - just like with a UART. */
        
        // TODO - ZE - check behavior on different OSes and test what happens if an
        // open connection isn't broken cleanly (cable is yanked out, host dies
        // or locks up, or host virtual serial port hangs)
        if (LineState > 0) {
                Endpoint_SelectEndpoint(CDC_TX_EPADDR);
                
                if (!Endpoint_IsReadWriteAllowed()) {
                        Endpoint_ClearIN();
                        while (!Endpoint_IsINReady() && USB_DeviceState == DEVICE_STATE_Configured) {
                                USB_USBTask();
                        }
                }
                
                set_blink_LED();
                Endpoint_Write_8(c);
                
                return 1;
        } else {
                setWriteError();
                return 0;
        }
}
开发者ID:Industruino,项目名称:boarddefinitions,代码行数:30,代码来源:usb_api.cpp


示例8: setWriteError

size_t WiFiClient::write(const uint8_t *buf, size_t size) {
  if (!ServerDrv::sendData(_sock, buf, size)) {
	  setWriteError();
    return 0;
  }
  return size;
}
开发者ID:FireflyTeam,项目名称:Fireduino-SDK,代码行数:7,代码来源:WiFiClient.cpp


示例9: LSB

// System Control
//  k is one of the SYSTEM_CONTROL defines which come from the HID usage table "Generic Desktop Page (0x01)"
// in "HID Usage Tables" (HUT1_12v2.pdf)
size_t Keyboard_::systemControl(uint8_t k) 
{
	if(k <= 16)
	{
		u16 mask = 0;
		u8 m[2];

		if(k > 0)
		{
			mask = 1 << (k - 1);
		}

		m[0] = LSB(mask);
		m[1] = MSB(mask);
		HID_SendReport(HID_REPORTID_SYSTEMCONTROL,m,sizeof(m));

		// these are all OSCs, so send a clear to make it possible to send it again later
		m[0] = 0;
		m[1] = 0;
		HID_SendReport(HID_REPORTID_SYSTEMCONTROL,m,sizeof(m));
		return 1;
	}
	else
	{
		setWriteError();
		return 0;
	}
}
开发者ID:granadaxronos,项目名称:Arduino,代码行数:31,代码来源:HID.cpp


示例10: setWriteError

// must be called in:
// slave tx event callback
// or after beginTransmission(address)
size_t TwoWire::write(uint8_t data)
{
    if(transmitting) {
        // in master transmitter mode
        // don't bother if buffer is full
        if(TX_BUFFER_FULL) {
            setWriteError();
            return 0;
        }
        // put byte in tx buffer
        txBuffer[txWriteIndex] = data;
        txWriteIndex = (txWriteIndex + 1) % BUFFER_LENGTH;

    } else {
        // in slave send mode
        // reply to master
        if(TX_BUFFER_FULL) {
            I2CSlaveDataPut(SLAVE_BASE, txBuffer[txReadIndex]);
            txReadIndex = (txReadIndex + 1) % BUFFER_LENGTH;
        }
        txBuffer[txWriteIndex] = data;
        txWriteIndex = (txWriteIndex + 1) % BUFFER_LENGTH;
    }
    return 1;
}
开发者ID:JuergenGe,项目名称:Energia,代码行数:28,代码来源:Wire.cpp


示例11: setWriteError

size_t Keyboard_::press1(uint8_t k, bool shift)
{
	uint8_t i;
  if (k >= 128 && k < 136) {	// it's a modifier key
    _keyReport.modifiers |= (1<<(k-128));

    k = 0;
  } else {
		if (shift) {						// it's a capital letter or other character reached with shift
			_keyReport.modifiers |= 0x02;	// the left shift modifier
		}
  }

	// Add k to the key report only if it's not already present
	// and if there is an empty slot.
	if (_keyReport.keys[0] != k && _keyReport.keys[1] != k && 
		_keyReport.keys[2] != k && _keyReport.keys[3] != k &&
		_keyReport.keys[4] != k && _keyReport.keys[5] != k) {
		
		for (i=0; i<6; i++) {
			if (_keyReport.keys[i] == 0x00) {
				_keyReport.keys[i] = k;
				break;
			}
		}
		if (i == 6) {
			setWriteError();
			return 0;
		}	
	}
	sendReport(&_keyReport);
	return 1;
}
开发者ID:kajboj,项目名称:keyboard,代码行数:33,代码来源:HID.cpp


示例12: setWriteError

// ------------------------------------------------------------------------------------------------------
// Write - write data to Tx buffer
// return: #bytes written = success, 0=fail
// parameters:
//      data = data byte
//
size_t i2c_t3::write(uint8_t data)
{
    if(i2c->txBufferLength < I2C_TX_BUFFER_LENGTH)
    {
        i2c->txBuffer[i2c->txBufferLength++] = data;
        return 1;
    }
    setWriteError();
    return 0;
}
开发者ID:UCCS-Robotics,项目名称:animated-archer,代码行数:16,代码来源:i2c_t3.cpp


示例13: USB_Send

//force a write without bothering to check if the serial port is open
size_t Serial_::WRITE(uint8_t c)
{
    int r = USB_Send(CDC_TX,&c,1);
    if (r > 0) {
        return r;
    } else {
        setWriteError(2);
        return 0;
    }
}
开发者ID:drewtm,项目名称:Fila-Mint,代码行数:11,代码来源:CDC.cpp


示例14: if

// press() adds the specified key (printing, non-printing, or modifier)
// to the persistent key report and sends the report.  Because of the way
// USB HID works, the host acts like the key remains pressed until we
// call release(), releaseAll(), or otherwise clear the report and resend.
size_t Keyboard_::press(uint8_t k)
{
    uint8_t i;
    if (k >= 136) {			// it's a non-printing key (not a modifier)
        k = k - 136;
    }
    else if (k >= 128) {	// it's a modifier key
        _keyReport.modifiers |= (1<<(k-128));
        k = 0;
    }
    else {				// it's a printing key
        k = pgm_read_byte(_asciimap + k);
        if (!k) {
            setWriteError();
            return 0;
        }
        if (k & 0x80) {						// it's a capital letter or other character reached with shift
            _keyReport.modifiers |= 0x02;	// the left shift modifier
            k &= 0x7F;
        }
    }

    // Add k to the key report only if it's not already present
    // and if there is an empty slot.
    if (_keyReport.keys[0] != k && _keyReport.keys[1] != k &&
            _keyReport.keys[2] != k && _keyReport.keys[3] != k &&
            _keyReport.keys[4] != k && _keyReport.keys[5] != k) {

        for (i=0; i<6; i++) {
            if (_keyReport.keys[i] == 0x00) {
                _keyReport.keys[i] = k;
                break;
            }
        }
        if (i == 6) {
            setWriteError();
            return 0;
        }
    }
    sendReport(&_keyReport);
    return 1;
}
开发者ID:javitrompix,项目名称:MediaKeys,代码行数:46,代码来源:MediaKeys.cpp


示例15: setWriteError

size_t WiFiEspClient::write(const uint8_t *buf, size_t size)
{
	if (_sock >= MAX_SOCK_NUM or size==0)
	{
		setWriteError();
		return 0;
	}

	bool r = EspDrv::sendData(_sock, buf, size);
	if (!r)
	{
		setWriteError();
		LOGERROR1(F("Failed to write to socket"), _sock);
		delay(4000);
		stop();
		return 0;
	}

	return size;
}
开发者ID:seco,项目名称:WiFiEsp,代码行数:20,代码来源:WiFiEspClient.cpp


示例16: setWriteError

size_t SendOnlySoftwareSerial::write(uint8_t b)
{
  if (_tx_delay == 0) {
    setWriteError();
    return 0;
  }

  // By declaring these as local variables, the compiler will put them
  // in registers _before_ disabling interrupts and entering the
  // critical timing sections below, which makes it a lot easier to
  // verify the cycle timings
  volatile uint8_t *reg = _transmitPortRegister;
  uint8_t reg_mask = _transmitBitMask;
  uint8_t inv_mask = ~_transmitBitMask;
  uint8_t oldSREG = SREG;
  bool inv = _inverse_logic;
  uint16_t delay = _tx_delay;

  if (inv)
    b = ~b;

  cli();  // turn off interrupts for a clean txmit

  // Write the start bit
  if (inv)
    *reg |= reg_mask;
  else
    *reg &= inv_mask;

  tunedDelay(delay);

  // Write each of the 8 bits
  for (uint8_t i = 8; i > 0; --i)
  {
    if (b & 1) // choose bit
      *reg |= reg_mask; // send 1
    else
      *reg &= inv_mask; // send 0

    tunedDelay(delay);
    b >>= 1;
  }

  // restore pin to natural state
  if (inv)
    *reg &= inv_mask;
  else
    *reg |= reg_mask;

  SREG = oldSREG; // turn interrupts back on
  tunedDelay(_tx_delay);
  
  return 1;
}
开发者ID:stahlfabrik,项目名称:TinyTX-TinyRX-Project,代码行数:54,代码来源:SendOnlySoftwareSerial.cpp


示例17: setWriteError

size_t Serial_::write(const uint8_t *buffer, size_t size)
{
	uint32_t r = usb.send(CDC_ENDPOINT_IN, buffer, size);

	if (r > 0) {
		return r;
	} else {
		setWriteError();
		return 0;
	}
}
开发者ID:mattairtech,项目名称:ArduinoCore-samd,代码行数:11,代码来源:CDC.cpp


示例18: setWriteError

// press() adds the specified key (printing, non-printing, or modifier)
// to the persistent key report and sends the report.  Because of the way
// USB HID works, the host acts like the key remains pressed until we
// call release(), releaseAll(), or otherwise clear the report and resend.
size_t USBKeyboard::press(uint16_t key, uint16_t modifiers)
{
    bool doReport = false;
    if (key >= KEY_LEFTCTRL && key <= KEY_RIGHTGUI)
    {
       // it's a modifier key
       keyReport.modifiers |= (1 << (key - KEY_LEFTCTRL));
       key = 0;
       doReport = true;
    }

    if (key > KEY_KPHEX)
        return 0;

    if (modifiers) {
        if (modifiers > MOD_RESERVED && modifiers <= (MOD_RESERVED | 0xFF)) {
            modifiers &= 0x00FF;
            keyReport.modifiers |= modifiers;
            doReport = true;
        } else {
            modifiers = 0;
        }
    }

    // Add key to the keyReport only if it's not already present
    // and if there is an empty slot.
    if (key && keyReport.keys[0] != key && keyReport.keys[1] != key &&
        keyReport.keys[2] != key && keyReport.keys[3] != key &&
        keyReport.keys[4] != key && keyReport.keys[5] != key)
    {
        uint8_t i;
        for (i = 0; i < 6; i++)
        {
            if (keyReport.keys[i] == 0x00)
            {
                keyReport.keys[i] = key;
                doReport = true;
                break;
            }
        }
        if (i == 6)
        {
            setWriteError();
            return 0;
        }
    }

    if (doReport) {
        sendReport();
        return 1;
    }
    return 0;
}
开发者ID:spark,项目名称:firmware,代码行数:57,代码来源:spark_wiring_usbkeyboard.cpp


示例19: setWriteError

size_t WiFiClient::write(const uint8_t *buf, size_t size) {
  	if (_sock < 0)
  	{
	  	setWriteError();
	  	return 0;
  	}
  	if (size==0)
  	{
	  	setWriteError();
      	return 0;
  	}

  	if (!clientdrv.sendData(_sock, buf, size))
  	{
	  	setWriteError();
		_is_connected = false;
      	return 0;
  	}
	
  	return size;
}
开发者ID:Ameba8195,项目名称:Arduino,代码行数:21,代码来源:WiFiClient.cpp


示例20: setWriteError

size_t TwoWire::write(uint8_t data)
{
	if (transmitting || slave_mode) {
		if (txBufferLength >= BUFFER_LENGTH+1) {
			setWriteError();
			return 0;
		}
		txBuffer[txBufferLength++] = data;
		return 1;
	}
	return 0;
}
开发者ID:PaulStoffregen,项目名称:Wire,代码行数:12,代码来源:WireKinetis.cpp



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
C++ setX函数代码示例发布时间:2022-05-30
下一篇:
C++ setWindowTitle函数代码示例发布时间: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