Closed rzbrk closed 2 years ago
Example:
>>> vr = PyVoiceRecognitionV3(device=dev)
>>> res = vr.check_record_train_status()
>>> res["train_status"].count("trained")
6
>>> res["no_trained_records"]
2
The entries in res["train_status]
are reasonable but res["no_trained_records"]
is wrong.
The root cause for this bug is that the method checks the wrong byte in the response message from the module (see here). It should check the 4th byte bjut actually checks the 3rd byte. Because the 3rd byte is the command id (\x02
) this explains why the same wrong number 2 is returned.
Not related to this bug: There might be a bug in the firmware of the module. When checking the train status of all records the module returns multiple messages. Each individual message should repeat the exact number of number of trained redords. However, the first message returns a wrong value:
>>> vr = PyVoiceRecognitionV3(device=dev)
>>> res = vr.check_record_train_status()
>>> res["train_status"].count("trained")
6
>>> for m in res["raw"]:
... print(m[3],end=" ")
...
5 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6
It seems as the value from the very first message is wrong. The values from the following messages are correct.
Effectively, the number of trained records is retrieved from the last message returned by the module. The potential bug in the firmware described above seems to effect only the first message. Therefore, the potential firmware bug has no consequence on the output from method check_record_train_status()
.
In the result dictionary of method
check_record_train_status()
the value of keyno_trained_records
and the number of records that are trained intrain_status
do not match