diff --git a/recipes-extended/um-service-cfg/config/ports b/recipes-extended/um-service-cfg/config/ports deleted file mode 100644 index e69de29..0000000 diff --git a/recipes-extended/um-service-cfg/config/ports-v1 b/recipes-extended/um-service-cfg/config/ports-v1 new file mode 100644 index 0000000..b23fac2 --- /dev/null +++ b/recipes-extended/um-service-cfg/config/ports-v1 @@ -0,0 +1,6 @@ +USER_MODULE_kline_port="2202" +USER_MODULE_lin_port="2200" +USER_MODULE_uart_port="2204" +USER_MODULE_cannellonie_port_remote="20000" +USER_MODULE_cannellonie_port_local="20000" +USER_MODULE_remote_gpio_port="6666" diff --git a/recipes-extended/um-service-cfg/config/ports-v2 b/recipes-extended/um-service-cfg/config/ports-v2 new file mode 100644 index 0000000..761e02e --- /dev/null +++ b/recipes-extended/um-service-cfg/config/ports-v2 @@ -0,0 +1,7 @@ +USER_MODULE_at_cmd_handler_port="7000" +USER_MODULE_kline_port="7050" +USER_MODULE_lin_port="7060" +USER_MODULE_uart_port="7040" +USER_MODULE_cannellonie_port_remote="7010 7011" +USER_MODULE_cannellonie_port_local="7010 7011" +USER_MODULE_remote_gpio_port="7020" diff --git a/recipes-extended/um-service-cfg/files/um-service-config.sh b/recipes-extended/um-service-cfg/files/um-service-config.sh index 66d29d1..8d63968 100644 --- a/recipes-extended/um-service-cfg/files/um-service-config.sh +++ b/recipes-extended/um-service-cfg/files/um-service-config.sh @@ -3,7 +3,8 @@ UM_CONFIG_PATH=/etc/user-module UM_CONFIG_FILE=network.conf UM_CONFIG=$UM_CONFIG_PATH/$UM_CONFIG_FILE -UM_PORTS=$UM_CONFIG_PATH/ports +UM_PORTS_V1=$UM_CONFIG_PATH/ports-v1 +UM_PORTS_V2=$UM_CONFIG_PATH/ports-v2 UM_DTS_NODE=/proc/device-tree/user_module @@ -21,7 +22,16 @@ for f in $UM_DTS_NODE/*; do echo "USER_MODULE_${f##*/}=\"`cat $f | tr -d '\0' `\"" | sed -E "s/,|-/_/g" >> $UM_CONFIG done -cat $UM_PORTS >> $UM_CONFIG +source $UM_CONFIG + +# Decide which config to load depending on the sw revision +if `nc -z $USER_MODULE_ipv4_addr 7000` ; then + echo "New UM software detected" + cat $UM_PORTS_V2 >> $UM_CONFIG +else + echo "Old UM software detected" + cat $UM_PORTS_V1 >> $UM_CONFIG +fi # source all fetched informations source $UM_CONFIG diff --git a/recipes-extended/um-service-cfg/um-service-cfg_0.0.1.bb b/recipes-extended/um-service-cfg/um-service-cfg_0.0.1.bb index a572f79..56b4a95 100644 --- a/recipes-extended/um-service-cfg/um-service-cfg_0.0.1.bb +++ b/recipes-extended/um-service-cfg/um-service-cfg_0.0.1.bb @@ -5,37 +5,27 @@ LICENSE = "MIT" LIC_FILES_CHKSUM = "file://${COMMON_LICENSE_DIR}/MIT;md5=0835ade698e0bcf8506ecda2f7b4f302" FILESEXTRAPATHS_prepend := "${THISDIR}/config:" +ALTERNATIVE_PRIORITY[netcat] = "100" +RDEPENDS_${PN} = "netcat" + SRC_URI = " \ - file://um-service-config.service \ - file://um-service-config.sh \ - file://user-module.target \ + file://um-service-config.service \ + file://um-service-config.sh \ + file://user-module.target \ file://um-rgpio-config.sh \ file://um-rgpio-config.service \ - file://ports \ - " + file://ports-v1 \ + file://ports-v2 \ + " FILES_${PN} = "${systemd_unitdir}/system ${bindir} /etc/user-module" -SYSTEMD_SERVICE_${PN} =" \ +SYSTEMD_SERVICE_${PN} =" \ um-service-config.service \ um-rgpio-config.service \ user-module.target \ " -do_install_append() { -# port config - echo "USER_MODULE_kline_port=\"2202\"" >> ${WORKDIR}/ports - echo "USER_MODULE_lin_port=\"2200\"" >> ${WORKDIR}/ports - echo "USER_MODULE_uart_port=\"2204\"" >> ${WORKDIR}/ports - echo "USER_MODULE_cannellonie_port_remote=\"20000\"" >> ${WORKDIR}/ports - echo "USER_MODULE_cannellonie_port_local=\"20000\"" >> ${WORKDIR}/ports - echo "USER_MODULE_remote_gpio_port=\"6666\"" >> ${WORKDIR}/ports - - install -d ${D}/etc/user-module - install -m 644 ${WORKDIR}/ports ${D}/etc/user-module/ports -} - - do_install() { install -d ${D}${systemd_unitdir}/system @@ -49,10 +39,14 @@ do_install() { install -d ${D}${bindir} install -m 744 ${WORKDIR}/um-service-config.sh ${D}${bindir}/um-service-config - + install -d ${D}${systemd_unitdir}/system install -m 644 ${WORKDIR}/um-rgpio-config.service ${D}${systemd_unitdir}/system/ install -d ${D}${bindir} install -m 744 ${WORKDIR}/um-rgpio-config.sh ${D}${bindir}/um-rgpio-config + + install -d ${D}/etc/user-module + install -m 644 ${WORKDIR}/ports-v1 ${D}/etc/user-module/ports-v1 + install -m 644 ${WORKDIR}/ports-v2 ${D}/etc/user-module/ports-v2 }