Cool stuff for Raspberry Pi, Arduino and all electronics hobby projects
Notifications
Clear all

[Solved / Archived] Can't open SD Drive executing C++ from afterStartup.sh

3 Posts
2 Users
0 Likes
78 Views
(@larry_gorham)
Posts: 5
Active Member Customer
Topic starter
 
I'm running Wittypi4 on raspi4 bullseye with a program (fpsT.cpp) that writes to the SD drive. I allow the drive to mount 
automatically and address it with explicit name and path definition.
This works fine if I execute from bash with just:
exec /home/larry/raspberry-pi-opencv/twoCore/fpsT &
 
But when I reboot and execute from afterStartup.sh it errors:
Could not open file "/media/larry/pro128e/WMCC_MYLU_20250301_081842.avi" for writing.
 
Permissions for that drive are:
drwxr-xr-x 2 larry larry 131072 Mar  1 08:44 pro128e
 
 
************
Here's afterStartup.sh:
*********
 
#!/bin/bash
# file: afterStartup.sh
#
# This script will run after Raspberry Pi boot up and finish running the schedule script.
# If you want to run your commands after boot, you can place them here.
# Remarks: please use absolute path of the command, or it can not be found (by root user).
# Remarks: you may append '&' at the end of command to avoid blocking the main daemon.sh.
#
 
exec /home/larry/raspberry-pi-opencv/twoCore/fpsT &
 
*********
Here's my witttyPi.log
*************
 
[2025-03-01 08:17:54] Shutting down system because button is clicked or GPIO-4 is pulled down.
[2025-03-01 08:17:54] Halting all processes and then shutdown Raspberry Pi...
[xxxx-xx-xx xx:xx:xx] Witty Pi daemon (v4.21) is started.
[xxxx-xx-xx xx:xx:xx] System: Raspbian GNU/Linux 11 (bullseye), Kernel: Linux 6.1.21-v8+, Architecture: armhf
[xxxx-xx-xx xx:xx:xx] Running on Raspberry Pi 4 Model B Rev 1.5
[xxxx-xx-xx xx:xx:xx] RTC offset register has value 0x7a
[xxxx-xx-xx xx:xx:xx] Seems RTC has good time, write RTC time into system
[xxxx-xx-xx xx:xx:xx] Writing RTC time to system...
[2025-03-01 08:18:34] Done 🙂
[2025-03-01 08:18:34] Firmware ID: 0x26
[2025-03-01 08:18:34] Firmware Revison: 0x06
[2025-03-01 08:18:34] Current Vout=5.11V, Iout=0.79A
[2025-03-01 08:18:34] System starts up because the button is clicked.
[2025-03-01 08:18:39] Send out the SYS_UP signal via GPIO-17 pin.
[2025-03-01 08:18:39] Pending for incoming shutdown command...
[2025-03-01 08:18:39] Schedule next shutdown at: 2025-05-28 20:21:00
[2025-03-01 08:18:40] Schedule next startup at: 2025-05-28 20:23:00
 
(fpsT:984): GStreamer-CRITICAL **: 08:18:43.499: gst_element_make_from_uri: assertion 'gst_uri_is_valid (uri)' failed
[ WARN:0] global ../modules/videoio/src/cap_gstreamer.cpp (1824) handleMessage OpenCV | GStreamer warning: Embedded video
 playback halted; module filesink0 reported: Could not open file "/media/larry/pro128e/WMCC_MYLU_20250301_081842.avi" for writing.
[ WARN:0] global ../modules/videoio/src/cap_gstreamer.cpp (1824) handleMessage OpenCV | GStreamer warning: Embedded video playback
halted; module filesink0 reported: GStreamer error: state change failed and some element failed to post a proper error message with the reason for the failure.
[ WARN:0] global ../modules/videoio/src/cap_gstreamer.cpp (1649) open OpenCV | GStreamer warning: GStreamer: cannot put pipeline to play
 
Could not open the output video file for write
 
 
Posted : 01/03/2025 2:58 pm
(@admin)
Posts: 567
Member Admin
 

If your SD drive is connected to Raspberry Pi via USB port, there is chance that the SD drive has not been mounted yet, when afterStartup.sh ran the command.

You may change your program and let it do some checkings (maybe in a loop) and wait until the SD drive is indeed accessible.

 
Posted : 01/03/2025 3:11 pm
(@larry_gorham)
Posts: 5
Active Member Customer
Topic starter
 

It now appears the problem in not in Wittypi as I have found it elsewhere by changing permissions. 

 
Posted : 01/03/2025 5:05 pm
Join Waitlist We will inform you when the product arrives in stock. Please leave your valid email address below.