Skip to content

Commit

Permalink
powerCycleUsb + changelog update + ...
Browse files Browse the repository at this point in the history
  • Loading branch information
tcharp38 committed Apr 11, 2024
1 parent 0ec5935 commit b81f89a
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 23 deletions.
19 changes: 8 additions & 11 deletions .tools/update_changelog.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

# Update changelog to add version

CL=docs/fr_FR/changelog.rst
TMP=docs/fr_FR/changelog.rst.tmp
CL=docs/fr_FR/changelog.md
TMP=docs/fr_FR/changelog.md.tmp

echo "Updating changelog..."

Expand All @@ -12,16 +12,13 @@ STEP=0
cat ${CL} |
while IFS= read -r L
do
# ChangeLog
# =========
# # ChangeLog (title)
#
# - JSON: Correction setReportTemp (#1918).

# ChangeLog
# =========
# # ChangeLog (title)
#
# VERSION X
# ---------
# ## VERSION X
#
# - JSON: Correction setReportTemp (#1918).

Expand All @@ -30,7 +27,7 @@ do

if [ ${STEP} -eq 0 ]; then
echo "${L}" >> ${TMP}
if [[ ${L} == "==="* ]]; then
if [[ ${L} == "# "* ]]; then
STEP=1 # Title found
fi
elif [ ${STEP} -eq 1 ]; then
Expand All @@ -53,14 +50,14 @@ do
continue
fi
# Assuming 'VERSION' line + '------'
if [[ "${L}" == *"${VERSION}"* ]]; then
if [[ "${L}" == "## ${VERSION}"* ]]; then
echo "- There is already correct version in changelog. Doing nothing"
echo
rm ${TMP}
break
fi
# Adding current version
echo "${VERSION}" >> ${TMP}
echo "## ${VERSION}" >> ${TMP}
fi
STEP=2 # Copy all remaining lines
else # STEP==2
Expand Down
2 changes: 1 addition & 1 deletion core/class/Abeille.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -482,7 +482,7 @@ public static function cron() {
$zgPort = $config['ab::zgPort'.$zgId];
if (($zgType == "USB") || ($zgType == "USBv2")) {
if ($config['ab::preventUsbPowerCycle'] == 'Y')
log::add('Abeille', 'Debug', 'Power cycle required for Zigate '.$zgId.' but disabled');
log::add('Abeille', 'warning', 'Power cycle required for Zigate '.$zgId.' but disabled');
else {
$dir = __DIR__."/../scripts";
$cmd = "cd ".$dir."; ".system::getCmdSudo()." ./powerCycleUsb.sh ".$zgPort." 1>/tmp/jeedom/Abeille/powerCycleUsb.log 2>&1";
Expand Down
2 changes: 1 addition & 1 deletion core/class/AbeilleCmdProcess.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -4461,7 +4461,7 @@ function processCmd($Command) {
// if (hexdec($dataSize) > 48)
// $dataSize = "30"; // Required ?
$realOffset = $fw['startIdx'] + hexdec($imgOffset);
cmdLog('debug', " Reading data from real offset ".$realOffset, $this->debug['processCmd']);
cmdLog('debug', " otaImageBlockResponse: Offset=${realOffset}, ImgSize=${imgSize}");
fseek($fh, $realOffset, SEEK_SET);
$data = fread($fh, hexdec($dataSize));
$data = strtoupper(bin2hex($data));
Expand Down
5 changes: 1 addition & 4 deletions core/class/AbeilleParser.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -4297,11 +4297,9 @@ function decode8002($dest, $payload, $lqi) {
$maxDataSize = AbeilleTools::reverseHex(substr($pl, 26, 2));

msgToCmd(PRIO_NORM, "Cmd".$dest."/".$srcAddr."/otaImageBlockResponse", 'ep='.$srcEp.'&sqn='.$sqn.'&cmd=05&manufCode='.$manufCode.'&imgType='.$imgType.'&imgOffset='.$fileOffset.'&maxData='.$maxDataSize);
// msgToCmd(PRIO_NORM, "Cmd".$dest."/".$srcAddr."/cmd-0019", 'ep='.$srcEp.'&cmd=05&manufCode='.$manufCode.'&imgType='.$imgType.'&imgOffset='.$fileOffset.'&maxData='.$maxDataSize);

$m = " fieldCtrl=".$fieldControl.", manufCode=".$manufCode.", imgType=".$imgType.", fileVers=".$fileVersion.", fileOffset=".$fileOffset.", maxData=".$maxDataSize;
parserLog2('debug', $srcAddr, $m);
// $toMon[] = $m;
} else if ($cmd == "06") { // Upgrade end request
$status = substr($pl, 0, 2);
$manufCode = substr($pl, 2, 4);
Expand All @@ -4314,14 +4312,13 @@ function decode8002($dest, $payload, $lqi) {
.', ImgType='.$imgType
.', FileVers='.$fileVersion;
parserLog2('debug', $srcAddr, $m);
// $toMon[] = $m;

// msgToCmd(PRIO_NORM, "Cmd".$dest."/".$addr."/otaUpgradeEndResponse", 'ep='.$srcEp.'&cmd=02&status=00&manufCode='.$manufCode.'&imgType='.$imgType.'&imgVersion='.$imgVers.'&imgSize='.$imgSize);
$eqLogic = Abeille::byLogicalId($dest.'/'.$srcAddr, 'Abeille');
$eqHName = $eqLogic->getHumanName();
switch ($status) {
case "00":
message::add("Abeille", $eqHName.": Mise-à-jour terminée");
message::add("Abeille", $eqHName.": Mise-à-jour du firmware terminée");
break;
case "95":
message::add("Abeille", $eqHName.": Transfert du firmware annulé par l'équipement");
Expand Down
17 changes: 11 additions & 6 deletions core/scripts/powerCycleUsb.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
###

# Note: https://www.kernel.org/doc/Documentation/usb/power-management.txt
DISCONNECT_TIME=2

echo -n "powerCycleUsb.sh starting: "
date
Expand Down Expand Up @@ -37,22 +38,26 @@ if [ "${DMESG}" == "" ]; then
dmesg
exit 3
fi

# TODO: DMESG may contains a list of "now attached to". How to keep most recent/last one ?

#echo "DMESG=$DMESG"
DMESG2=`echo ${DMESG} | sed 's/:.*//'`
echo "DMESG2='$DMESG2'"
DMESG2=`echo ${DMESG} | sed 's/:.*//'` # Remove everything after ':'
CONVERTOR=`echo ${DMESG} | awk '{ print $3 }'`
# echo "DMESG2='$DMESG2'"
PORT=${DMESG2#usb }
echo "PORT='$PORT'"
echo "CONVERTOR=${CONVERTOR}, PORT='${PORT}'"

# Port identified. Let's do power cycling
if [ -e "/sys/bus/usb/drivers/usb/unbind" ]; then
echo "Disconnecting ${PORT}"
echo "Disconnecting '${PORT}' ${DISCONNECT_TIME} sec"
echo "$PORT" > /sys/bus/usb/drivers/usb/unbind
ERR=$?
if [ $ERR -ne 0 ]; then
sudo echo "= ERROR: 'unbind' failed ! Are you root ?"
else
sleep 2
echo "Reconnecting ${PORT}"
sleep ${DISCONNECT_TIME}
echo "Reconnecting '${PORT}'"
sudo echo "$PORT" > /sys/bus/usb/drivers/usb/bind
fi
else
Expand Down
3 changes: 3 additions & 0 deletions docs/fr_FR/Changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@
- Mais **ATTENTION** si vous migrez d'une version 'legacy' vers 'OPDM' il vous faudra **effacer la PDM et réapparairer tous vos équipements**.

- Moes ZM-105-M: Support préliminaire (2697).
- Interne: Amélioration msg dbg OTA.
- Interne: powerCycleUsb: Améliorations mineures.
- Changelog: Migré au format markdown.

## 240409-BETA-1

Expand Down

0 comments on commit b81f89a

Please sign in to comment.