Fix sequence number having the wrong value
* I'm really not sure what it is, but for some reason with the ternary operator the sequence number was ending up wrong - it would end up being 1 twice in a row, at startup it would be 0 when it should have been 1 and other issues. This fixes that * Also made it atomic Commit amended for code style by Adam Honse <calcprogrammer1@gmail.com>
This commit is contained in:
parent
b2736d6575
commit
9b2296b0bc
2 changed files with 11 additions and 2 deletions
|
|
@ -216,7 +216,16 @@ void CorsairHydroPlatinumController::SendColors(std::vector<RGBColor> colors, un
|
|||
|
||||
unsigned int CorsairHydroPlatinumController::GetSequenceNumber()
|
||||
{
|
||||
return ((sequence_number < 32) ? sequence_number++ : sequence_number = 1) << 3;
|
||||
if(sequence_number < 31)
|
||||
{
|
||||
sequence_number++;
|
||||
}
|
||||
else
|
||||
{
|
||||
sequence_number = 1;
|
||||
}
|
||||
|
||||
return(sequence_number << 3);
|
||||
}
|
||||
|
||||
uint8_t CorsairHydroPlatinumController::ComputePEC(const void * data, size_t size)
|
||||
|
|
|
|||
|
|
@ -43,7 +43,7 @@ private:
|
|||
std::string location;
|
||||
std::string firmware_version;
|
||||
|
||||
unsigned int sequence_number;
|
||||
std::atomic<unsigned int> sequence_number;
|
||||
|
||||
void SendMagic(const uint8_t* magic, unsigned int command);
|
||||
void SendColors(std::vector<RGBColor> colors, unsigned int start, unsigned int end, unsigned int command);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue