浏览代码

Update Stream.cpp

main
Frank 5 年前
父节点
当前提交
06522dc2b1
没有帐户链接到提交者的电子邮件
共有 1 个文件被更改,包括 7 次插入3 次删除
  1. +7
    -3
      teensy4/Stream.cpp

+ 7
- 3
teensy4/Stream.cpp 查看文件

@@ -75,7 +75,7 @@ void Stream::setTimeout(unsigned long timeout) // sets the maximum number of mi

// find returns true if the target string is found
bool Stream::find(const char *target)
{
{
return findUntil(target, NULL);
}

@@ -89,6 +89,8 @@ bool Stream::find(const char *target, size_t length)
// as find but search ends if the terminator string is found
bool Stream::findUntil(const char *target, const char *terminator)
{
if(target == NULL) return true;
if(terminator == NULL) return true;
return findUntil(target, strlen(target), terminator, strlen(terminator));
}

@@ -101,8 +103,10 @@ bool Stream::findUntil(const char *target, size_t targetLen, const char *termina
size_t termIndex = 0;
int c;

if( *target == 0)
return true; // return true if target is a null string
if( target == NULL) return true;
if( *target == 0) return true; // return true if target is a null string
if(terminator == NULL) return true;
while( (c = timedRead()) > 0){
if( c == target[index]){
//////Serial.print("found "); Serial.write(c); Serial.print("index now"); Serial.println(index+1);

正在加载...
取消
保存