Skip to content

Commit

Permalink
[Automated] Merged develop into target master
Browse files Browse the repository at this point in the history
  • Loading branch information
meteyou authored Apr 2, 2024
2 parents e96cd46 + 7f85366 commit ea6ab64
Show file tree
Hide file tree
Showing 6 changed files with 63 additions and 25 deletions.
4 changes: 2 additions & 2 deletions bin/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,10 @@ CLONE_FLAGS=(--depth=1 --single-branch)
# Ustreamer repo
USTREAMER_PATH="ustreamer"
if [[ -z "${CROWSNEST_USTREAMER_REPO_SHIP}" ]]; then
CROWSNEST_USTREAMER_REPO_SHIP="https://github.com/mryel00/ustreamer.git"
CROWSNEST_USTREAMER_REPO_SHIP="https://github.com/pikvm/ustreamer.git"
fi
if [[ -z "${CROWSNEST_USTREAMER_REPO_BRANCH}" ]]; then
CROWSNEST_USTREAMER_REPO_BRANCH="master"
CROWSNEST_USTREAMER_REPO_BRANCH="v6.10"
fi

# Camera-streamer repo
Expand Down
13 changes: 5 additions & 8 deletions libs/core.sh
Original file line number Diff line number Diff line change
Expand Up @@ -82,18 +82,15 @@ function check_dep {

function check_apps {
local cstreamer ustreamer
ustreamer_base="bin/ustreamer"
ustreamer="$(find "${BASE_CN_PATH}"/"${ustreamer_base}" \
-iname 'ustreamer.bin' 2> /dev/null | sed '1q')"
ustreamer="bin/ustreamer/src/ustreamer.bin"
cstreamer="bin/camera-streamer/camera-streamer"

if [[ -x "${ustreamer}" ]]; then
log_msg "Dependency: '${ustreamer##*/}' found in ${ustreamer_base}/${ustreamer##*/}."
UST_BIN="${ustreamer}"
if [[ -x "${BASE_CN_PATH}/${ustreamer}" ]]; then
log_msg "Dependency: 'ustreamer' found in ${ustreamer}."
UST_BIN="${BASE_CN_PATH}/${ustreamer}"
# shellcheck disable=SC2034
declare -r UST_BIN
else
log_msg "Dependency: '${ustreamer##*/}' not found. Exiting!"
log_msg "Dependency: 'ustreamer' not found. Exiting!"
exit 1
fi

Expand Down
57 changes: 47 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 @@ -63,8 +62,8 @@ detect_libcamera() {
local avail
if [[ "$(is_raspberry_pi)" = "1" ]] &&
[[ -x "$(command -v libcamera-hello)" ]]; then
avail="$(libcamera-hello --list-cameras | sed '/^\[.*\].*/d' | awk 'NR==1 {print $1}')"
if [[ "${avail}" = "Available" ]]; then
avail="$(libcamera-hello --list-cameras | grep -c "Available")"
if [[ "${avail}" = "1" ]]; then
get_libcamera_path | wc -l
else
echo "0"
Expand All @@ -83,23 +82,61 @@ get_libcamera_path() {
fi
}

# print libcamera resolutions
list_picam_resolution() {
local prefix
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}"
done < <(libcamera-hello --list-cameras | sed '1,2d;s/Modes:/Colorspace:/')
}

get_libcamera_controls() {
local ust_bin flags
flags=( --camera-type=libcamera --camera-list_options )
ust_bin="${BASE_CN_PATH}/bin/camera-streamer/camera-streamer"
if [[ -x "${ust_bin}" ]]; then
"${ust_bin}" "${flags[@]}" --camera-path="$(get_libcamera_path)" 2> /dev/null | \
sed 's/device//g;/^SNAPSHOT/q' | sed '/^SNAPSHOT/d' | \
sed '/^CAMERA/d;/- property/d' | sed '/camera-streamer Version:/d' | \
sed 's/- available option: //g' | sed '/^$/d;' | \
sed 's/([0-9]*[a-z,0-9]\,//g' | sed '/type=7/d;/type=4/d' | \
sed 's/type=1/ (bool/g;s/type=3/ (int/g;s/type=5/ (float/g' | \
sed 's/\[/min=/g;s/\.\./ max=/g;s/\]$//g'
else
log_msg "WARN: 'libcamera' device option can not be displayed, because"
log_msg "WARN: camera-streamer is not installed"
fi
}

list_picam_controls() {
local prefix
prefix="$(date +'[%D %T]') crowsnest:"
log_msg "'libcamera' device controls :"
while read -r i; do
if [[ ! "${i}" =~ "INFO" ]]; then
printf "%s\t\t%s\n" "${prefix}" "${i}" >>"${CROWSNEST_LOG_PATH}"
fi
done < <(get_libcamera_controls)
# blank line workaround
log_msg ""
}

# Determine connected "legacy" device
function detect_legacy {
local avail
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 \
)"
if vcgencmd get_camera &> /dev/null; then
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' | \
v4l2-ctl --list-devices | grep -A1 -e 'mmal' | \
awk 'NR==2 {print $1}'
}

Expand Down
6 changes: 5 additions & 1 deletion libs/logging.sh
Original file line number Diff line number Diff line change
Expand Up @@ -108,9 +108,13 @@ function print_cams {
for device in $(get_libcamera_path); do
log_msg "Detected 'libcamera' device -> ${device}"
done
if [[ "$(is_pi5)" = "0" ]]; then
list_picam_resolution
list_picam_controls
fi
fi
if [[ "${legacy}" -ne 0 ]]; then
raspicam="$(v4l2-ctl --list-devices | grep -A1 -e 'mmal' | \
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
Expand Down
4 changes: 2 additions & 2 deletions tools/configure.sh
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ CN_CONFIG_CONFIGPATH="${CN_CONFIG_ROOTPATH}/config"
CN_CONFIG_LOGPATH="${CN_CONFIG_ROOTPATH}/logs"
CN_CONFIG_ENVPATH="${CN_CONFIG_ROOTPATH}/systemd"
CN_MOONRAKER_CONFIG_PATH="${CN_CONFIG_CONFIGPATH}/moonraker.conf"
CN_USTREAMER_REPO="https://github.com/mryel00/ustreamer.git"
CN_USTREAMER_BRANCH="master"
CN_USTREAMER_REPO="https://github.com/pikvm/ustreamer.git"
CN_USTREAMER_BRANCH="v6.10"
CN_CAMERA_STREAMER_REPO="https://github.com/ayufan/camera-streamer.git"
CN_CAMERA_STREAMER_BRANCH="master"

Expand Down
4 changes: 2 additions & 2 deletions tools/libs/config.sh
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ import_config() {
[[ -n "${CROWSNEST_CONFIG_PATH}" ]] || CROWSNEST_CONFIG_PATH="/home/${BASE_USER}/printer_data/config"
[[ -n "${CROWSNEST_LOG_PATH}" ]] || CROWSNEST_LOG_PATH="/home/${BASE_USER}/printer_data/logs"
[[ -n "${CROWSNEST_ENV_PATH}" ]] || CROWSNEST_ENV_PATH="/home/${BASE_USER}/printer_data/systemd"
[[ -n "${CROWSNEST_USTREAMER_REPO_SHIP}" ]] || CROWSNEST_USTREAMER_REPO_SHIP="https://github.com/mryel00/ustreamer.git"
[[ -n "${CROWSNEST_USTREAMER_REPO_BRANCH}" ]] || CROWSNEST_USTREAMER_REPO_BRANCH="master"
[[ -n "${CROWSNEST_USTREAMER_REPO_SHIP}" ]] || CROWSNEST_USTREAMER_REPO_SHIP="https://github.com/pikvm/ustreamer.git"
[[ -n "${CROWSNEST_USTREAMER_REPO_BRANCH}" ]] || CROWSNEST_USTREAMER_REPO_BRANCH="v6.10"
[[ -n "${CROWSNEST_CAMERA_STREAMER_REPO_SHIP}" ]] || CROWSNEST_CAMERA_STREAMER_REPO_SHIP="https://github.com/ayufan/camera-streamer.git"
[[ -n "${CROWSNEST_CAMERA_STREAMER_REPO_BRANCH}" ]] || CROWSNEST_CAMERA_STREAMER_REPO_BRANCH="master"
status_msg "Using default configuration ..." "0"
Expand Down

0 comments on commit ea6ab64

Please sign in to comment.