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


C++ setWriteError函数代码示例

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


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


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