Click here to Skip to main content
15,446,510 members
Home / Discussions / Design and Architecture
   

Design and Architecture

 
GeneralRe: Making data notation extending another language Pin
Richard MacCutchan19-May-20 23:26
mveRichard MacCutchan19-May-20 23:26 
AnswerRe: Making data notation extending another language Pin
Richard Deeming19-May-20 23:04
mveRichard Deeming19-May-20 23:04 
GeneralRe: Making data notation extending another language Pin
nedzadarek20-May-20 5:58
Membernedzadarek20-May-20 5:58 
GeneralRe: Making data notation extending another language Pin
Eddy Vluggen25-May-20 10:42
professionalEddy Vluggen25-May-20 10:42 
GeneralRe: Making data notation extending another language Pin
Greg Utas25-May-20 11:34
mveGreg Utas25-May-20 11:34 
GeneralRe: Making data notation extending another language Pin
Eddy Vluggen25-May-20 12:18
professionalEddy Vluggen25-May-20 12:18 
GeneralRe: Making data notation extending another language Pin
Greg Utas25-May-20 13:28
mveGreg Utas25-May-20 13:28 
QuestionPlease come with suggestions for how I should version my registers? Pin
arnold_w13-May-20 0:50
Memberarnold_w13-May-20 0:50 
I am working with several products that communicate with each other through registers and when a new firmware release is made in any of the products, registers could have been added or discontinued. I was thinking of having something like this:

h-file:
#ifndef DONT_KNOW_IF_REG_IS_STILL_SUPPORTED_YOU_HAVE_TO_ASK
#define DONT_KNOW_IF_REG_IS_STILL_SUPPORTED_YOU_HAVE_TO_ASK    (0xFF)
#endif
#ifndef REG_IS_NO_LONGER_SUPPORTED
#define REG_IS_NO_LONGER_SUPPORTED                             (0)
#endif
#ifndef REG_IS_STILL_SUPPORTED
#define REG_IS_STILL_SUPPORTED                                 (1)
#endif

typedef struct __attribute__((__packed__)) {
    uint8_t versionMajorFunc;
    uint8_t versionMinorFunc;
    uint8_t versionMajorBug;
    uint8_t versionMinorBug;
    uint8_t variant;
} versionAndVariant_s;

typedef struct __attribute__((__packed__)) {
    uint32_t          addr;
    uint8_t           versionMajorFuncRegWasIntroduced;
    uint8_t           versionMinorFuncRegWasIntroduced;
    uint8_t           versionMajorBugRegWasIntroduced;
    uint8_t           versionMinorBugRegWasIntroduced;
    uint32_t          supportedVariantsMask;
    uint8_t           isRegStillSupported;
} regSpec_s;


#ifndef IS_REG_COMPATIBLE
#define IS_REG_COMPATIBLE(__FW_VERSION_AND_VARIANT_PTR__,__REG_SPEC_PTR__)                                                    \
       ((((((uint32_t)(__REG_SPEC_PTR__)->versionMajorFunc)               << 24) |                                            \
          (((uint32_t)(__REG_SPEC_PTR__)->versionMinorFunc)               << 16) |                                            \
          (((uint32_t)(__REG_SPEC_PTR__)->versionMajorBug)                <<  8) |                                            \
          (((uint32_t)(__REG_SPEC_PTR__)->versionMinorBug)                <<  0)) <=                                          \
         ((((uint32_t)(__FW_VERSION_AND_VARIANT_PTR__)->versionMajorFunc) << 24) |                                            \
          (((uint32_t)(__FW_VERSION_AND_VARIANT_PTR__)->versionMinorFunc) << 16) |                                            \
          (((uint32_t)(__FW_VERSION_AND_VARIANT_PTR__)->versionMajorBug)  <<  8) |                                            \
          (((uint32_t)(__FW_VERSION_AND_VARIANT_PTR__)->versionMinorBug)  <<  0))) &&                                         \
        (0 < ((__REG_SPEC_PTR__)->supportedVariantsMask & VARIANT_TO_VARIANT_MASK((__FW_VERSION_AND_VARIANT_PTR__)->variant))) && \
                                                  (!(((__FW_VERSION_AND_VARIANT_PTR__)->versionMajorFunc == 0xFF) &&          \
                                                     ((__FW_VERSION_AND_VARIANT_PTR__)->versionMinorFunc == 0xFF) &&          \
                                                     ((__FW_VERSION_AND_VARIANT_PTR__)->versionMajorBug  == 0xFF) &&          \
                                                     ((__FW_VERSION_AND_VARIANT_PTR__)->versionMinorBug  == 0xFF))))
#endif

extern const regSpec_s MY_REG_1;
extern const regSpec_s MY_REG_2;
C-file:
const regSpec_s MY_REG_1 = {1000, 0, 0, 0, 4, ALL_VARIANTS_MASK, DONT_KNOW_IF_REG_IS_STILL_SUPPORTED_YOU_HAVE_TO_ASK};
const regSpec_s MY_REG_2 = {1002, 0, 0, 0, 4, ALL_VARIANTS_MASK, DONT_KNOW_IF_REG_IS_STILL_SUPPORTED_YOU_HAVE_TO_ASK};

In my code I would then first query the firmware version of the product I want to communicate with and then I can determine whether the register exists or not:
C++
versionAndVariant_s* versionAndVariantOfOtherProduct = getVersionAndVariant(otherProduct);
if (!IS_REG_COMPATIBLE(versionAndVariantOfOtherProduct, &MY_REG_1)) {
    return FALSE; // Error! The other product's fw is too old to have this register
}
if (MY_REG_1.isRegStillSupported == DONT_KNOW_IF_REG_IS_STILL_SUPPORTED_YOU_HAVE_TO_ASK) {
    MY_REG_1.isRegStillSupported = isRegStillSupported(otherProduct, MY_REG_1.addr);
}
if (MY_REG_1.isRegStillSupported == REG_IS_NO_LONGER_SUPPORTED) {
    return FALSE; // Error! At some point the other product supported this register, but not anymore
}
Any suggestions for improvements on this?

modified 13-May-20 6:57am.

QuestionHow should I organize my shared h-files with register definitions? Pin
arnold_w12-May-20 23:56
Memberarnold_w12-May-20 23:56 
QuestionSimple plain text "encryption" that is very easy to decrypt without specialty software? Pin
arnold_w1-May-20 23:28
Memberarnold_w1-May-20 23:28 
AnswerRe: Simple plain text "encryption" that is very easy to decrypt without specialty software? Pin
Richard MacCutchan2-May-20 1:31
mveRichard MacCutchan2-May-20 1:31 
GeneralRe: Simple plain text "encryption" that is very easy to decrypt without specialty software? Pin
arnold_w2-May-20 3:12
Memberarnold_w2-May-20 3:12 
GeneralRe: Simple plain text "encryption" that is very easy to decrypt without specialty software? Pin
Richard MacCutchan2-May-20 4:51
mveRichard MacCutchan2-May-20 4:51 
GeneralRe: Simple plain text "encryption" that is very easy to decrypt without specialty software? Pin
Richard Deeming5-May-20 1:40
mveRichard Deeming5-May-20 1:40 
AnswerRe: Simple plain text "encryption" that is very easy to decrypt without specialty software? Pin
Mycroft Holmes2-May-20 12:18
professionalMycroft Holmes2-May-20 12:18 
AnswerRe: Simple plain text "encryption" that is very easy to decrypt without specialty software? Pin
arnold_w2-May-20 21:23
Memberarnold_w2-May-20 21:23 
GeneralRe: Simple plain text "encryption" that is very easy to decrypt without specialty software? Pin
Eddy Vluggen2-May-20 21:31
professionalEddy Vluggen2-May-20 21:31 
GeneralRe: Simple plain text "encryption" that is very easy to decrypt without specialty software? Pin
kalberts2-May-20 22:44
Memberkalberts2-May-20 22:44 
GeneralRe: Simple plain text "encryption" that is very easy to decrypt without specialty software? Pin
arnold_w2-May-20 22:54
Memberarnold_w2-May-20 22:54 
GeneralRe: Simple plain text "encryption" that is very easy to decrypt without specialty software? Pin
Eddy Vluggen2-May-20 23:01
professionalEddy Vluggen2-May-20 23:01 
GeneralRe: Simple plain text "encryption" that is very easy to decrypt without specialty software? Pin
arnold_w2-May-20 23:03
Memberarnold_w2-May-20 23:03 
GeneralRe: Simple plain text "encryption" that is very easy to decrypt without specialty software? Pin
Eddy Vluggen2-May-20 23:16
professionalEddy Vluggen2-May-20 23:16 
AnswerRe: Simple plain text "encryption" that is very easy to decrypt without specialty software? Pin
Graham Breach2-May-20 22:16
MemberGraham Breach2-May-20 22:16 
QuestionHigh Scale Real time communication (Server to Client) Pin
Nand3225-Apr-20 3:49
MemberNand3225-Apr-20 3:49 
QuestionRe: High Scale Real time communication Pin
Greg Utas25-Apr-20 23:44
mveGreg Utas25-Apr-20 23:44 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.