I'm looking for some pointers to help me develop a general formula to extract a given signal from a CAN frame, given the startbit and length of the signal.
I'm thinking that if I could calculate the MSB position in that first byte, I could simple read 10 bits sequentially from there.
In my head, it's easy to do this for each case, but I'm struggling to generalise it. For example if the signal starts in the middle, end or start of a byte, etc. Here is an example frame, where I am trying to take out Sig1 with start bit of 23 and a length of 13. Eventually I want to end up with a C function that can perform this extraction, but I feel that once I can calculate the byte position of the MSB, it should be easy from there.
Any help is much appreciated! Example CAN Frame