Skip to content

Commit

Permalink
fix: revert code style changes
Browse files Browse the repository at this point in the history
Signed-off-by: Stephan Wendel <me@stephanwe.de>
  • Loading branch information
KwadFan committed Jan 31, 2024
1 parent a94288e commit cc4217a
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 28 deletions.
30 changes: 15 additions & 15 deletions libs/hwhandler.sh
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ list_cam_formats() {
prefix="$(date +'[%D %T]') crowsnest:"
log_msg "Supported Formats:"
while read -r i; do
printf "%s\t\t%s\n" "${prefix}" "${i}" >>"${CROWSNEST_LOG_PATH}"
printf "%s\t\t%s\n" "${prefix}" "${i}" >> "${CROWSNEST_LOG_PATH}"
done < <(v4l2-ctl -d "${device}" --list-formats-ext | sed '1,3d')
}

Expand All @@ -54,15 +54,15 @@ list_cam_v4l2ctrls() {
prefix="$(date +'[%D %T]') crowsnest:"
log_msg "Supported Controls:"
while read -r i; do
printf "%s\t\t%s\n" "${prefix}" "${i}" >>"${CROWSNEST_LOG_PATH}"
printf "%s\t\t%s\n" "${prefix}" "${i}" >> "${CROWSNEST_LOG_PATH}"
done < <(v4l2-ctl -d "${device}" --list-ctrls-menus)
}

## Determine connected libcamera (CSI) device
detect_libcamera() {
local avail
if [[ "$(is_raspberry_pi)" = "1" ]] &&
[[ -x "$(command -v libcamera-hello)" ]]; then
[[ -x "$(command -v libcamera-hello)" ]]; then
avail="$(libcamera-hello --list-cameras | grep -c "Available")"
if [[ "${avail}" = "1" ]]; then
get_libcamera_path | wc -l
Expand All @@ -78,8 +78,8 @@ detect_libcamera() {
get_libcamera_path() {
if [[ "$(is_raspberry_pi)" = "1" ]] &&
[[ -x "$(command -v libcamera-hello)" ]]; then
libcamera-hello --list-cameras | sed '1,2d' |
grep "\(/base/*\)" | cut -d"(" -f2 | tr -d '$)'
libcamera-hello --list-cameras | sed '1,2d' \
| grep "\(/base/*\)" | cut -d"(" -f2 | tr -d '$)'
fi
}

Expand All @@ -89,7 +89,7 @@ list_picam_resolution() {
prefix="$(date +'[%D %T]') crowsnest:"
log_msg "'libcamera' device(s) resolution(s) :"
while read -r i; do
printf "%s\t\t%s\n" "${prefix}" "${i}" >>"${CROWSNEST_LOG_PATH}"
printf "%s\t\t%s\n" "${prefix}" "${i}" >> "${CROWSNEST_LOG_PATH}"
done < <(libcamera-hello --list-cameras | sed '1,2d;s/Modes:/Colorspace:/')
}

Expand Down Expand Up @@ -137,18 +137,18 @@ function detect_legacy {
command -v vcgencmd &>/dev/null; then
if vcgencmd get_camera &>/dev/null; then
avail="$(
vcgencmd get_camera |
awk -F '=' '{ print $3 }' |
cut -d',' -f1
)"
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 All @@ -172,7 +172,7 @@ detect_mjpeg() {
## Check if device is raspberry sbc
is_raspberry_pi() {
if [[ -f /proc/device-tree/model ]] &&
grep -q "Raspberry" /proc/device-tree/model; then
grep -q "Raspberry" /proc/device-tree/model; then
echo "1"
else
echo "0"
Expand All @@ -181,7 +181,7 @@ is_raspberry_pi() {

is_pi5() {
if [[ -f /proc/device-tree/model ]] &&
grep -q "Raspberry Pi 5" /proc/device-tree/model; then
grep -q "Raspberry Pi 5" /proc/device-tree/model; then
echo "1"
else
echo "0"
Expand All @@ -190,7 +190,7 @@ is_pi5() {

is_ubuntu_arm() {
if [[ "$(is_raspberry_pi)" = "1" ]] &&
grep -q "ubuntu" /etc/os-release; then
grep -q "ubuntu" /etc/os-release; then
echo "1"
else
echo "0"
Expand Down
26 changes: 13 additions & 13 deletions libs/logging.sh
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ function init_logging {

function set_log_level {
local loglevel
loglevel="$(get_param crowsnest log_level 2>/dev/null)"
loglevel="$(get_param crowsnest log_level 2> /dev/null)"
# Set default log_level to quiet
if [ -z "${loglevel}" ] || [[ "${loglevel}" != @(quiet|verbose|debug) ]]; then
CROWSNEST_LOG_LEVEL="quiet"
Expand All @@ -51,7 +51,7 @@ function set_log_level {

function delete_log {
local del_log
del_log="$(get_param "crowsnest" delete_log 2>/dev/null)"
del_log="$(get_param "crowsnest" delete_log 2> /dev/null)"
if [ "${del_log}" = "true" ]; then
rm -rf "${CROWSNEST_LOG_PATH}"
fi
Expand All @@ -61,7 +61,7 @@ function log_msg {
local msg prefix
msg="${1}"
prefix="$(date +'[%D %T]') crowsnest:"
printf "%s %s\n" "${prefix}" "${msg}" >>"${CROWSNEST_LOG_PATH}"
printf "%s %s\n" "${prefix}" "${msg}" >> "${CROWSNEST_LOG_PATH}"
printf "%s\n" "${msg}"
}

Expand All @@ -81,18 +81,18 @@ function print_cfg {
prefix="$(date +'[%D %T]') crowsnest:"
log_msg "INFO: Print Configfile: '${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 "\t\t%s\n" "${line}"
done
while read -r line; do
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)"
libcamera="$(detect_libcamera)"
legacy="$(detect_legacy)"
total="$((v4l + libcamera + legacy))"
total="$((v4l+libcamera+legacy))"
if [ "${total}" -eq 0 ]; then
log_msg "ERROR: No usable Devices Found. Stopping $(basename "${0}")."
exit 1
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 All @@ -154,7 +154,7 @@ function print_host {
log_msg "Host Info: Model: ${sbc_model}"
fi
if [[ -n "${generic_model}" ]] &&
[[ -z "${sbc_model}" ]]; then
[[ -z "${sbc_model}" ]]; then
log_msg "Host Info: Model: ${generic_model}"
fi
## CPU count
Expand Down

0 comments on commit cc4217a

Please sign in to comment.