您当前的位置:首页 > IT编程 > C++
| C语言 | Java | VB | VC | python | Android | TensorFlow | C++ | oracle | 学术与代码 | cnn卷积神经网络 | gnn | 图像修复 | Keras | 数据集 | Neo4j | 自然语言处理 | 深度学习 | 医学CAD | 医学影像 | 超参数 | pointnet | pytorch | 异常检测 | Transformers | 情感分类 | 知识图谱 |

自学教程:C++ timedRead函数代码示例

51自学网 2021-06-03 08:50:56
  C++
这篇教程C++ timedRead函数代码示例写得很实用,希望能帮到您。

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

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

示例1: timedRead

char * Stream::readString(char * buf) {  char * ret = buf;  int c = timedRead();  while (c >= 0) {    *ret++ = (char)c;    c = timedRead();  }  return ret;}
开发者ID:ADTL,项目名称:ARMWork,代码行数:9,


示例2: timedRead

std::string Stream::readStringUntil(char terminator) {    std::string ret;    int c = timedRead();    while(c >= 0 && c != terminator) {        ret += (char) c;        c = timedRead();    }    return ret;}
开发者ID:joshuacox,项目名称:arduino-libraries,代码行数:9,


示例3: timedRead

String ICACHE_FLASH_ATTR Stream::readStringUntil(char terminator) {    String ret;    int c = timedRead();    while(c >= 0 && c != terminator) {        ret += (char) c;        c = timedRead();    }    return ret;}
开发者ID:141141,项目名称:ESP31B,代码行数:9,


示例4: headerRead

/** /ingroup header * Read (and load) header from file handle. * @param fd		file handle * @param magicp	read (and verify) 8 bytes of (magic, 0)? * @return		header (or NULL on error) */Header headerRead(FD_t fd, enum hMagic magicp){    int32_t block[4];    int32_t reserved;    int32_t * ei = NULL;    int32_t il;    int32_t dl;    int32_t magic;    Header h = NULL;    size_t len;    int i;    memset(block, 0, sizeof(block));    i = 2;    if (magicp == HEADER_MAGIC_YES)	i += 2;    /* FIX: cast? */    if (timedRead(fd, (char *)block, i*sizeof(*block)) != (i * sizeof(*block)))	goto exit;    i = 0;    if (magicp == HEADER_MAGIC_YES) {	magic = block[i++];	if (memcmp(&magic, rpm_header_magic, sizeof(magic)))	    goto exit;	reserved = block[i++];    }        il = ntohl(block[i]);	i++;    dl = ntohl(block[i]);	i++;    len = sizeof(il) + sizeof(dl) + (il * sizeof(struct entryInfo_s)) + dl;    /* Sanity checks on header intro. */    if (hdrchkTags(il) || hdrchkData(dl) || len > headerMaxbytes)	goto exit;    ei = xmalloc(len);    ei[0] = htonl(il);    ei[1] = htonl(dl);    len -= sizeof(il) + sizeof(dl);    /* FIX: cast? */    if (timedRead(fd, (char *)&ei[2], len) != len)	goto exit;        h = headerLoad(ei);exit:    if (h == NULL && ei != NULL) {	free(ei);    }    return h;}
开发者ID:cms-externals,项目名称:rpm,代码行数:62,


示例5: memcpy

ssize_t eHttpStream::httpChunkedRead(void *buf, size_t count){	ssize_t ret = -1;	size_t total_read = partialPktSz;	// write partial packet from the previous read	if (partialPktSz > 0)	{		memcpy(buf, partialPkt, partialPktSz);		partialPktSz = 0;	}	if (!isChunked)	{		ret = timedRead(streamSocket,((char*)buf) + total_read , count - total_read, 5000, 100);		if (ret > 0)		{			ret += total_read;			ret = syncNextRead(buf, ret);		}	}	else	{		while (total_read < count)		{			if (0 == currentChunkSize)			{				do				{					ret = readLine(streamSocket, &tmpBuf, &tmpBufSize);					if (ret < 0) return -1;				} while (!*tmpBuf && ret > 0); /* skip CR LF from last chunk */				if (ret == 0)					break;				currentChunkSize = strtol(tmpBuf, NULL, 16);				if (currentChunkSize == 0) return -1;			}			size_t to_read = count - total_read;			if (currentChunkSize < to_read)				to_read = currentChunkSize;			// do not wait too long if we have something in the buffer already			ret = timedRead(streamSocket, ((char*)buf) + total_read, to_read, ((total_read)? 100 : 5000), 100);			if (ret <= 0)				break;			currentChunkSize -= ret;			total_read += ret;		}		if (total_read > 0)		{			ret = syncNextRead(buf, total_read);		}	}	return ret;}
开发者ID:Brainbuster,项目名称:stb-gui,代码行数:56,


示例6: while

// reads data from the stream until the target string of the given length is found// search terminated if the terminator string is found// returns true if target string is found, false if terminated or timed outbool Stream::findUntil(char *target, size_t targetLen, char *terminator, size_t termLen){  size_t index = 0;  // maximum target string length is 64k bytes!  size_t termIndex = 0;  int c;    if( *target == 0)  return true;   // return true if target is a null string  while( (c = timedRead()) > 0){        if(c != target[index])    index = 0; // reset index if any char does not match        if( c == target[index]){      //////Serial.print("found "); Serial.write(c); Serial.print("index now"); Serial.println(index+1);      if(++index >= targetLen){ // return true if all chars in the target match        return true;      }    }        if(termLen > 0 && c == terminator[termIndex]){      if(++termIndex >= termLen)      return false;       // return false if terminate string found before target string    }    else    termIndex = 0;  }  return false;}
开发者ID:0xPIT,项目名称:Sming,代码行数:32,


示例7: if

ssize_t eHttpStream::read(off_t offset, void *buf, size_t count){	if (connectionStatus == BUSY)		return 0;	else if (connectionStatus == FAILED)		return -1;	return timedRead(streamSocket, buf, count, 5000, 500);}
开发者ID:tom1984,项目名称:enigma2,代码行数:8,


示例8: eDebug

ssize_t eHttpStream::read(off_t offset, void *buf, size_t count){	sock_mutex.lock();	sock_mutex.unlock();	if (streamSocket < 0) {		eDebug("eHttpStream::read not valid fd");		return -1;	}	return timedRead(streamSocket, buf, count, 5000, 500);}
开发者ID:licvik,项目名称:amiko-e2-pli,代码行数:10,


示例9: while

/*** @brief Read characters into buffer.* Terminates if length characters have been read, timeout, or* if the terminator character has been detected* @param The terminator character to look for* @param The buffer to read into.* @param The number of bytes to read.* @return The number of bytes read. 0 means no valid data found.*/size_t RN2483::readBytesUntil(char terminator, char *buffer, size_t bytesToRead){    if (bytesToRead < 1) return 0;    size_t index = 0;    while (index < (bytesToRead - 1 )) {        int c = timedRead(1000);        if (c < 0 || c == terminator) break;        *buffer++ = (char)c;        index++;    }    return index; // return number of characters, not including null terminator}
开发者ID:coredump-ch,项目名称:watertemp,代码行数:21,


示例10: timedRead

bool EspDrv::getDataBuf(uint8_t sock, uint8_t *_data, uint16_t *_dataLen){	for(int i=0; i<_bufPos; i++)	{		int c = timedRead();		_data[i] = (char)c;	}	*_dataLen = _bufPos;	_bufPos = 0;	return true;}
开发者ID:seco,项目名称:WiFiEsp,代码行数:13,


示例11: while

size_t ESP8266_Serial::readBytesUntilAndIncluding(char terminator, char *buffer, size_t length, byte maxOneLineOnly){    if (length < 1) return 0;    size_t index = 0;    while (index < length) {        int c = timedRead();        if (c < 0) break;        *buffer++ = (char)c;        index++;        if(c == terminator) break;        if(maxOneLineOnly && ( c == '/n') ) break;    }    return index; // return number of characters, not including null terminator}
开发者ID:wony365,项目名称:ESP8266-1,代码行数:14,


示例12: while

String Stream::readStringUntil(char terminator, size_t max){	String str;	size_t length = str.length();	while (length < max) {		int c = timedRead();		if (c < 0) {			setReadError();			break;	// timeout		}		if (c == 0 || c == terminator) break;		str += (char)c;	}	return str;}
开发者ID:cryham,项目名称:controller,代码行数:15,


示例13: timedRead

/** * Receive the data into a buffer. * It reads up to bufSize bytes. * @return	received data size for success else -1. */int EspDrv::getDataBuf(uint8_t connId, uint8_t *buf, uint16_t bufSize){	if (connId!=_connId)		return false;	if(_bufPos<bufSize)		bufSize = _bufPos;		for(int i=0; i<bufSize; i++)	{		int c = timedRead();		//LOGDEBUG(c);		if(c==-1)			return -1;				buf[i] = (char)c;		_bufPos--;	}	return bufSize;}
开发者ID:DiazMaxiM,项目名称:The_Bomb_Game,代码行数:26,


示例14: contentLength

String HttpClient::responseBody(){    int bodyLength = contentLength();    String response;    if (bodyLength > 0)    {        // try to reserve bodyLength bytes        if (response.reserve(bodyLength) == 0) {            // String reserve failed            return String((const char*)NULL);        }    }    // keep on timedRead'ing, until:    //  - we have a content length: body length equals consumed or no bytes    //                              available    //  - no content length:        no bytes are available    while (iBodyLengthConsumed != bodyLength)    {        int c = timedRead();        if (c == -1) {            // read timed out, done            break;        }        if (!response.concat((char)c)) {            // adding char failed            return String((const char*)NULL);        }    }    if (bodyLength > 0 && (unsigned int)bodyLength != response.length()) {        // failure, we did not read in reponse content length bytes        return String((const char*)NULL);    }    return response;}
开发者ID:DawesLab,项目名称:arduino,代码行数:40,


示例15: readLine

ssize_t readLine(int fd, char** buffer, size_t* bufsize){	size_t i = 0;	int result;	while (1) 	{		if (i >= *bufsize) 		{			char *newbuf = (char*)realloc(*buffer, (*bufsize)+1024);			if (newbuf == NULL)				return -ENOMEM;			*buffer = newbuf;			*bufsize = (*bufsize) + 1024;		}		result = timedRead(fd, (*buffer) + i, 1, 3000, 100);		if (result <= 0 || (*buffer)[i] == '/n')		{			(*buffer)[i] = '/0';			return result <= 0 ? -1 : i;		}		if ((*buffer)[i] != '/r') i++;	}	return -1;}
开发者ID:dazulrich,项目名称:dvbapp,代码行数:24,


示例16: main

//.........这里部分代码省略.........	else	{		size = atoi(argv[3]);	}	int volumeid = find_volumeid(argv[1]);	if (volumeid >= 0)	{		std::cout << "found existing volume, resize to " << size << std::endl;		int ret;		struct ubi_rsvol_req req;		fd = open("/dev/ubi0", O_RDONLY);		if (fd < 0)		{			std::cerr << "failed to open " << "/dev/ubi0" <<  std::endl;			exit(EXIT_FAILURE);		}		req.bytes = size;		req.vol_id = volumeid;		ret = ioctl(fd, UBI_IOCRSVOL, &req);		close(fd);	}	else	{		std::cout << "create new volume, size " << size << std::endl;		int ret;		struct ubi_mkvol_req r;		size_t n;		memset(&r, 0, sizeof(struct ubi_mkvol_req));		r.vol_id = UBI_VOL_NUM_AUTO;		r.alignment = 1;		r.bytes = size;		r.vol_type = UBI_STATIC_VOLUME;		n = strlen(argv[1]);		if (n > UBI_MAX_VOLUME_NAME)		{			std::cerr << "volume name too long, max " << UBI_MAX_VOLUME_NAME << std::endl;			exit(EXIT_FAILURE);		}		strncpy(r.name, argv[1], UBI_MAX_VOLUME_NAME + 1);		r.name_len = n;		fd = open("/dev/ubi0", O_RDONLY);		if (fd < 0)		{			std::cerr << "failed to open " << "/dev/ubi0" <<  std::endl;			exit(EXIT_FAILURE);		}		ret = ioctl(fd, UBI_IOCMKVOL, &r);		if (ret < 0) 		{			close(fd);			std::cerr << "failed to create volume" <<  std::endl;			exit(EXIT_FAILURE);		}		close(fd);		volumeid = r.vol_id;		for (int i = 0; i < 10; i++)		{			snprintf(buffer, sizeof(buffer), "/dev/ubi0_%d", volumeid);			if (access(buffer, F_OK) >= 0) break;			/* HACK: give udev/mdev some time to create the devicenode */			usleep(100000);		}	}	snprintf(buffer, sizeof(buffer), "/dev/ubi0_%d", volumeid);	fd = open(buffer, O_RDWR);	if (fd < 0)	{		std::cerr << "failed to open " << buffer <<  std::endl;		exit(EXIT_FAILURE);	}	ioctl(fd, UBI_IOCVOLUP, &size);	int in;	if (!strcmp(argv[2], "-"))	{		in = 0;	}	else	{		in = open(argv[2], O_RDONLY);	}	if (in < 0)	{		std::cerr << "failed to open " << argv[2] <<  std::endl;		exit(EXIT_FAILURE);	}	while (1)	{		int result = timedRead(in, buffer, sizeof(buffer), 5000, 5000);		if (result <= 0) break;		if (writeAll(fd, buffer, result) < 0) break;	}	exit(EXIT_SUCCESS);}
开发者ID:Brainbuster,项目名称:opennfr-buildumgebung,代码行数:101,


示例17: while

int Stream::findMulti( struct Stream::MultiTarget *targets, int tCount) {  // any zero length target string automatically matches and would make  // a mess of the rest of the algorithm.  for (struct MultiTarget *t = targets; t < targets+tCount; ++t) {    if (t->len <= 0)      return t - targets;  }  while (1) {    int c = timedRead();    if (c < 0)      return -1;    for (struct MultiTarget *t = targets; t < targets+tCount; ++t) {      // the simple case is if we match, deal with that first.      if (c == t->str[t->index]) {        if (++t->index == t->len)          return t - targets;        else          continue;      }      // if not we need to walk back and see if we could have matched further      // down the stream (ie '1112' doesn't match the first position in '11112'      // but it will match the second position so we can't just reset the current      // index to 0 when we find a mismatch.      if (t->index == 0)        continue;      int origIndex = t->index;      do {        --t->index;        // first check if current char works against the new current index        if (c != t->str[t->index])          continue;        // if it's the only char then we're good, nothing more to check        if (t->index == 0) {          t->index++;          break;        }        // otherwise we need to check the rest of the found string        int diff = origIndex - t->index;        size_t i;        for (i = 0; i < t->index; ++i) {          if (t->str[i] != t->str[i + diff])            break;        }        // if we successfully got through the previous loop then our current        // index is good.        if (i == t->index) {          t->index++;          break;        }        // otherwise we just try the next index      } while (t->index);    }  }  // unreachable  return -1;}
开发者ID:RickKimball,项目名称:Arduino_STM32,代码行数:64,


示例18: rpmpkgReadHeader

static rpmRC rpmpkgReadHeader(rpmKeyring keyring, rpmVSFlags vsflags, 		       FD_t fd, Header *hdrp, char ** msg){    char *buf = NULL;    int32_t block[4];    int32_t il;    int32_t dl;    int32_t * ei = NULL;    size_t uc;    size_t nb;    Header h = NULL;    rpmRC rc = RPMRC_FAIL;		/* assume failure */    int xx;    if (hdrp)	*hdrp = NULL;    if (msg)	*msg = NULL;    memset(block, 0, sizeof(block));    if ((xx = timedRead(fd, (char *)block, sizeof(block))) != sizeof(block)) {	rasprintf(&buf, 		_("hdr size(%d): BAD, read returned %d/n"), (int)sizeof(block), xx);	goto exit;    }    if (memcmp(block, rpm_header_magic, sizeof(rpm_header_magic))) {	rasprintf(&buf, _("hdr magic: BAD/n"));	goto exit;    }    il = ntohl(block[2]);    if (hdrchkTags(il)) {	rasprintf(&buf, _("hdr tags: BAD, no. of tags(%d) out of range/n"), il);	goto exit;    }    dl = ntohl(block[3]);    if (hdrchkData(dl)) {	rasprintf(&buf,		  _("hdr data: BAD, no. of bytes(%d) out of range/n"), dl);	goto exit;    }    nb = (il * sizeof(struct entryInfo_s)) + dl;    uc = sizeof(il) + sizeof(dl) + nb;    ei = xmalloc(uc);    ei[0] = block[2];    ei[1] = block[3];    if ((xx = timedRead(fd, (char *)&ei[2], nb)) != nb) {	rasprintf(&buf, _("hdr blob(%zd): BAD, read returned %d/n"), nb, xx);	goto exit;    }    /* Sanity check header tags */    rc = headerVerify(keyring, vsflags, ei, uc, msg);    if (rc != RPMRC_OK)	goto exit;    /* OK, blob looks sane, load the header. */    h = headerLoad(ei);    if (h == NULL) {	rasprintf(&buf, _("hdr load: BAD/n"));	rc = RPMRC_FAIL;        goto exit;    }    ei = NULL;	/* XXX will be freed with header */    exit:    if (hdrp && h && rc == RPMRC_OK)	*hdrp = headerLink(h);    ei = _free(ei);    h = headerFree(h);    if (msg != NULL && *msg == NULL && buf != NULL) {	*msg = buf;    } else {	free(buf);    }    return rc;}
开发者ID:pombredanne,项目名称:debian-rpm,代码行数:79,


示例19: timedRead

ssize_t eHttpStream::read(off_t offset, void *buf, size_t count){	return timedRead(streamSocket, buf, count, 5000, 500);}
开发者ID:Anubisko,项目名称:enigma2,代码行数:4,



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


C++ timed_output_dev_register函数代码示例
C++ timecounter_init函数代码示例
万事OK自学网:51自学网_软件自学网_CAD自学网自学excel、自学PS、自学CAD、自学C语言、自学css3实例,是一个通过网络自主学习工作技能的自学平台,网友喜欢的软件自学网站。