I have been looking further into this protocol in my efforts to create protocols.ini entries for the protocols I have added to DecodeIR. The executor needs to calculate the rather curious checksum, since it has to deal with whatever values for Device, Function etc are provided by the user, so I have tried to see if there is something more systematic in the checksum than appears at first sight. I think there is, though it is not as systematic as I would like. Here is what I have come up with.
The protocol has Device (D), Subdevice (S) and Function (F) codes that are each 8-bit, and in addition an 8-bit checksum (C). There is also an 8-bit toggle mask M with M=4 for the example we have been given, though I see no reason why M cannot vary, providing different versions of the protocol. There is an 8-bit toggle parameter T with T=0 for the first frame and T=M for all repeat frames. The IRP is
Amino {55.5k,270,msb}<-1,1|1,-1>(7,-6,3,(D^T):8,S:8,F:8,C:8,-77m)+
where C = (D^T^S^F^FF^(((F^FF)&(T^M))<<1))|$F0 with FF = F:1:4*((F<<1)&(F<<2)&(F<<3)) .
The notation X<<n, created by me for this protocol, means X shifted left n places, with 1's filling the empty places to the right. (Note that this differs from the same notation in C++, where the empty places would be filled with 0's).
These are the things I find unsatisfactory. The top four bits of C are forced to 1 by the "or $F0" at the end of its definition. I suspect that if we had examples with greater variation in the top four bits of the data fields then it would be possible to create a checksum that genuinely used all 8 bits. The F<<n terms ANDed together in FF could be extended to all n from 1 to 7 as nothing would change for the data in our sample, but it could not include F<<0. Finally, the singling out of bit F:1:4 is odd, to say the least. There is in fact no need to include S in the construction of C, as S=0 in our sample, but I've done so as it seems to fit naturally.
If nothing else, this provides a relatively easy way to calculate the checksum in an executor, and to check it in DecodeIR. Note that in decoding, the first frame alone is enough to identify D, S and F but not to check the checksum since M is unknown. If there is at least a second frame, my code in DecodeIR compares the two, determines M and validates the checksum. Since the checksum probably does not hold true for general D, S and F, DecodeIR "XORs" the calculated and actual checksums and, if nonzero, it returns the result as a parameter N. If it has only one frame to work with, it reports M and N as undetermined. The sample we have has D=13, S=0, T=4.
Here is a protocols.ini entry with HCS08 and S3C8+ code that generates this protocol for arbitrary toggle mask M and checksum seed N:
Code: Select all
[Amino]
PID=01 FC
DevParms=Device:8=13,Sub Device:8=0,M:8=4,N:8=0
DeviceTranslator=Translator(2,8) Translator(3,8,8) Translator(0,8,16) Translator(1,8,24)
CmdParms=OBC:8=0
CmdTranslator=Translator(0,8)
FixedData=04 00 0D 00
Code.HCS08=20 1A 18 30 41 8F 84 10 08 08 00 87 00 87 00 87 00 87 96 64 01 95 00 00 03 B1 03 2A 3C AA 4E AA AC A6 FF AE 03 B4 64 99 49 5B FA 08 64 01 4F B7 65 B8 64 B4 60 99 49 45 00 05 E8 60 5B FC AA F0 B7 65 AE 7A CD FF 65 CD FF 5F B6 62 B8 60 B7 62 3F 60 CD FF 92 25 CA 81
Code.S3C80=2E 5E 41 8B 17 8F 84 10 08 08 00 87 00 73 00 87 00 73 96 64 01 95 00 00 03 B1 03 16 20 11 E4 11 01 1C FF 2C 03 54 07 C1 DF 10 C1 2A F8 28 07 37 29 02 B0 C1 19 08 B4 07 C1 54 03 C1 DF 10 C1 2C 08 4C 05 B3 12 00 C2 4A FA 46 C1 F0 19 08 1C 22 F6 01 4C F6 01 46 B4 03 05 B0 03 F6 01 0A 7B C1 AF
I've arbitrarily used a PID of 01FC. It would be nice to have some policy on PIDs created by this forum, though I see no way of avoiding possible clashes with ones issued by UEI in the future. I believe RM has a facility for using an Alternate PID if the main PID is built in to the remote, so perhaps we could create two for each protocol to minimise the risk?
________________
Graham