lpcmanager

Parents cc123ca10682
Children b7fd71c78140
Renaming of per-platform (uC/SoM) C templates, so that what was done for MC9 can also be used on GOT6. Also added missing header (empty for now)
  • +9 -5
    LPCArch.py
  • +3 -3
    LPCBus.py
  • +1 -0
    LPCBus/MC10.h
  • +0 -35
    LPCBus/MC8.c
  • +0 -105
    LPCBus/MC9.c
  • +105 -0
    LPCBus/SOM.c
  • +35 -0
    LPCBus/uC.c
  • +12 -11
    LPCExtension.py
  • --- a/LPCArch.py Wed May 29 13:42:55 2019 +0200
    +++ b/LPCArch.py Thu May 30 10:49:24 2019 +0200
    @@ -16,12 +16,16 @@
    def GetLPCProduct():
    return product
    +def GetLPCSOM():
    + if product in SOM28_modules:
    + return "SOM28"
    + if product in SOM6_modules:
    + return "SOM6"
    +
    def GetLPCArch():
    if product in SOM28_modules:
    - bus_template_name = "MC9"
    + return "MC9"
    elif product in SOM6_modules:
    - bus_template_name = "MC10"
    + return "MC10"
    elif product is "MC8" :
    - bus_template_name = "MC8"
    - else:
    - bus_template_name = None
    + return "MC8"
    --- a/LPCBus.py Wed May 29 13:42:55 2019 +0200
    +++ b/LPCBus.py Thu May 30 10:49:24 2019 +0200
    @@ -19,9 +19,9 @@
    ("Devices", "uC_Devices")],
    "MC9" :[ ("Right", "SOM28_Right"),
    ("On Board", "SOM_OnBoard"),
    - ("Devices", "SOM_Devices" ],
    + ("Devices", "SOM_Devices")],
    "MC10" :[("On Board", "SOM_OnBoard"),
    - ("Devices", "SOM_Devices" ]}
    + ("Devices", "SOM_Devices")]}
    # This matches names of .h files in LPCBus with product from LPCArch
    headernames = {
    @@ -30,7 +30,7 @@
    "GOT":"GOT",
    "GOT_131":"GOT100",
    "GOT_111":"GOT100",
    - "GOT6":"GOT6"
    + "GOT6":"MC10"
    }
    bus_template_code = { plc: GetLocalCode(
    --- /dev/null Thu Jan 01 00:00:00 1970 +0000
    +++ b/LPCBus/MC10.h Thu May 30 10:49:24 2019 +0200
    @@ -0,0 +1,1 @@
    +// Nothing for now
    --- a/LPCBus/MC8.c Wed May 29 13:42:55 2019 +0200
    +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
    @@ -1,35 +0,0 @@
    -/* Code generated by LPCBus confnode */
    -
    -/* LPCBus confnode includes */
    -#include "app_glue.h"
    -#ifdef _WINDOWS_H
    - #include "iec_types.h"
    -#else
    - #include "iec_std_lib.h"
    -#endif
    -
    -%(declare_code)s
    -
    -/* LPCBus confnode user variables definition */
    -%(var_decl)s
    -
    -/* LPCBus confnode functions */
    -int __init_%(location_str)s(int argc,char **argv)
    -{
    -%(init_code)s
    - return 0;
    -}
    -
    -void __cleanup_%(location_str)s(void)
    -{
    -}
    -
    -void __retrieve_%(location_str)s(void)
    -{
    -%(retrieve_code)s
    -}
    -
    -void __publish_%(location_str)s(void)
    -{
    -%(publish_code)s
    -}
    --- a/LPCBus/MC9.c Wed May 29 13:42:55 2019 +0200
    +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
    @@ -1,105 +0,0 @@
    -
    -/* Code generated by LPCBus confnode */
    -
    -#ifdef _WINDOWS_H
    - #include "iec_types.h"
    -#else
    - #include "iec_std_lib.h"
    -#endif
    -
    -static inline int16_t getWord(char *buffer)
    -{
    - return ((int16_t)*buffer<<8) + (int16_t)*(buffer+1);
    -}
    -
    -static inline int16_t getWordSwapped(char *buffer)
    -{
    - return (((int16_t)*(buffer+1))<<8) + (int16_t)*buffer;
    -}
    -
    -static inline void setWord(char *buffer, int16_t word)
    -{
    - *buffer = (char)(word>>8);
    - *(buffer+1) = (char)(word);
    -}
    -
    -static inline void setWordSwapped(char *buffer, int16_t word)
    -{
    - *buffer = (char)word;
    - *(buffer+1) = (char)(word>>8);
    -}
    -
    -static inline int8_t getBit(char *buffer, unsigned char bitOffset)
    -{
    - return (*buffer & (0x01 << bitOffset)) && 1;
    -}
    -
    -static inline void setBit(char *buffer, unsigned char bitOffset, int8_t bit)
    -{
    - unsigned char msk = (0x01 << bitOffset);
    - if(bit)
    - *buffer |= msk;
    - else
    - *buffer &= ~msk;
    -}
    -
    -static void setWord16(short *buffer, uint16_t word)
    -{
    - *buffer = (short)word;
    -}
    -
    -static int16_t getWord16(short *buffer)
    -{
    - return((uint16_t)*buffer);
    -}
    -
    -static inline unsigned char getByte(char *buffer)
    -{
    - return((unsigned char)*buffer);
    -}
    -
    -static inline void setByte(char *buffer, unsigned char byte)
    -{
    - *buffer = byte;
    -}
    -
    -typedef struct
    -{
    - unsigned char status; /* Current status of timer - running / expired */
    - uint64_t actValue; /* Actual timer value */
    - uint64_t toValue; /* Timeout value - initialized at startup */
    - uint64_t oldTime; /* Time at previous timer increment; NOTE: if RTIME (unsigned long long) changes type, oldTime has to be adapted */
    -} commTimer;
    -
    -#define TIM_DISABLED 0
    -#define TIM_EN_RUNNING 1
    -#define TIM_EN_EXPIRED 2
    -
    -%(bus_decl)s
    -
    -%(declare_code)s
    -
    -/* LPCBus confnode user variables definition */
    -%(var_decl)s
    -
    -/* LPCBus confnode functions */
    -int __init_%(location_str)s(int argc,char **argv)
    -{
    - %(bus_init_code)s
    - return 0;
    -}
    -
    -void __cleanup_%(location_str)s(void)
    -{
    - %(bus_cleanup_code)s
    -}
    -
    -void __retrieve_%(location_str)s(void)
    -{
    -%(bus_retrieve_code)s
    -}
    -
    -void __publish_%(location_str)s(void)
    -{
    -%(bus_publish_code)s
    -}
    --- /dev/null Thu Jan 01 00:00:00 1970 +0000
    +++ b/LPCBus/SOM.c Thu May 30 10:49:24 2019 +0200
    @@ -0,0 +1,105 @@
    +
    +/* Code generated by LPCBus confnode */
    +
    +#ifdef _WINDOWS_H
    + #include "iec_types.h"
    +#else
    + #include "iec_std_lib.h"
    +#endif
    +
    +static inline int16_t getWord(char *buffer)
    +{
    + return ((int16_t)*buffer<<8) + (int16_t)*(buffer+1);
    +}
    +
    +static inline int16_t getWordSwapped(char *buffer)
    +{
    + return (((int16_t)*(buffer+1))<<8) + (int16_t)*buffer;
    +}
    +
    +static inline void setWord(char *buffer, int16_t word)
    +{
    + *buffer = (char)(word>>8);
    + *(buffer+1) = (char)(word);
    +}
    +
    +static inline void setWordSwapped(char *buffer, int16_t word)
    +{
    + *buffer = (char)word;
    + *(buffer+1) = (char)(word>>8);
    +}
    +
    +static inline int8_t getBit(char *buffer, unsigned char bitOffset)
    +{
    + return (*buffer & (0x01 << bitOffset)) && 1;
    +}
    +
    +static inline void setBit(char *buffer, unsigned char bitOffset, int8_t bit)
    +{
    + unsigned char msk = (0x01 << bitOffset);
    + if(bit)
    + *buffer |= msk;
    + else
    + *buffer &= ~msk;
    +}
    +
    +static void setWord16(short *buffer, uint16_t word)
    +{
    + *buffer = (short)word;
    +}
    +
    +static int16_t getWord16(short *buffer)
    +{
    + return((uint16_t)*buffer);
    +}
    +
    +static inline unsigned char getByte(char *buffer)
    +{
    + return((unsigned char)*buffer);
    +}
    +
    +static inline void setByte(char *buffer, unsigned char byte)
    +{
    + *buffer = byte;
    +}
    +
    +typedef struct
    +{
    + unsigned char status; /* Current status of timer - running / expired */
    + uint64_t actValue; /* Actual timer value */
    + uint64_t toValue; /* Timeout value - initialized at startup */
    + uint64_t oldTime; /* Time at previous timer increment; NOTE: if RTIME (unsigned long long) changes type, oldTime has to be adapted */
    +} commTimer;
    +
    +#define TIM_DISABLED 0
    +#define TIM_EN_RUNNING 1
    +#define TIM_EN_EXPIRED 2
    +
    +%(bus_decl)s
    +
    +%(declare_code)s
    +
    +/* LPCBus confnode user variables definition */
    +%(var_decl)s
    +
    +/* LPCBus confnode functions */
    +int __init_%(location_str)s(int argc,char **argv)
    +{
    + %(bus_init_code)s
    + return 0;
    +}
    +
    +void __cleanup_%(location_str)s(void)
    +{
    + %(bus_cleanup_code)s
    +}
    +
    +void __retrieve_%(location_str)s(void)
    +{
    +%(bus_retrieve_code)s
    +}
    +
    +void __publish_%(location_str)s(void)
    +{
    +%(bus_publish_code)s
    +}
    --- /dev/null Thu Jan 01 00:00:00 1970 +0000
    +++ b/LPCBus/uC.c Thu May 30 10:49:24 2019 +0200
    @@ -0,0 +1,35 @@
    +/* Code generated by LPCBus confnode */
    +
    +/* LPCBus confnode includes */
    +#include "app_glue.h"
    +#ifdef _WINDOWS_H
    + #include "iec_types.h"
    +#else
    + #include "iec_std_lib.h"
    +#endif
    +
    +%(declare_code)s
    +
    +/* LPCBus confnode user variables definition */
    +%(var_decl)s
    +
    +/* LPCBus confnode functions */
    +int __init_%(location_str)s(int argc,char **argv)
    +{
    +%(init_code)s
    + return 0;
    +}
    +
    +void __cleanup_%(location_str)s(void)
    +{
    +}
    +
    +void __retrieve_%(location_str)s(void)
    +{
    +%(retrieve_code)s
    +}
    +
    +void __publish_%(location_str)s(void)
    +{
    +%(publish_code)s
    +}
    --- a/LPCExtension.py Wed May 29 13:42:55 2019 +0200
    +++ b/LPCExtension.py Thu May 30 10:49:24 2019 +0200
    @@ -8,7 +8,7 @@
    import features
    from POULibrary import SimplePOULibraryFactory
    -from LPCArch import GetLPCProduct, MC9_modules, WX_GOT_modules, SVG_GOT_modules
    +from LPCArch import GetLPCProduct, GetLPCSOM, MC9_modules, WX_GOT_modules, SVG_GOT_modules
    # _lpcmanager_path, arch, etc are defined here because
    # globals() of LPCManager.py are passed to extentions
    @@ -66,21 +66,22 @@
    import targets
    from LPCtarget import LPC_target
    +som = GetLPCSOM()
    +if som is not None:
    + targets.targets = {product : {
    + "xsd": os.path.join(_lpcmanager_path, som+"target", "XSD"),
    + "class": targets.targets["Xenomai"]["class"],
    + "code": {"plc_"+som+"_main.c": targets.targets["Xenomai"]["code"]["plc_Xenomai_main.c"],
    + "plc_"+som+"_main_retain.c": os.path.join(_lpcmanager_path,
    + som+"target",
    + "plc_"+som+"_main_retain.c")}}}
    +else:
    + raise NotImplemented
    # targets.targets["LPC"] = {"xsd": os.path.join(_lpcmanager_path, "LPCtarget", "XSD"),
    # "class": lambda: LPC_target,
    # "code": {os.path.join(_lpcmanager_path, "LPCtarget", "plc_LPC_main.c")}}
    # targets.toolchains["makefile"] = os.path.join(_lpcmanager_path, "LPCtarget", "XSD_toolchain_makefile")
    -# for arch in SOM28_modules:
    -
    -targets.targets = {arch : {
    - "xsd": os.path.join(_lpcmanager_path, "SOM28target", "XSD"),
    - "class": targets.targets["Xenomai"]["class"],
    - "code": {"plc_SOM28_main.c": targets.targets["Xenomai"]["code"]["plc_Xenomai_main.c"],
    - "plc_SOM28_main_retain.c": os.path.join(_lpcmanager_path,
    - "SOM28target",
    - "plc_SOM28_main_retain.c")}}}
    -
    #
    # --------- Custom columns function Extension ------------
    #