Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Only 1 video upload for YFUS #12

Open
mrxyzl opened this issue Jun 15, 2024 · 33 comments
Open

Only 1 video upload for YFUS #12

mrxyzl opened this issue Jun 15, 2024 · 33 comments

Comments

@mrxyzl
Copy link

mrxyzl commented Jun 15, 2024

Hi, i try to hack sucessfully the Yi Home Pro 2K with Yi hack all winner v2
I successfully follow your OneDrive upload integration but only first video is uploaded
The next_file in logs say:
Last uploaded file: /tmp/sd/record/2024Y06M15D07H/E718M31S29.mp4
Search next file to upload...
Search in directory: '2024Y06M15D07H'
No newer file found from directory last uploaded file located
No more newer direcotries found
No available newer file to upload for now

Output on SSH shows:

Start the auto-clean monitor...
2024-06-15 08:04:54 Success: check_drive_space
Start to check camera video and image files for uploading...
grep: unrecognized option: A
grep: unrecognized option: A
All files were uploaded, wait for a new recorded video or image file.

Meanwhile, files_index show :

/tmp/sd/record/2024Y06M15D07H/E718M31S29.mp4
/tmp/sd/record/2024Y06M15D07H/E723M37S23.mp4
/tmp/sd/record/2024Y06M15D07H/E724M00S60.mp4
/tmp/sd/record/2024Y06M15D07H/E731M25S35.mp4
/tmp/sd/record/2024Y06M15D07H/E732M00S60.mp4
/tmp/sd/record/2024Y06M15D07H/E733M00S60.mp4

Can you help with the reason why the upload stop?

Edit: it seem to me the current grep is missing -A option

@denven
Copy link
Owner

denven commented Jun 17, 2024

grep: unrecognized option: A

Can you check your busybox version or the grep command supported options?

image

@mrxyzl
Copy link
Author

mrxyzl commented Jun 17, 2024

I think the busy box version is 1.2 something as I don't have the laptop with me on my trip..
Can you tell me how to update busybox? @denven

@denven
Copy link
Owner

denven commented Jun 17, 2024

I think the busy box version is 1.2 something as I don't have the laptop with me on my trip.. Can you tell me how to update busybox? @denven

Probably you'd better re-hack and upgrade your camera firmware with all winner v2 to the supported latest version first, the busybox utils will upgrade as well. I am not sure if you are using this one, the latest version is v0.3.2: yi-hack-Allwinner-v2 0.3.2

@mrxyzl
Copy link
Author

mrxyzl commented Jun 17, 2024

Yes I think I use that one. I'll do a proper recheck on busybox version and grep command and report once I get home.

@mrxyzl
Copy link
Author

mrxyzl commented Jun 18, 2024

I think the busy box version is 1.2 something as I don't have the laptop with me on my trip.. Can you tell me how to update busybox? @denven

Probably you'd better re-hack and upgrade your camera firmware with all winner v2 to the supported latest version first, the busybox utils will upgrade as well. I am not sure if you are using this one, the latest version is v0.3.2: yi-hack-Allwinner-v2 0.3.2

Hello attach is the busy box version, and the all winer version. I think it's the latest hack
Screenshot_20240618_140237_JuiceSSH
SmartSelect_20240618_140316_Brave - Beta

@denven
Copy link
Owner

denven commented Jun 18, 2024

You can create a file in current path and test if your grep support s the -A option.
echo 1 >> test
echo 2 >> test
grep -A1 1 test
grep -A 1 1 test

@mrxyzl
Copy link
Author

mrxyzl commented Jun 18, 2024

You can create a file in current path and test if your grep support s the -A option. echo 1 >> test echo 2 >> test grep -A1 1 test grep -A 1 1 test

SmartSelect_20240618_151547_JuiceSSH

It seem to not support -A command

@denven
Copy link
Owner

denven commented Jun 18, 2024

I checked all winner v2 repo, its busybox has been updated to v1.36.1, but your busy box shows version. Can you confirm you've completely upgraded your firmware components without using existing data (cached)?

@mrxyzl
Copy link
Author

mrxyzl commented Jun 18, 2024

I checked all winner v2 repo, its busybox has been updated to v1.36.1, but your busy box shows version. Can you confirm you've completely upgraded your firmware components without using existing data (cached)?

That's really weird, because it's a brand new camera I just unbox. I followed the guide on all winner v2

@mrxyzl
Copy link
Author

mrxyzl commented Jun 18, 2024

I checked all winner v2 repo, its busybox has been updated to v1.36.1, but your busy box shows version. Can you confirm you've completely upgraded your firmware components without using existing data (cached)?

so theres no way to update busybox?

@denven
Copy link
Owner

denven commented Jun 18, 2024

I would say that, for most cases the -A option should be enabled and supported by default even you are on version 1.27.2. Can you run and check the output?
busybox grep -A1 test

@mrxyzl
Copy link
Author

mrxyzl commented Jun 18, 2024

I would say that, for most cases the -A option should be enabled and supported by default even you are on version 1.27.2. Can you run and check the output? busybox grep -A1 test

Here's the result
SmartSelect_20240619_064040_JuiceSSH

@denven
Copy link
Owner

denven commented Jun 19, 2024

Right now, from your output, I don't think your busybox provides the grep application, I checked the file .config and found it is not included.

You can check if the below has any output
/bin/busybox --list | grep -n grep

And check your grep version info:
grep --help

Probably your firmware provides the gnu grep application for you.
grep -V

Since your current grep doesn't provide -A option, there are two ways to solve this issue:

  1. you can raise an issue for the all-winner-v2 repository to include it in the newer versions and upgrade later
  2. download a static grep binary and make sure it is compatible with your camera

for the 2nd way:

  • check your cpu architecture: cat /proc/cpuinfo
  • download a grep binary file from linux-static-binaries (Note that I haven't verified the binaries), upload it to /tmp/sd/yi-hack/onedrive/bin path
  • enter the path and test the new grep program with -A option, check if it is executable and supports -A option or not.
    chmod 755 grep
    ./grep --help

if the downloaded grep provides -A option, you can clean up your yihack-onedrive-uploader and re-configure, to check if it is working then.

@mrxyzl
Copy link
Author

mrxyzl commented Jun 19, 2024

Right now, from your output, I don't think your busybox provides the grep application, I checked the file .config and found it is not included.

You can check if the below has any output /bin/busybox --list | grep -n grep

And check your grep version info: grep --help

Probably your firmware provides the gnu grep application for you. grep -V

Since your current grep doesn't provide -A option, there are two ways to solve this issue:

  1. you can raise an issue for the all-winner-v2 repository to include it in the newer versions and upgrade later
  2. download a static grep binary and make sure it is compatible with your camera

for the 2nd way:

  • check your cpu architecture: cat /proc/cpuinfo
  • download a grep binary file from linux-static-binaries (Note that I haven't verified the binaries), upload it to /tmp/sd/yi-hack/onedrive/bin path
  • enter the path and test the new grep program with -A option, check if it is executable and supports -A option or not.
    chmod 755 grep
    ./grep --help

if the downloaded grep provides -A option, you can clean up your yihack-onedrive-uploader and re-configure, to check if it is working then.

hello, thank you for your help in the end i copy the grep from linux static libraries link above to yi-hack/bin in order for the code to work
But a new error pop up, regarding upload large file

2024-06-19 08:26:48 Start to upload /tmp/sd/record/2024Y06M15D07H/E724M00S60.mp4
Target OneDrive path: yihack_videos/202406/20240615/2024Y06M15D07H, file size: 6.31MB
2024-06-19 08:26:51 Success: create_upload_session /tmp/sd/record/2024Y06M15D07H/E724M00S60.mp4
upload_large_file_by_chunks /tmp/sd/record/2024Y06M15D07H/E724M00S60.mp4
2024-06-19 08:26:51 upload chunk: 0, length: 3932160, bytes: 0-3932159
./init.sh: line 1: Illegal number: -3

Edit: it seem the user from this issue also encountered this error : #11 (comment)

Edit 2: i think something is wrong with the code regarding chunk size

@mrxyzl
Copy link
Author

mrxyzl commented Jun 19, 2024

hello, after copying the api.sh you provide from #11 (comment), here is the result:
Success: create_upload_session /tmp/sd/record/2024Y06M15D07H/E732M00S60.mp4
upload_large_file_by_chunks /tmp/sd/record/2024Y06M15D07H/E732M00S60.mp4
2024-06-19 09:07:49 upload chunk: 0, length: 3932160, bytes: 0-3932159
write temp file for upload
get upload response: {"expirationDateTime":"2024-06-19T09:22:58.809Z","nextExpectedRanges":["3932160-6746131"]}202
./init.sh: line 1: Illegal number: -3
Edit: it seem the code copy the chunk to tmp sucessful, upload sucessful but failed to initiate the next chunk

Edit 2: i seem to fix the issue, by removing the spare ":" at line 219 of api.sh. I dont know if this is intentional spare ":" for coding or just mistyped

Edit 3: it seem the script stop when i exit ssh, also, didnt run on reboot terminal file in ./log showed:
Start to check camera video and image files for uploading...
2024-06-19 12:49:34 Success: check_drive_space
grep: unrecognized option: A
grep: unrecognized option: A
All files were uploaded, wait for a new recorded video or image file.
grep: unrecognized option: A
grep: unrecognized option: A

But execute the init.sh file manually give no error for grep unrecognize option A. Checking grep file already -rwxr-xr-x .

@denven
Copy link
Owner

denven commented Jun 19, 2024

  1. Can you replace the latest code file's line resp_json=${1:: -3} to the below line and test:
resp_json=${1:0:${#1}-3}
  1. Did you put your downloaded file in this path /tmp/sd/yi-hack/onedrive/bin/grep? If yes and it doesn't work, can you add the below line in file init.sh to reboot and test again?
export PATH=$PATH:/tmp/sd/yi-hack/onedrive/bin
# add the below line
alias grep='/tmp/sd/yi-hack/onedrive/bin/grep'

@denven
Copy link
Owner

denven commented Jun 19, 2024

hello, after copying the api.sh you provide from #11 (comment), here is the result:

Success: create_upload_session /tmp/sd/record/2024Y06M15D07H/E732M00S60.mp4

upload_large_file_by_chunks /tmp/sd/record/2024Y06M15D07H/E732M00S60.mp4

2024-06-19 09:07:49 upload chunk: 0, length: 3932160, bytes: 0-3932159

write temp file for upload

get upload response: {"expirationDateTime":"2024-06-19T09:22:58.809Z","nextExpectedRanges":["3932160-6746131"]}202

./init.sh: line 1: Illegal number: -3

Edit: it seem the code copy the chunk to tmp sucessful, upload sucessful but failed to initiate the next chunk

Edit 2: i seem to fix the issue, by removing the spare ":" at line 219 of api.sh. I dont know if this is intentional spare ":" for coding or just mistyped

Edit 3: it seem the script stop when i exit ssh, also, didnt run on reboot terminal file in ./log showed:

Start to check camera video and image files for uploading...

2024-06-19 12:49:34 Success: check_drive_space

grep: unrecognized option: A

grep: unrecognized option: A

All files were uploaded, wait for a new recorded video or image file.

grep: unrecognized option: A

grep: unrecognized option: A

But execute the init.sh file manually give no error for grep unrecognize option A. Checking grep file already -rwxr-xr-x .

The link file is a debug source file for locating issues. Good thing is you tried and found something.

The extra : is intentional but unfortunately not compatible with your guys' devices.

@mrxyzl
Copy link
Author

mrxyzl commented Jun 21, 2024

  1. Can you replace the latest code file's line resp_json=${1:: -3} to the below line and test:
resp_json=${1:0:${#1}-3}
  1. Did you put your downloaded file in this path /tmp/sd/yi-hack/onedrive/bin/grep? If yes and it doesn't work, can you add the below line in file init.sh to reboot and test again?
export PATH=$PATH:/tmp/sd/yi-hack/onedrive/bin
# add the below line
alias grep='/tmp/sd/yi-hack/onedrive/bin/grep'
  1. the same error persist

image
still same error

@denven
Copy link
Owner

denven commented Jun 21, 2024

It seems you are close to success, what's is your onedrive path?
can you put the output of your grep:
/tmp/sd/yi-hack/onedrive/bin/grep --help

@mrxyzl
Copy link
Author

mrxyzl commented Jun 21, 2024

It seems you are close to success, what's is your onedrive path? can you put the output of your grep: /tmp/sd/yi-hack/onedrive/bin/grep --help

Screenshot_20240621_173020_JuiceSSH

Seem like grep work. But error still show up

@denven
Copy link
Owner

denven commented Jun 21, 2024

Is the error reported from a reboot?

@mrxyzl
Copy link
Author

mrxyzl commented Jun 21, 2024

Is the error reported from a reboot?

Yes. If I reboot, init.sh terminal log show the mentioned error. If I manually run init.ah no error occur

Anyway as a reference from this link https://stackoverflow.com/questions/7451423/how-to-show-only-next-line-after-the-matched-one

Do you think you can change the Grep -A1 to awk?

@denven
Copy link
Owner

denven commented Jun 21, 2024

Is the error reported from a reboot?

Yes. If I reboot, init.sh terminal log show the mentioned error. If I manually run init.ah no error occur

Anyway as a reference from this link https://stackoverflow.com/questions/7451423/how-to-show-only-next-line-after-the-matched-one

Do you think you can change the Grep -A1 to awk?

Maybe I can do that later.

How about put alias grep='/tmp/sd/yi-hack/onedrive/bin/grep' on top of upload.sh file and test?
Or another ugly solution is you find and replace grep -A to /tmp/sd/yi-hack/onedrive/bin/grep -A
Let me know if this will fix it.

I will find a time to use an alternative way to fix the grep compatibility issue. Just try the temporary way first.

@mrxyzl
Copy link
Author

mrxyzl commented Jun 21, 2024

grep='/tmp/sd/yi-hack/onedrive/bin/grep' on top of upload.sh file

This works ! thanks a lot for your help

@denven
Copy link
Owner

denven commented Jun 21, 2024

@mrxyzl Please share your camera Model and firmware version, I will update it to the Readme file for people to check.

@mrxyzl
Copy link
Author

mrxyzl commented Jun 21, 2024

@mrxyzl Please share your camera Model and firmware version, I will update it to the Readme file for people to check.

Model: Yi Home Pro 2K
Model Suffix: y623
Base Firmware: 12.0.51.08_202403081746
Allwinner v2 firmware: 0.3.2

@denven
Copy link
Owner

denven commented Jun 22, 2024

Is the error reported from a reboot?

Yes. If I reboot, init.sh terminal log show the mentioned error. If I manually run init.ah no error occur

Anyway as a reference from this link https://stackoverflow.com/questions/7451423/how-to-show-only-next-line-after-the-matched-one

Do you think you can change the Grep -A1 to awk?

You can test the latest code I submitted today (without using an extra downloaded grep)

@mrxyzl
Copy link
Author

mrxyzl commented Jun 25, 2024

Is the error reported from a reboot?

Yes. If I reboot, init.sh terminal log show the mentioned error. If I manually run init.ah no error occur
Anyway as a reference from this link https://stackoverflow.com/questions/7451423/how-to-show-only-next-line-after-the-matched-one
Do you think you can change the Grep -A1 to awk?

You can test the latest code I submitted today (without using an extra downloaded grep)

The code for api.sh still failed
SmartSelect_20240625_191547_JuiceSSH

@denven
Copy link
Owner

denven commented Jun 25, 2024

that is weird since this error has been fixed and it's the same code as the previous discussed here.

is it reported from the reboot execution or your manual?check the other ticket you created. have you tried the code from the new branch,it contains all the latest changes.

@mrxyzl
Copy link
Author

mrxyzl commented Jun 25, 2024

that is weird since this error has been fixed and it's the same code as the previous discussed here.

is it reported from the reboot execution or your manual?check the other ticket you created. have you tried the code from the new branch,it contains all the latest changes.

I mean the previous code also doesn't work as I comment above.
Screenshot_20240625_233155_Brave - Beta

@denven
Copy link
Owner

denven commented Jun 25, 2024

OK. I ll give you some new code to test, both old and current code are working on my camera.

@denven
Copy link
Owner

denven commented Jun 26, 2024

Please replace the current code line resp_json=${1:0:${#1}-3} in api.sh to the below lines. @mrxyzl

		resp_len=$((${#1}-3))
                resp_json=${1:0:resp_len}
		resp_len=$((${#1}-3))
                resp_json=${1:0:${resp_len}}
                resp_len=$((${#1}-3))
                resp_json=$(echo "$1" | cut -c1-${resp_len})
                length=${#1}
                resp_len=$(($length-3))
                resp_json=${1:0:${resp_len}}
                length=${#1}
                resp_len=$(($length-3))
		resp_json=$(echo "$1" | cut -c1-${resp_len})

I provide several different alternative code lines above, however, I don't know which code snippet will work on your device. Please test them one by one and let me know the result. Hope one or more of them can work.

@mrxyzl
Copy link
Author

mrxyzl commented Jun 27, 2024

 length=${#1}
                resp_len=$(($length-3))
                resp_json=${1:0:${resp_len}}

Hello, im happy to announce that this:
length=${#1}
resp_len=$(($length-3))
resp_json=${1:0:${resp_len}}

works, i didnt test the others tho

@denven denven self-assigned this Jun 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants