lpcmanager

Parents 49677dcdda8e
Children acee64d7456d
Added Right Bus Xenomai driver support through RTDM IOCTLs. Othe minor fixes for MC9 build
  • +69 -10
    LPCManager.py
  • --- a/LPCManager.py Fri Nov 21 18:15:53 2014 +0100
    +++ b/LPCManager.py Fri Nov 21 20:16:03 2014 +0100
    @@ -274,7 +274,7 @@
    *buffer &= ~msk;
    }
    -%(bus_code)s
    +%(bus_decl)s
    %(declare_code)s
    @@ -285,26 +285,33 @@
    int __init_%(location_str)s(int argc,char **argv)
    {
    %(init_code)s
    + %(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
    %(retrieve_code)s
    }
    void __publish_%(location_str)s(void)
    {
    %(publish_code)s
    +%(bus_publish_code)s
    }
    """}
    bus_code = {
    - "MC9:Right":"""
    + "MC9:Right": {
    + "decl" : """
    +#include <rtdm/rtdm.h>
    +
    /* LPCBus confnode includes */
    #define RIGHT_READ_BUFSIZE 30 /**< Right bus read buffer size */
    #define RIGHT_WRITE_BUFSIZE 30 /**< Right bus write buffer size */
    @@ -328,16 +335,58 @@
    #define RTSMT_RTIOC_READ _IOR(RTIOC_TYPE_SMT, 0x02, rightReadBuf_t)
    #define RTSMT_RTIOC_WRITE _IOR(RTIOC_TYPE_SMT, 0x03, rightWriteBuf_t)
    -rightReadBuf_t rightReadBuf;
    -rightWriteBuf_t rightWriteBuf;
    -rightI2CMod_t rightI2CMod;
    +static rightReadBuf_t rightReadBuf;
    +static rightWriteBuf_t rightWriteBuf;
    +static rightI2CMod_t rightI2CMod;
    +
    +static int rightbusfd = -1;
    /* XXX TODO #include "smarteh.h" */
    """,
    - "MC9:On Board":"""
    + "init":"""
    +#define DEVICEFILENAME "rightbus"
    +
    +int err;
    +rightbusfd = rt_dev_open( DEVICEFILENAME, 0);
    +if (rightbusfd < 0) {
    + printf("can't open %s rtdm device, %s\\n", DEVICEFILENAME,
    + strerror(-rightbusfd));
    + return rightbusfd;
    +}
    +
    +err = rt_dev_ioctl(rightbusfd, RTSMT_RTIOC_INIT, &rightI2CMod);
    +if (err) {
    + printf("error while RTSMT_RTIOC_INIT, %s\\n",
    + strerror(-err));
    + rt_dev_close(rightbusfd);
    + return err;
    +}
    +""",
    + "retrieve":"""
    +rt_dev_ioctl(rightbusfd, RTSMT_RTIOC_READ, &rightReadBuf);
    +""",
    + "publish":"""
    +rt_dev_ioctl(rightbusfd, RTSMT_RTIOC_WRITE, &rightWriteBuf);
    +""",
    + "cleanup":"""
    +rt_dev_close(rightbusfd);
    +""",
    + },
    + "MC9:On Board": {
    + "decl" : """
    #define MAX_ONBOARD_DEVICES 2
    unsigned char onBoardDev[MAX_ONBOARD_DEVICES][2]; /**< Tables containing information about enabled on-board devices (initialized by Composer) */
    -"""}
    +""",
    + "init":"""
    +""",
    + "retrieve":"""
    +""",
    + "publish":"""
    +""",
    + "cleanup":"""
    +""",
    + },
    +}
    class LPCBus(object):
    @@ -461,14 +510,24 @@
    location_str = "_".join(map(str, current_location))
    BusName = arch + ":" + self.BaseParams.getName()
    -
    +
    + bcode = bus_code.get(BusName,{"decl":"",
    + "init":"",
    + "retrieve":"",
    + "publish":"",
    + "cleanup":"",
    + })
    code_str = {"location_str": location_str,
    "var_decl": "",
    "declare_code": "",
    "init_code": "",
    "retrieve_code": "",
    "publish_code": "",
    - "bus_code":bus_code.get(BusName,"")
    + "bus_decl":bcode["decl"],
    + "bus_init_code": bcode["init"],
    + "bus_cleanup_code": bcode["cleanup"],
    + "bus_retrieve_code": bcode["retrieve"],
    + "bus_publish_code": bcode["publish"],
    }
    for module in _GetModuleChildren(self):
    @@ -793,7 +852,7 @@
    def GetTarget(self):
    target = ProjectController.GetTarget(self)
    - if self.CurrentMode != SIMULATION_MODE:
    + if self.CurrentMode != SIMULATION_MODE and arch != "MC9":
    target.getcontent().setBuildPath(self.BuildPath)
    return target