From 814c92c43d522f395814461c6c213b76889fe215 Mon Sep 17 00:00:00 2001 From: Hendrik Langer Date: Tue, 17 Jul 2018 23:29:52 +0200 Subject: [PATCH] fix python script --- README.md | 52 +++++++++++++++++---------- doc/README.md | 35 ++++++++++++++++++ raspberry-environment/cmd.txt | 8 ++--- raspberry-environment/pythonscript.py | 28 +++++++++++---- windows-snapshot-tool/src/main.cpp | 15 ++++++++ 5 files changed, 108 insertions(+), 30 deletions(-) create mode 100644 doc/README.md diff --git a/README.md b/README.md index 39451f5..10480ea 100644 --- a/README.md +++ b/README.md @@ -1,35 +1,49 @@ -https://blog.danman.eu/new-version-of-lenkeng-hdmi-over-ip-extender-lkv373a/ -https://github.com/gkralik/python-gst-tutorial -https://github.com/brettviren/pygst-tutorial-org +## Parts + * Mini-HDMI <-> HDMI Adapter + * Mini-USB <-> USB A Cable + * Micro-SD-Card >= 2GB + * Raspberry Pi Zero or Zero W or Model A (Model B/2B/3 not supported!) -gst-launch-1.0 -v udpsrc multicast-iface="eth0" multicast-group=239.255.42.42 auto-multicast=true port=5004 caps="video/mpegts, media=(string)video" ! tsdemux ! decodebin ! videoconvert ! autovideosink sync=false +## Hardware + ______________________ + | :::::::::::::::::::: | + | | + |_HDMI________USB__PWR_| + | | nc + v v + Beamer PC -vlc -vvv udp://@239.255.42.42:5004 +## Build windows snapshot-tool +cd windows-snapshot-tool +mkdir build && cd build +cmake -DCMAKE_TOOLCHAIN_FILE=../Toolchain-cross-mingw32-linux.cmake ../ +make -raspi: ! omxh264dec ! autovideosink -fbdevsink device=/dev/fb0 -h264parse ! omxh264dec ! glimagesink -gst-launch-1.0 videotestsrc ! eglglessink - -g_mass_storage -stall=0 ro=1 +## prepare raspberry pi +install raspbian lite -(gstreamer-1.0) python3-gi (or python3-gst-1.0 ??) gstreamer1.0-omx gstreamer1.0-plugins-good gstreamer1.0-plugins-bad +sudo raspi-config + * ?? + * ?? +sudo su - +apt update +apt dist-upgrade +apt install python3-pyinotify python3-rpi.gpio -length: 1324 (packet: 1358) -pid: 0x7d1 cc=0 1 2 12 13 14 15 +echo "dtoverlay=dwc2" >> /boot/config.txt +readonly-root -how to build: -mkdir build && cd build -cmake -DCMAKE_TOOLCHAIN_FILE=../Toolchain-cross-mingw32-linux.cmake ../ -make +## ToDo + * readonly-root + * dritte led für boot? + * screenshot-tool option für sofortigen screenshot diff --git a/doc/README.md b/doc/README.md new file mode 100644 index 0000000..39451f5 --- /dev/null +++ b/doc/README.md @@ -0,0 +1,35 @@ + +https://blog.danman.eu/new-version-of-lenkeng-hdmi-over-ip-extender-lkv373a/ + +https://github.com/gkralik/python-gst-tutorial +https://github.com/brettviren/pygst-tutorial-org + + +gst-launch-1.0 -v udpsrc multicast-iface="eth0" multicast-group=239.255.42.42 auto-multicast=true port=5004 caps="video/mpegts, media=(string)video" ! tsdemux ! decodebin ! videoconvert ! autovideosink sync=false + +vlc -vvv udp://@239.255.42.42:5004 + + +raspi: ! omxh264dec ! autovideosink +fbdevsink device=/dev/fb0 +h264parse ! omxh264dec ! glimagesink +gst-launch-1.0 videotestsrc ! eglglessink + +g_mass_storage +stall=0 ro=1 + + + +(gstreamer-1.0) python3-gi (or python3-gst-1.0 ??) gstreamer1.0-omx gstreamer1.0-plugins-good gstreamer1.0-plugins-bad + + +length: 1324 (packet: 1358) +pid: 0x7d1 cc=0 1 2 12 13 14 15 + + + +how to build: + +mkdir build && cd build +cmake -DCMAKE_TOOLCHAIN_FILE=../Toolchain-cross-mingw32-linux.cmake ../ +make diff --git a/raspberry-environment/cmd.txt b/raspberry-environment/cmd.txt index 286cb4e..6431548 100644 --- a/raspberry-environment/cmd.txt +++ b/raspberry-environment/cmd.txt @@ -119,11 +119,11 @@ done ToDo: - -inotify only once!! recreate image on boot +repartition for usbimage? +memory split? (hdmi ausgabe u framebuffer beachten!) readonly-root +dritte led für boot? - -python3-pyinotify +screenshot-tool option für sofortigen screenshot diff --git a/raspberry-environment/pythonscript.py b/raspberry-environment/pythonscript.py index 899b58f..2bb16db 100644 --- a/raspberry-environment/pythonscript.py +++ b/raspberry-environment/pythonscript.py @@ -120,7 +120,18 @@ if __name__ == '__main__': GPIO.output(23, GPIO.LOW) try: - subprocess.run(['modprobe', 'g_mass_storage', 'file=/usbdisk.img', 'stall=0', 'removable=1', 'iSerialNumber=1234567890'], shell=False, check=True) + subprocess.run(['dd', 'if=/dev/zero', 'of=/tmp/usbdisk.img', 'bs=1M', 'count=96'], shell=False, check=True) + #sfdisk + #loop-mount + #mkfs + subprocess.run(['mkfs', '-t', 'vfat', '-n', 'SCREENSHOTS', '/tmp/usbdisk.img'], shell=False, check=True) + #subprocess.run(['mount', '-o', 'loop,ro', '-t', 'vfat', '/tmp/usbdisk.img', '/mnt'], shell=False, check=True) + # copy screenshot-tool.exe + # copy background.png + #subprocess.run(['umount', '/mnt'], shell=False, check=False) + + + subprocess.run(['modprobe', 'g_mass_storage', 'file=/tmp/usbdisk.img', 'stall=0', 'removable=1', 'iSerialNumber=1234567890'], shell=False, check=True) #tvservice -p # tvservice -e "DMT 82" # fbset -g 1920 1080 1920 1080 16 @@ -134,17 +145,20 @@ if __name__ == '__main__': print('file changed') subprocess.run(['killall', 'fim'], shell=False) subprocess.run(['umount', '/mnt'], shell=False, check=False) - subprocess.run(['mount', '-o', 'loop,ro,offset=1048576', '-t', 'vfat', '/usbdisk.img', '/mnt'], shell=False, check=True) + subprocess.run(['mount', '-o', 'loop,ro', '-t', 'vfat', '/tmp/usbdisk.img', '/mnt'], shell=False, check=True) - list_of_files = glob.glob('/mnt/*') - latest_file = max(list_of_files, key=os.path.getctime) - print (latest_file) + list_of_files = glob.glob('/mnt/*.png') + list_of_files.extend(glob.glob('/mnt/*.jpg')) + list_of_files.extend(glob.glob('/mnt/*.bmp')) - subprocess.run('fim -d /dev/fb0 -T 1 --autozoom --quiet '+paths[0], shell=True) + if list_of_files: + latest_file = max(list_of_files, key=os.path.getctime) + print(latest_file) + subprocess.run('fim -d /dev/fb0 -T 1 --autozoom --quiet "'+latest_file+'" &', shell=True) GPIO.output(23, GPIO.LOW) - watch_delay_call('/usbdisk.img', callback, 0.5, True, pyinotify.IN_MODIFY) + watch_delay_call('/tmp/usbdisk.img', callback, 0.5, True, pyinotify.IN_MODIFY) finally: GPIO.output(23, GPIO.LOW) diff --git a/windows-snapshot-tool/src/main.cpp b/windows-snapshot-tool/src/main.cpp index e6b3169..b669623 100644 --- a/windows-snapshot-tool/src/main.cpp +++ b/windows-snapshot-tool/src/main.cpp @@ -236,6 +236,21 @@ void getRaspiStorage() { // GetLogicalDrives() // for result // if result.GetDriveType() == DRIVE_REMOVABLE + + TCHAR szName[MAX_PATH]; + TCHAR szTemp[512]; + TCHAR szDrive[3] = TEXT(" :"); + szTemp[0] = '\0'; + if (GetLogicalDriveStrings(BUFSIZE-1, szTemp)) + { + BOOL bFound = FALSE; + for (TCHAR* p = szTemp; !bFound && *p; *p++;) { + *szDrive = *p; + if (QueryDosDevice(szDrive, szName, MAX_PATH)) + { + } + } + } }