Closed TG9541 closed 4 years ago
In order to solve the "bit packing" requirement in FC-1, FC-2 and FC-15 I experimented with indexed Bit Field access. Copying a number of bits from Big Endian to Little Endian representation is then a simple loop. That's certainly not the most performant way (the code that I'm working on requires less than 2 x 5 µs per bit) but I can't think of applications that require copying more than a few hundred bits in a single FC access.
The issue of implementing FC15 has been solved together with an improving FC01 and FC02.
Here is a screenshot of QModMaster:
The words BF@
and BF!
provide Big Endian access to bitfields (the representation of both MODBUS registers and STM8 eForth 16bit words) but the same code implements LEBF@
and LEBF!
, bitfield access for Little Endian MODBUS packed binary transport.
By the way, the confusion about counting from 1 (FC05, "internal register addresses") or counting from 0 (all the rest of the MODBUS protocol and any meaningful implementation short of BASIC and PASCAL) is really funny. I can easily imagine different groups of people specifying and using or implementing the protocol. Maybe in multiple steps and in different roles. It's very human in all its imperfection ;-)
@tealbrains: I tested the implementation with QModMaster. Of course I can't guarantee the validity of that test but at I implemented against the MODBUS V1.1b specification and I guess you can implement against it. The code doesn't validate address, item count and N* and there won't be an EC=3 if your code is wrong (yet).
@anklimov: maybe you find the time to try it. I'm not completely sure about what to do about the behavior of FC05 addresses 0 and 255 that you observed. Otherwise release alpha 0.17 is likely at least as usable as the stock firmware.
It looks like I was wrong about the address representation of FC05 all along! That's easy enough to fix, and I better fix it soon.
There is a big fat bug in the implementation of FC15. A first fix can provide a limited functionality, e.g. like FC2.