synaptics: Fix lost messages when sequence counter overflows

The device will always use sequence number 0 for certain messages. We
use this knowledge to filter the messages and assume that it is one of
these special messages rather than a response to a command.

However, we could end up sending a command with a sequence counter of 0
which would result in the response being ignored. Fix this by ensuring
we correctly wrap from 255 to 1 instead of 0.

Fixes: #358
This commit is contained in:
Benjamin Berg 2021-02-05 16:09:24 +01:00
parent 9e164485f0
commit 966703057d

View file

@ -348,7 +348,7 @@ synaptics_sensor_cmd (FpiDeviceSynaptics *self,
* may only be a cancellation currently). */
if (seq_num <= 0)
{
self->last_seq_num = MAX (1, self->last_seq_num + 1);
self->last_seq_num = MAX (1, (self->last_seq_num + 1) & 0xff);
real_seq_num = self->last_seq_num;
if (seq_num == 0)
self->cmd_seq_num = self->last_seq_num;