本文整理汇总了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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
}
示例8: setWriteError
size_t WiFiClient::write(const uint8_t *buf, size_t size) {
if (!ServerDrv::sendData(_sock, buf, size)) {
setWriteError();
return 0;
}
return size;
}
示例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;
}
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
}
示例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;
}
示例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;
}