check-ptp-camera 1.2 KB

1234567891011121314151617181920212223242526272829303132333435
  1. #!/bin/bash
  2. # This program is free software; you can redistribute it and/or
  3. # modify it under the terms of the GNU Lesser General Public
  4. # License as published by the Free Software Foundation; either
  5. # version 2 of the License, or (at your option) any later version.
  6. #
  7. # This library is distributed in the hope that it will be useful,
  8. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  10. # Lesser General Public License for more details.
  11. #
  12. # You should have received a copy of the GNU Lesser General Public
  13. # License along with this library; if not, write to the
  14. # Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
  15. # Boston, MA 02110-1301 USA
  16. #
  17. #
  18. # check if any interface of this device is a PTP camera interface (06)
  19. INTERFACE="${1:-06/01/01}"
  20. BASENAME=${DEVPATH##*/}
  21. for d in /sys/${DEVPATH}/${BASENAME}:*; do
  22. [[ -d ${d} ]] || continue
  23. INTERFACEID="$(< ${d}/bInterfaceClass)"
  24. INTERFACEID="${INTERFACEID}/$(< ${d}/bInterfaceSubClass)"
  25. INTERFACEID="${INTERFACEID}/$(< ${d}/bInterfaceProtocol)"
  26. #echo ${d}: ${INTERFACEID}
  27. if [[ ${INTERFACE} == ${INTERFACEID} ]]; then
  28. # Found interface
  29. exit 0
  30. fi
  31. done
  32. exit 1