Skip to content

Commit

Permalink
chore: revert code style changes
Browse files Browse the repository at this point in the history
Signed-off-by: Stephan Wendel <[email protected]>
  • Loading branch information
KwadFan committed Mar 19, 2024
1 parent 1df93b1 commit 058df55
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 17 deletions.
15 changes: 5 additions & 10 deletions libs/hwhandler.sh
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,7 @@ detect_avail_cams() {
local avail realpath
avail="$(find /dev/v4l/by-id/ -iname "*index0" 2>/dev/null)"
count="$(echo "${avail}" | wc -l)"
if [[ -d "/dev/v4l/by-id/" ]] &&
[[ -n "${avail}" ]]; then
if [[ -d "/dev/v4l/by-id/" ]] && [[ -n "${avail}" ]]; then
log_msg "INFO: Found ${count} available v4l2 (UVC) camera(s)"
echo "${avail}" | while read -r v4l; do
realpath=$(readlink -e "${v4l}")
Expand Down Expand Up @@ -77,7 +76,7 @@ detect_libcamera() {
## Spit /base/soc path for libcamera device
get_libcamera_path() {
if [[ "$(is_raspberry_pi)" = "1" ]] &&
[[ -x "$(command -v libcamera-hello)" ]]; then
[[ -x "$(command -v libcamera-hello)" ]]; then
libcamera-hello --list-cameras | sed '1,2d' \
| grep "\(/base/*\)" | cut -d"(" -f2 | tr -d '$)'
fi
Expand Down Expand Up @@ -131,19 +130,15 @@ function detect_legacy {
if [[ "$(is_raspberry_pi)" = "1" ]] &&
command -v vcgencmd &>/dev/null; then
if vcgencmd get_camera &>/dev/null; then
avail="$(
vcgencmd get_camera \
| awk -F '=' '{ print $3 }' \
| cut -d',' -f1
)"
avail="$( vcgencmd get_camera | awk -F '=' '{ print $3 }' | cut -d',' -f1)"
fi
fi
echo "${avail:-0}"
}

function dev_is_legacy {
v4l2-ctl --list-devices | grep -A1 -e 'mmal' \
| awk 'NR==2 {print $1}'
v4l2-ctl --list-devices | grep -A1 -e 'mmal' | \
awk 'NR==2 {print $1}'
}

## Determine if cam has H.264 Hardware encoder
Expand Down
14 changes: 7 additions & 7 deletions libs/logging.sh
Original file line number Diff line number Diff line change
Expand Up @@ -80,16 +80,16 @@ function print_cfg {
local prefix
prefix="$(date +'[%D %T]') crowsnest:"
log_msg "INFO: Print Configfile: '${CROWSNEST_CFG}'"
(sed '/^#.*/d;/./,$!d' | cut -d'#' -f1) <"${CROWSNEST_CFG}" |
(sed '/^#.*/d;/./,$!d' | cut -d'#' -f1) < "${CROWSNEST_CFG}" | \
while read -r line; do
printf "%s\t\t%s\n" "${prefix}" "${line}" >>"${CROWSNEST_LOG_PATH}"
printf "%s\t\t%s\n" "${prefix}" "${line}" >> "${CROWSNEST_LOG_PATH}"
printf "\t\t%s\n" "${line}"
done
}

function print_cams {
local device total v4l
v4l="$(find /dev/v4l/by-id/ -iname "*index0" 2>/dev/null | wc -l)"
v4l="$(find /dev/v4l/by-id/ -iname "*index0" 2> /dev/null | wc -l)"
libcamera="$(detect_libcamera)"
legacy="$(detect_legacy)"
total="$((v4l+libcamera+legacy))"
Expand All @@ -114,8 +114,8 @@ function print_cams {
fi
fi
if [[ "${legacy}" -ne 0 ]]; then
raspicam="$(v4l2-ctl --list-devices | grep -A1 -e 'mmal' \
| awk 'NR==2 {print $1}')"
raspicam="$(v4l2-ctl --list-devices | grep -A1 -e 'mmal' | \
awk 'NR==2 {print $1}')"
log_msg "Detected 'Raspicam' Device -> ${raspicam}"
if [[ ! "${CROWSNEST_LOG_LEVEL}" = "quiet" ]]; then
list_cam_formats "${raspicam}"
Expand All @@ -139,8 +139,8 @@ function print_host {
## OS Infos
## OS Version
if [[ -f /etc/os-release ]]; then
log_msg "Host Info: Distribution: $(grep "PRETTY" /etc/os-release \
| cut -d '=' -f2 | sed 's/^"//;s/"$//')"
log_msg "Host Info: Distribution: $(grep "PRETTY" /etc/os-release | \
cut -d '=' -f2 | sed 's/^"//;s/"$//')"
fi
## Release Version of MainsailOS (if file present)
if [[ -f /etc/mainsailos-release ]]; then
Expand Down

0 comments on commit 058df55

Please sign in to comment.