CRC должен считаться на всю длину пакета. и пох на варианты
нутрянки. это арифметика. выбоены с последней парой байт (где
укладывается CRC) это мрак. при этом кросавчеги намалевали
табличный расчёт, который используют только в том маразме. по сути
decode должен вызываться после таймаута на разрыв пакета и сам
пакет уже есть. его не имеет смысла скрести по частям. ему сразу
после транспортной части определяют битость, а не скребутся по
расчётам длин исходя из кишок. а уже после кишок. смотрим MODBUS over serial line specification and implementation guide V1.02 Figure 14 и камменты под
After detection of the end of frame, the CRC calculation and checking is completed. Afterwards the address field is analysed to
determine if the frame is for the device. If not the frame is discarded. In order to reduce the reception processing time the
address field can be analysed as soon as it is received without waiting the end of frame. In this case the CRC will be calculated
and checked only if the frame is addressed to the slave (broadcast frame included).