Better handling of live chunk receives in comms
This commit is contained in:
parent
ef89229e27
commit
9af5534de4
|
@ -21,7 +21,7 @@ byte currentCommand;
|
|||
bool cmdPending = false;
|
||||
bool chunkPending = false;
|
||||
uint16_t chunkComplete = 0;
|
||||
int16_t chunkSize = 0;
|
||||
uint16_t chunkSize = 0;
|
||||
byte cmdGroup = 0;
|
||||
byte cmdValue = 0;
|
||||
int cmdCombined = 0; //the cmdgroup as high byte and cmdvalue as low byte
|
||||
|
|
|
@ -243,14 +243,19 @@ void command()
|
|||
length2 = Serial.read(); // Length to be written (Should always be 1)
|
||||
chunkSize = word(length2, length1);
|
||||
|
||||
//chunkPending = true;
|
||||
for(int i = 0; i < chunkSize; i++)
|
||||
chunkPending = true;
|
||||
chunkComplete = 0;
|
||||
}
|
||||
}
|
||||
//This CANNOT be an else of the above if statement as chunkPending gets set to true above
|
||||
if(chunkPending == true)
|
||||
{
|
||||
while(Serial.available() == 0) { } //For chunk writes, we can safely loop here
|
||||
receiveValue( (valueOffset + i), Serial.read());
|
||||
}
|
||||
cmdPending = false;
|
||||
while( (Serial.available() > 0) && (chunkComplete < chunkSize) )
|
||||
{
|
||||
receiveValue( (valueOffset + chunkComplete), Serial.read());
|
||||
chunkComplete++;
|
||||
}
|
||||
if(chunkComplete >= chunkSize) { cmdPending = false; chunkPending = false; }
|
||||
}
|
||||
break;
|
||||
|
||||
|
|
Loading…
Reference in New Issue