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 cmdPending = false;
|
||||||
bool chunkPending = false;
|
bool chunkPending = false;
|
||||||
uint16_t chunkComplete = 0;
|
uint16_t chunkComplete = 0;
|
||||||
int16_t chunkSize = 0;
|
uint16_t chunkSize = 0;
|
||||||
byte cmdGroup = 0;
|
byte cmdGroup = 0;
|
||||||
byte cmdValue = 0;
|
byte cmdValue = 0;
|
||||||
int cmdCombined = 0; //the cmdgroup as high byte and cmdvalue as low byte
|
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)
|
length2 = Serial.read(); // Length to be written (Should always be 1)
|
||||||
chunkSize = word(length2, length1);
|
chunkSize = word(length2, length1);
|
||||||
|
|
||||||
//chunkPending = true;
|
chunkPending = true;
|
||||||
for(int i = 0; i < chunkSize; i++)
|
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
|
while( (Serial.available() > 0) && (chunkComplete < chunkSize) )
|
||||||
receiveValue( (valueOffset + i), Serial.read());
|
{
|
||||||
}
|
receiveValue( (valueOffset + chunkComplete), Serial.read());
|
||||||
cmdPending = false;
|
chunkComplete++;
|
||||||
}
|
}
|
||||||
|
if(chunkComplete >= chunkSize) { cmdPending = false; chunkPending = false; }
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue