milesburton / teslacam

Experiment to use the Tesla (S/3/X) V9 Dashcam with the Raspberry Pi Zero W for automatic backup
Apache License 2.0
86 stars 19 forks source link

Tesla not seeing USB drive #17

Open natrlhy opened 5 years ago

natrlhy commented 5 years ago

Thanks for this code. Hoping to get it fully working. Here are the steps I've taken to go through the install. I've done everything thus far as root:

`Insert your SDHC card into your PC. Launch Etcher. Point it to the location of the Raspbian .zip file and flash the card. When that is completed, I ejected the card and reinserted it. Connect the Micro USB to USB cable to the USB labeled port on the Pi Zero W

Use an SSH client to SSH to the Pi Zero W

hostname: rasbperrypi.local username: pi password: raspberry

Do everything as root:

sudo su - cd /boot vi wpa_supplicant.conf

Paste this for the WiFi Setup:

country=us update_config=1 ctrl_interface=/var/run/wpa_supplicant

network={ scan_ssid=1 ssid="yourwifi" psk="yourpassword" }

reboot

SSH back into the Pi to install DaemonTools:

mkdir -p /package chmod 1755 /package cd /package

wget http://cr.yp.to/daemontools/daemontools-0.76.tar.gz tar -xpf daemontools-0.76.tar.gz rm -f daemontools-0.76.tar.gz cd admin/daemontools-0.76

ed ./src/conf-cc 1s/$/ -include errno.h/ wq package/install

apt-get install csh csh -cf '/command/svscanboot &' sed -i "1 a\csh -cf '/command/svscanboot &'" /etc/rc.local chmod +x /etc/rc.local

Install Node.js: mkdir -p /opt/node; cd /opt/node wget https://nodejs.org/dist/v10.16.0/node-v10.16.0-linux-armv6l.tar.xz tar -xvf node-v10.16.0-linux-armv6l.tar.xz chown -R root:root node-v10.16.0-linux-armv6l ln -s /opt/node/node-v10.16.0-linux-armv6l/bin/* /usr/bin/

apt-get install git git config --global user.name "Me" git config --global user.email myemail@user.com cd /home/pi git clone https://github.com/milesburton/teslacam mkdir -p /etc/service;cd /etc/service;ln -s /home/pi/teslacam/services/* . cd /home/pi/teslacam;npm install cd /home/pi/teslacam/src/remote;npm install`

When I plug it into the USB port on the PI and the front USB on the Tesla M3, I never see the icon on the touchscreen that signifies the USB drive is seen.

I haven't done any DropBox integration yet as ultimately I want to upload to my Synology NAS

milesburton commented 5 years ago

Does the drive mount when you plug it in to your PC? That's the first ACID test to make sure it appears

natrlhy commented 5 years ago

When I first flashed it I saw /boot. Now I don't see that in Explorer.

SSH:

pi@teslacam:~ $ df -h Filesystem Size Used Avail Use% Mounted on /dev/root 59G 1.6G 55G 3% / devtmpfs 213M 0 213M 0% /dev tmpfs 217M 0 217M 0% /dev/shm tmpfs 217M 3.1M 214M 2% /run tmpfs 5.0M 4.0K 5.0M 1% /run/lock tmpfs 217M 0 217M 0% /sys/fs/cgroup /dev/mmcblk0p1 253M 40M 214M 16% /boot tmpfs 44M 0 44M 0% /run/user/1000

milesburton commented 5 years ago

Take a look at the logs tail -f /home/pi/teslacam/services/dashcam-monitor/log/main/current. See if it's doing anything strange.

It's probably a permission issue, or maybe corrupt disk images.

On Thu, Jul 18, 2019 at 2:41 PM natrlhy notifications@github.com wrote:

When I first flashed it I saw /boot. Now I don't see that in Explorer.

SSH:

pi@teslacam:~ $ df -h Filesystem Size Used Avail Use% Mounted on /dev/root 59G 1.6G 55G 3% / devtmpfs 213M 0 213M 0% /dev tmpfs 217M 0 217M 0% /dev/shm tmpfs 217M 3.1M 214M 2% /run tmpfs 5.0M 4.0K 5.0M 1% /run/lock tmpfs 217M 0 217M 0% /sys/fs/cgroup /dev/mmcblk0p1 253M 40M 214M 16% /boot tmpfs 44M 0 44M 0% /run/user/1000

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/milesburton/teslacam/issues/17?email_source=notifications&email_token=AAJGHMYUGNKE42ZUIREODS3QABXIBA5CNFSM4IEWOCT2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD2IQKXI#issuecomment-512820573, or mute the thread https://github.com/notifications/unsubscribe-auth/AAJGHM6U6B6EUSZTIQF3LALQABXIBANCNFSM4IEWOCTQ .

natrlhy commented 5 years ago

Not seeing any logs in that dir...

milesburton commented 5 years ago

My bet is it's not running. if you go to /home/pi and run npm start what does it say/do

On Thu, Jul 18, 2019 at 3:32 PM natrlhy notifications@github.com wrote:

Not seeing any logs in that dir...

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/milesburton/teslacam/issues/17?email_source=notifications&email_token=AAJGHM2OBCRPCUPSY65QQMDQAB5GPA5CNFSM4IEWOCT2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD2IVNNI#issuecomment-512841397, or mute the thread https://github.com/notifications/unsubscribe-auth/AAJGHM3Y7NGPQVWOPOZ7INDQAB5GPANCNFSM4IEWOCTQ .

natrlhy commented 5 years ago

root@teslacam:/home/pi# npm start npm ERR! path /home/pi/package.json npm ERR! code ENOENT npm ERR! errno -2 npm ERR! syscall open npm ERR! enoent ENOENT: no such file or directory, open '/home/pi/package.json' npm ERR! enoent This is related to npm not being able to find a file. npm ERR! enoent

npm ERR! A complete log of this run can be found in: npm ERR! /root/.npm/_logs/2019-07-18T14_43_17_323Z-debug.log

root@teslacam:/home/pi# more /root/.npm/_logs/2019-07-18T14_43_17_323Z-debug.log 0 info it worked if it ends with ok 1 verbose cli [ '/opt/node/node-v10.16.0-linux-armv6l/bin/node', 1 verbose cli '/usr/bin/npm', 1 verbose cli 'start' ] 2 info using npm@6.9.0 3 info using node@v10.16.0 4 verbose stack Error: ENOENT: no such file or directory, open '/home/pi/package.json' 5 verbose cwd /home/pi 6 verbose Linux 4.19.57+ 7 verbose argv "/opt/node/node-v10.16.0-linux-armv6l/bin/node" "/usr/bin/npm" "start" 8 verbose node v10.16.0 9 verbose npm v6.9.0 10 error path /home/pi/package.json 11 error code ENOENT 12 error errno -2 13 error syscall open 14 error enoent ENOENT: no such file or directory, open '/home/pi/package.json' 15 error enoent This is related to npm not being able to find a file. 16 verbose exit [ -2, true ]

milesburton commented 5 years ago

Sorry, run it from the teslacam directory

On Thu, Jul 18, 2019 at 3:43 PM natrlhy notifications@github.com wrote:

root@teslacam:/home/pi# npm start npm ERR! path /home/pi/package.json npm ERR! code ENOENT npm ERR! errno -2 npm ERR! syscall open npm ERR! enoent ENOENT: no such file or directory, open '/home/pi/package.json' npm ERR! enoent This is related to npm not being able to find a file. npm ERR! enoent

npm ERR! A complete log of this run can be found in: npm ERR! /root/.npm/_logs/2019-07-18T14_43_17_323Z-debug.log

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/milesburton/teslacam/issues/17?email_source=notifications&email_token=AAJGHM4VKGWLXYLXKB2OFQDQAB6RRA5CNFSM4IEWOCT2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD2IWSBQ#issuecomment-512846086, or mute the thread https://github.com/notifications/unsubscribe-auth/AAJGHM4VNVGRRQXZMFEMSV3QAB6RRANCNFSM4IEWOCTQ .

natrlhy commented 5 years ago

Ok...

root@teslacam:/home/pi/teslacam# npm start

teslacam@1.0.0 start /home/pi/teslacam node src/services start

Running [sudo svc -u /home/pi/teslacam/./services/dashcam-monitor] svc: warning: unable to control /home/pi/teslacam/./services/dashcam-monitor: file does not exist Running [sudo svc -u /home/pi/teslacam/./services/dropbox-upload] svc: warning: unable to control /home/pi/teslacam/./services/dropbox-upload: file does not exist Running [sudo svc -u /home/pi/teslacam/./services/rotate-video] svc: warning: unable to control /home/pi/teslacam/./services/rotate-video: file does not exist (node:648) ExperimentalWarning: The fs.promises API is experimental

milesburton commented 5 years ago

Looks like it's not installed correctly. Can you run an "ls -lart" within the teslacam folder and again in the services folder? You may need to clone the repo again

natrlhy commented 5 years ago

root@teslacam:/home/pi/teslacam# pwd /home/pi/teslacam root@teslacam:/home/pi/teslacam# ls -lart total 208 drwxr-xr-x 4 pi pi 4096 Jul 17 16:58 .. -rw-r--r-- 1 root root 222 Jul 17 16:58 .eslintrc.json -rw-r--r-- 1 root root 13 Jul 17 16:58 .eslintignore -rw-r--r-- 1 root root 8307 Jul 17 16:58 README.md -rw-r--r-- 1 root root 703 Jul 17 16:58 package.json -rw-r--r-- 1 root root 11357 Jul 17 16:58 LICENSE drwxr-xr-x 2 root root 4096 Jul 17 16:58 installation drwxr-xr-x 2 root root 4096 Jul 17 16:58 images -rw-r--r-- 1 root root 1324 Jul 17 16:58 .gitignore drwxr-xr-x 2 root root 4096 Jul 17 16:58 etc drwxr-xr-x 5 root root 4096 Jul 17 16:58 services drwxr-xr-x 3 root root 4096 Jul 17 16:58 src -rw-r--r-- 1 root root 57247 Jul 17 16:58 yarn.lock drwxr-xr-x 2 root root 4096 Jul 17 16:58 video drwxr-xr-x 2 root root 4096 Jul 17 16:58 supervise drwxr-xr-x 8 root root 4096 Jul 17 16:58 .git lrwxrwxrwx 1 root root 39 Jul 17 16:59 rotate-video -> /home/pi/teslacam/services/rotate-video lrwxrwxrwx 1 root root 41 Jul 17 16:59 dropbox-upload -> /home/pi/teslacam/services/dropbox-upload lrwxrwxrwx 1 root root 42 Jul 17 16:59 dashcam-monitor -> /home/pi/teslacam/services/dashcam-monitor drwxr-xr-x 194 root root 4096 Jul 17 17:17 node_modules -rw-r--r-- 1 root root 66747 Jul 17 17:17 package-lock.json drwxr-xr-x 11 root root 4096 Jul 17 17:17 .

root@teslacam:/home/pi/teslacam/services# ls -latrh total 20K drwxr-xr-x 4 root root 4.0K Jul 17 16:58 rotate-video drwxr-xr-x 4 root root 4.0K Jul 17 16:58 dropbox-upload drwxr-xr-x 4 root root 4.0K Jul 17 16:58 dashcam-monitor drwxr-xr-x 5 root root 4.0K Jul 17 16:58 . drwxr-xr-x 11 root root 4.0K Jul 17 17:17 ..

milesburton commented 5 years ago

This looks wrong:

rwxrwxrwx 1 root root 39 Jul 17 16:59 rotate-video -> /home/pi/teslacam/services/rotate-video lrwxrwxrwx 1 root root 41 Jul 17 16:59 dropbox-upload -> /home/pi/teslacam/services/dropbox-upload lrwxrwxrwx 1 root root 42 Jul 17 16:59 dashcam-monitor -> /home/pi/teslacam/services/dashcam-monitor

I'd abort this install, and delete the teslacam folder and clone down the repo again. Your existing symlinks should still be valid

On Thu, Jul 18, 2019 at 3:49 PM natrlhy notifications@github.com wrote:

root@teslacam:/home/pi/teslacam# pwd /home/pi/teslacam root@teslacam:/home/pi/teslacam# ls -lart total 208 drwxr-xr-x 4 pi pi 4096 Jul 17 16:58 .. -rw-r--r-- 1 root root 222 Jul 17 16:58 .eslintrc.json -rw-r--r-- 1 root root 13 Jul 17 16:58 .eslintignore -rw-r--r-- 1 root root 8307 Jul 17 16:58 README.md -rw-r--r-- 1 root root 703 Jul 17 16:58 package.json -rw-r--r-- 1 root root 11357 Jul 17 16:58 LICENSE drwxr-xr-x 2 root root 4096 Jul 17 16:58 installation drwxr-xr-x 2 root root 4096 Jul 17 16:58 images -rw-r--r-- 1 root root 1324 Jul 17 16:58 .gitignore drwxr-xr-x 2 root root 4096 Jul 17 16:58 etc drwxr-xr-x 5 root root 4096 Jul 17 16:58 services drwxr-xr-x 3 root root 4096 Jul 17 16:58 src -rw-r--r-- 1 root root 57247 Jul 17 16:58 yarn.lock drwxr-xr-x 2 root root 4096 Jul 17 16:58 video drwxr-xr-x 2 root root 4096 Jul 17 16:58 supervise drwxr-xr-x 8 root root 4096 Jul 17 16:58 .git lrwxrwxrwx 1 root root 39 Jul 17 16:59 rotate-video -> /home/pi/teslacam/services/rotate-video lrwxrwxrwx 1 root root 41 Jul 17 16:59 dropbox-upload -> /home/pi/teslacam/services/dropbox-upload lrwxrwxrwx 1 root root 42 Jul 17 16:59 dashcam-monitor -> /home/pi/teslacam/services/dashcam-monitor drwxr-xr-x 194 root root 4096 Jul 17 17:17 node_modules -rw-r--r-- 1 root root 66747 Jul 17 17:17 package-lock.json drwxr-xr-x 11 root root 4096 Jul 17 17:17 .

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/milesburton/teslacam/issues/17?email_source=notifications&email_token=AAJGHM3FAOQKVKCRQKGVPHLQAB7IXA5CNFSM4IEWOCT2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD2IXGZY#issuecomment-512848743, or mute the thread https://github.com/notifications/unsubscribe-auth/AAJGHM6OBUPA76KQ54XNFCLQAB7IXANCNFSM4IEWOCTQ .

natrlhy commented 5 years ago

Ok, and it's not an issue that it's all running as root? Should I reflash?

My steps for cloning the repo is valid?

cd /home/pi git clone https://github.com/milesburton/teslacam

milesburton commented 5 years ago

During installation you need to install daemon tools etc - this requires root.

The teslacam code itself doesn't require root, but you will need to install the ~/teslacam/installation/sudoers file to white list certain commands such as enabling host usb mode on the pi.

For the sake of getting it running, I'd just get it running as root - when it works, lock it down (all commands run as sudo, so you can restrict the code from doing anything unexpected)

On Thu, Jul 18, 2019 at 3:54 PM natrlhy notifications@github.com wrote:

Ok, and it's not an issue that it's all running as root?

My steps for cloning the repo is valid?

cd /home/pi git clone https://github.com/milesburton/teslacam

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/milesburton/teslacam/issues/17?email_source=notifications&email_token=AAJGHM3ACBYHO4SLQBGRURTQAB7ZLA5CNFSM4IEWOCT2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD2IXWAI#issuecomment-512850689, or mute the thread https://github.com/notifications/unsubscribe-auth/AAJGHM5GKVFFMPKX4YKL4RLQAB7ZLANCNFSM4IEWOCTQ .

natrlhy commented 5 years ago

Ok... I know one of your desires was to get an updated install guide setup. I'd be happy to help flush things out during my initial testing of this. I didn't see anything about the ~/teslacam/installation/sudoers installation so I'll add that to my notes thus far

milesburton commented 5 years ago

That would be great. It's still a work in progress so as improvements are made I've neglected to update the docs by mistake.

Just FYI there are two additional branches. One which uses Docker to avoid the pain of installation, and another which uses EXT4 instead of FAT32. You may want to check those out once you have master running.

On Thu, Jul 18, 2019 at 4:17 PM natrlhy notifications@github.com wrote:

Ok... I know one of your desires was to get an updated install guide setup. I'd be happy to help flush things out during my initial testing of this. I didn't see anything about the ~/teslacam/installation/sudoers installation so I'll add that to my notes thus far

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/milesburton/teslacam/issues/17?email_source=notifications&email_token=AAJGHM3C3WOEF6G4KURMJBLQACCSDA5CNFSM4IEWOCT2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD2I2IBY#issuecomment-512861191, or mute the thread https://github.com/notifications/unsubscribe-auth/AAJGHMZYUXPJEGCTAV6W74DQACCSDANCNFSM4IEWOCTQ .

natrlhy commented 5 years ago

I wonder if one of my issues is using this:

2019-07-10-raspbian-buster-lite.zip

milesburton commented 5 years ago

Possibly but I doubt it.

On Thu, Jul 18, 2019 at 4:36 PM natrlhy notifications@github.com wrote:

I wonder if one of my issues is using this:

2019-07-10-raspbian-buster-lite.zip

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/milesburton/teslacam/issues/17?email_source=notifications&email_token=AAJGHMYTAVTPLRW3UDEOARDQACEY5A5CNFSM4IEWOCT2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD2I4HNI#issuecomment-512869301, or mute the thread https://github.com/notifications/unsubscribe-auth/AAJGHM76SA4IJD5PXO5477TQACEY5ANCNFSM4IEWOCTQ .

natrlhy commented 5 years ago

When doing the 1st npm install I get this. Is this of concern?

npm notice created a lockfile as package-lock.json. You should commit this file. npm WARN react-virtualized@9.21.1 requires a peer of react@^15.3.0 || ^16.0.0-alpha but none is installed. You must install peer dependencies yourself. npm WARN react-virtualized@9.21.1 requires a peer of react-dom@^15.3.0 || ^16.0.0-alpha but none is installed. You must install peer dependencies yourself. npm WARN teslacam@1.0.0 No repository field.

added 216 packages from 153 contributors and audited 620 packages in 191.416s found 0 vulnerabilities

natrlhy commented 5 years ago

Re-did everything. Services don't seem to ever start. I tried entering things into the /etc/rc.local but no go. Not sure where I'm going wrong. These are my steps:

Steps to get a Raspberry Pi Zero W setup for TeslaCam on Windows

Hardware:

https://www.amazon.com/gp/product/B013G4EAEI/ https://www.amazon.com/gp/product/B0748MPQT4/ 64GB SDHC Card (already had one I got from Costco)

Download and the latest "lite" Raspbian: https://www.raspberrypi.org/downloads/raspbian/ Download and install Etcher: https://www.balena.io/etcher/

Insert your SDHC card into your PC. Launch Etcher. Point it to the location of the Raspbian .zip file and flash the card. When that is completed, re-insert the SDHC card into your PC

===== Enable OTG on the Pi Zero W =====

Follow this great guide to setup OTG on the Pi Zero W: https://blog.gbaman.info/?p=791

Browse to the /boot partition on the SDHC card on your PC Add this to the bottom of the config.txt file: dtoverlay=dwc2 Save the file

Add this to the cmdline.txt file. Place it right after rootwait with a space at the end of it. Be careful as syntax is critical: modules-load=dwc2,g_ether

Save the file

===== Configure WiFi =====

Follow this guide for WiFi setup: https://www.raspberrypi-spy.co.uk/2017/04/manually-setting-up-pi-wifi-using-wpa_supplicant-conf/

Create a file called wpa_supplicant.conf Paste this for the WiFi Setup:

country=us update_config=1 ctrl_interface=/var/run/wpa_supplicant

network={ scan_ssid=1 ssid="yourwifi" psk="yourpassword" }

Save the file

==== Boot the Pi Zero W for the first time =====

Eject the SDHC card from your PC Place the SDHC card into the proper slot on the Pi Zero W Connect your USB Micro to USB cable to the USB port on the Pi Zero W Connect the this to your PC and wait for the Pi to boot (about 2 minutes. The green light on the Pi will be solid green)

Use an SSH client to SSH to the Pi Zero W

hostname: rasbperrypi.local username: pi password: raspberry

===== Installing daemontools ===== https://isotope11.com/blog/manage-your-services-with-daemontools

SSH back into the Pi to install daemontools:

sudo su - mkdir -p /package chmod 1755 /package cd /package

wget http://cr.yp.to/daemontools/daemontools-0.76.tar.gz tar -xpf daemontools-0.76.tar.gz rm -f daemontools-0.76.tar.gz cd admin/daemontools-0.76

ed ./src/conf-cc 1s/$/ -include errno.h/ wq

package/install

apt-get install csh csh -cf '/command/svscanboot &' sed -i "1 a\csh -cf '/command/svscanboot &'" /etc/rc.local chmod +x /etc/rc.local reboot

===== Install Node.js =====

mkdir -p /opt/node; cd /opt/node wget https://nodejs.org/dist/v10.16.0/node-v10.16.0-linux-armv6l.tar.xz tar -xvf node-v10.16.0-linux-armv6l.tar.xz chown -R root:root node-v10.16.0-linux-armv6l ln -s /opt/node/node-v10.16.0-linux-armv6l/bin/* /usr/bin/

===== Install GIT =====

apt-get install git

As the pi User:

cd /home/pi git clone https://github.com/milesburton/teslacam

===== Final Steps =====

As root:

mkdir -p /etc/service;cd /etc/service;ln -s /home/pi/teslacam/services/* . vi /etc/sudoers r /home/pi/teslacam/installation/sudoers reboot

As the pi User:

cd /home/pi/teslacam;npm install cd /home/pi/teslacam/src/remote;npm install

sudo poweroff

Plug the Pi Zero W into the Tesla media USB ports (the front ports). Make sure you use the data port on the Pi, google if you are unsure. Reboot, once the automatic configuration completes (circa 1 minute) the car should detect the Pi as a USB drive.

milesburton commented 5 years ago

OK let's try something simple.

Let's start the dashcam-monitor.js directly. To do that, cd /home/pi/teslacam/src; node dashcam-monitor.js // whilst plugged in to your computer.

The services could be something irrelevant. Now you've checked out the code again, what did npm run start do for you from /home/pi/teslacam?

On Thu, Jul 18, 2019 at 6:47 PM natrlhy notifications@github.com wrote:

Re-did everything. Services don't seem to ever start. I tried entering things into the /etc/rc.local but no go. Not sure where I'm going wrong. These are my steps:

Steps to get a Raspberry Pi Zero W setup for TeslaCam on Windows

Hardware:

https://www.amazon.com/gp/product/B013G4EAEI/ https://www.amazon.com/gp/product/B0748MPQT4/ 64GB SDHC Card (already had one I got from Costco)

Download and the latest "lite" Raspbian: https://www.raspberrypi.org/downloads/raspbian/ Download and install Etcher: https://www.balena.io/etcher/

Insert your SDHC card into your PC. Launch Etcher. Point it to the location of the Raspbian .zip file and flash the card. When that is completed, re-insert the SDHC card into your PC

===== Enable OTG on the Pi Zero W =====

Follow this great guide to setup OTG on the Pi Zero W: https://blog.gbaman.info/?p=791

Browse to the /boot partition on the SDHC card on your PC Add this to the bottom of the config.txt file: dtoverlay=dwc2 Save the file

Add this to the cmdline.txt file. Place it right after rootwait with a space at the end of it. Be careful as syntax is critical: modules-load=dwc2,g_ether

Save the file

===== Configure WiFi =====

Follow this guide for WiFi setup: https://www.raspberrypi-spy.co.uk/2017/04/manually-setting-up-pi-wifi-using-wpa_supplicant-conf/

Create a file called wpa_supplicant.conf Paste this for the WiFi Setup:

country=us update_config=1 ctrl_interface=/var/run/wpa_supplicant

network={ scan_ssid=1 ssid="yourwifi" psk="yourpassword" }

Save the file

==== Boot the Pi Zero W for the first time =====

Eject the SDHC card from your PC Place the SDHC card into the proper slot on the Pi Zero W Connect your USB Micro to USB cable to the USB port on the Pi Zero W Connect the this to your PC and wait for the Pi to boot (about 2 minutes. The green light on the Pi will be solid green)

Use an SSH client to SSH to the Pi Zero W

hostname: rasbperrypi.local username: pi password: raspberry

===== Installing daemontools ===== https://isotope11.com/blog/manage-your-services-with-daemontools

SSH back into the Pi to install daemontools:

sudo su - mkdir -p /package chmod 1755 /package cd /package

wget http://cr.yp.to/daemontools/daemontools-0.76.tar.gz tar -xpf daemontools-0.76.tar.gz rm -f daemontools-0.76.tar.gz cd admin/daemontools-0.76

ed ./src/conf-cc 1s/$/ -include errno.h/ wq

package/install

apt-get install csh csh -cf '/command/svscanboot &' sed -i "1 a\csh -cf '/command/svscanboot &'" /etc/rc.local chmod +x /etc/rc.local reboot

===== Install Node.js =====

mkdir -p /opt/node; cd /opt/node wget https://nodejs.org/dist/v10.16.0/node-v10.16.0-linux-armv6l.tar.xz tar -xvf node-v10.16.0-linux-armv6l.tar.xz chown -R root:root node-v10.16.0-linux-armv6l ln -s /opt/node/node-v10.16.0-linux-armv6l/bin/* /usr/bin/

===== Install GIT =====

apt-get install git

As the pi User:

cd /home/pi git clone https://github.com/milesburton/teslacam

===== Final Steps =====

As root:

mkdir -p /etc/service;cd /etc/service;ln -s /home/pi/teslacam/services/* . vi /etc/sudoers r /home/pi/teslacam/installation/sudoers reboot

As the pi User:

cd /home/pi/teslacam;npm install cd /home/pi/teslacam/src/remote;npm install

sudo poweroff

Plug the Pi Zero W into the Tesla media USB ports (the front ports). Make sure you use the data port on the Pi, google if you are unsure. Reboot, once the automatic configuration completes (circa 1 minute) the car should detect the Pi as a USB drive.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/milesburton/teslacam/issues/17?email_source=notifications&email_token=AAJGHMYSZPPFBU2IJ2H32QTQACUD7A5CNFSM4IEWOCT2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD2JIL3Q#issuecomment-512919022, or mute the thread https://github.com/notifications/unsubscribe-auth/AAJGHM2VJNTBSILHMCCNPADQACUD7ANCNFSM4IEWOCTQ .

natrlhy commented 5 years ago

I got this error when just using the command:

pi@raspberrypi:~ $ /home/pi/teslacam/src; node dashcam-monitor.js -bash: /home/pi/teslacam/src: Is a directory internal/modules/cjs/loader.js:638 throw err; ^

Error: Cannot find module '/home/pi/dashcam-monitor.js' at Function.Module._resolveFilename (internal/modules/cjs/loader.js:636:15) at Function.Module._load (internal/modules/cjs/loader.js:562:25) at Function.Module.runMain (internal/modules/cjs/loader.js:829:12) at startup (internal/bootstrap/node.js:283:19) at bootstrapNodeJSCore (internal/bootstrap/node.js:622:3)

But when I cd to the /home/pi/teslacam/src and run node dashcam-monitor.js:

pi@raspberrypi:~/teslacam/src $ node dashcam-monitor.js Starting Tesla Sync script Unmounting image All Running [sudo /sbin/modprobe -r g_mass_storage] Preparing to unmount local image 0 Running [sudo /bin/umount /mnt] umount: /mnt: not mounted. Failed: code [32]: umount: /mnt: not mounted. Running [sudo /sbin/losetup -d /dev/loop0] losetup: /dev/loop0: detach failed: No such device or address Failed: code [1]: losetup: /dev/loop0: detach failed: No such device or address (node:507) ExperimentalWarning: The fs.promises API is experimental Video /home/pi/teslacam/video/.gitkeep is 0 bytes. Deleting file Running [rm /home/pi/teslacam/video/.gitkeep] Running [fallocate -l 1024M /home/pi/teslacam/images/cam0] Running [echo "type=c" | /sbin/sfdisk /home/pi/teslacam/images/cam0] ======================= Success Checking that no-one is using this disk right now ... OK

Disk /home/pi/teslacam/images/cam0: 1 GiB, 1073741824 bytes, 2097152 sectors Units: sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes

Created a new DOS disklabel with disk identifier 0x7958db6d. /home/pi/teslacam/images/cam0p1: Created a new partition 1 of type 'W95 FAT32 (LBA)' and of size 1023 MiB. /home/pi/teslacam/images/cam0p2: Done.

New situation: Disklabel type: dos Disk identifier: 0x7958db6d

Device Boot Start End Sectors Size Id Type /home/pi/teslacam/images/cam0p1 2048 2097151 2095104 1023M c W95 FAT32 (LBA)

The partition table has been altered. Syncing disks. ======================= /Success Preparing to local mount image 0 Running [sfdisk -l -o Size -q --bytes "/home/pi/teslacam/images/cam0" | tail -1] Success: 1072693248 Running [sfdisk -l -o Sectors -q "/home/pi/teslacam/images/cam0" | tail -1] Success: 2095104 Sector size: 512 Running [sfdisk -l -o Start -q "/home/pi/teslacam/images/cam0" | tail -1] Success: 2048 Running [sudo /sbin/losetup -o 1048576 /dev/loop0 /home/pi/teslacam/images/cam0] Running [sudo /sbin/mkfs.vfat /dev/loop0 -F 32 -I] Success: mkfs.fat 4.1 (2017-01-24) Preparing to unmount local image 0 Running [sudo /bin/umount /mnt] umount: /mnt: not mounted. Failed: code [32]: umount: /mnt: not mounted. Running [sudo /sbin/losetup -d /dev/loop0] Running [fallocate -l 1024M /home/pi/teslacam/images/cam1] Running [echo "type=c" | /sbin/sfdisk /home/pi/teslacam/images/cam1] ======================= Success Checking that no-one is using this disk right now ... OK

Disk /home/pi/teslacam/images/cam1: 1 GiB, 1073741824 bytes, 2097152 sectors Units: sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes

Created a new DOS disklabel with disk identifier 0xb8117a6c. /home/pi/teslacam/images/cam1p1: Created a new partition 1 of type 'W95 FAT32 (LBA)' and of size 1023 MiB. /home/pi/teslacam/images/cam1p2: Done.

New situation: Disklabel type: dos Disk identifier: 0xb8117a6c

Device Boot Start End Sectors Size Id Type /home/pi/teslacam/images/cam1p1 2048 2097151 2095104 1023M c W95 FAT32 (LBA)

The partition table has been altered. Syncing disks. ======================= /Success Preparing to local mount image 1 Running [sfdisk -l -o Size -q --bytes "/home/pi/teslacam/images/cam1" | tail -1] Success: 1072693248 Running [sfdisk -l -o Sectors -q "/home/pi/teslacam/images/cam1" | tail -1] Success: 2095104 Sector size: 512 Running [sfdisk -l -o Start -q "/home/pi/teslacam/images/cam1" | tail -1] Success: 2048 Running [sudo /sbin/losetup -o 1048576 /dev/loop1 /home/pi/teslacam/images/cam1] Running [sudo /sbin/mkfs.vfat /dev/loop1 -F 32 -I] Success: mkfs.fat 4.1 (2017-01-24) Preparing to unmount local image 1 Running [sudo /bin/umount /mnt] umount: /mnt: not mounted. Failed: code [32]: umount: /mnt: not mounted. Running [sudo /sbin/losetup -d /dev/loop1] Preparing to local mount image 0 Running [sfdisk -l -o Size -q --bytes "/home/pi/teslacam/images/cam0" | tail -1] Success: 1072693248 Running [sfdisk -l -o Sectors -q "/home/pi/teslacam/images/cam0" | tail -1] Success: 2095104 Sector size: 512 Running [sfdisk -l -o Start -q "/home/pi/teslacam/images/cam0" | tail -1] Success: 2048 Running [sudo /sbin/losetup -o 1048576 /dev/loop0 /home/pi/teslacam/images/cam0] Running [sudo /bin/mount -o gid=pi,uid=pi /dev/loop0 /mnt] No files found Preparing to unmount local image 0 Running [sudo /bin/umount /mnt] Running [sudo /sbin/losetup -d /dev/loop0] Preparing to local mount image 1 Running [sfdisk -l -o Size -q --bytes "/home/pi/teslacam/images/cam1" | tail -1] Success: 1072693248 Running [sfdisk -l -o Sectors -q "/home/pi/teslacam/images/cam1" | tail -1] Success: 2095104 Sector size: 512 Running [sfdisk -l -o Start -q "/home/pi/teslacam/images/cam1" | tail -1] Success: 2048 Running [sudo /sbin/losetup -o 1048576 /dev/loop1 /home/pi/teslacam/images/cam1] Running [sudo /bin/mount -o gid=pi,uid=pi /dev/loop1 /mnt] No files found Preparing to unmount local image 1 Running [sudo /bin/umount /mnt] Running [sudo /sbin/losetup -d /dev/loop1] Preparing to mount image 0 Running [sudo /sbin/modprobe g_mass_storage file=/home/pi/teslacam/images/cam0 removable=1 ro=0 stall=0 iSerialNumber=11610] Waiting for video files

As the pi user here's the output for npm:

pi@raspberrypi:~/teslacam $ pwd /home/pi/teslacam pi@raspberrypi:~/teslacam $ npm run start

teslacam@1.0.0 start /home/pi/teslacam node src/services start

Running [sudo svc -u /home/pi/teslacam/./services/dashcam-monitor] svc: warning: unable to control /home/pi/teslacam/./services/dashcam-monitor: file does not exist Running [sudo svc -u /home/pi/teslacam/./services/dropbox-upload] svc: warning: unable to control /home/pi/teslacam/./services/dropbox-upload: file does not exist Running [sudo svc -u /home/pi/teslacam/./services/rotate-video] svc: warning: unable to control /home/pi/teslacam/./services/rotate-video: file does not exist (node:812) ExperimentalWarning: The fs.promises API is experimental

milesburton commented 5 years ago

OK the node script you ran looks good, did it mount anything on your machine?

Not sure why npm start isn't playing ball. Let's start with the raw dashcam script to make sure that's doing what it should and go from there

On Thu, Jul 18, 2019 at 8:24 PM natrlhy notifications@github.com wrote:

I got this error when just using the command:

pi@raspberrypi:~ $ /home/pi/teslacam/src; node dashcam-monitor.js -bash: /home/pi/teslacam/src: Is a directory internal/modules/cjs/loader.js:638 throw err; ^

Error: Cannot find module '/home/pi/dashcam-monitor.js' at Function.Module._resolveFilename (internal/modules/cjs/loader.js:636:15) at Function.Module._load (internal/modules/cjs/loader.js:562:25) at Function.Module.runMain (internal/modules/cjs/loader.js:829:12) at startup (internal/bootstrap/node.js:283:19) at bootstrapNodeJSCore (internal/bootstrap/node.js:622:3)

But when I cd to the /home/pi/teslacam/src and run node dashcam-monitor.js:

pi@raspberrypi:~/teslacam/src $ node dashcam-monitor.js Starting Tesla Sync script Unmounting image All Running [sudo /sbin/modprobe -r g_mass_storage] Preparing to unmount local image 0 Running [sudo /bin/umount /mnt] umount: /mnt: not mounted. Failed: code [32]: umount: /mnt: not mounted. Running [sudo /sbin/losetup -d /dev/loop0] losetup: /dev/loop0: detach failed: No such device or address Failed: code [1]: losetup: /dev/loop0: detach failed: No such device or address (node:507) ExperimentalWarning: The fs.promises API is experimental Video /home/pi/teslacam/video/.gitkeep is 0 bytes. Deleting file Running [rm /home/pi/teslacam/video/.gitkeep] Running [fallocate -l 1024M /home/pi/teslacam/images/cam0] Running [echo "type=c" | /sbin/sfdisk /home/pi/teslacam/images/cam0] ======================= Success Checking that no-one is using this disk right now ... OK

Disk /home/pi/teslacam/images/cam0: 1 GiB, 1073741824 bytes, 2097152 sectors Units: sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes

Created a new DOS disklabel with disk identifier 0x7958db6d. /home/pi/teslacam/images/cam0p1: Created a new partition 1 of type 'W95 FAT32 (LBA)' and of size 1023 MiB. /home/pi/teslacam/images/cam0p2: Done.

New situation: Disklabel type: dos Disk identifier: 0x7958db6d

Device Boot Start End Sectors Size Id Type /home/pi/teslacam/images/cam0p1 2048 2097151 2095104 1023M c W95 FAT32 (LBA)

The partition table has been altered. Syncing disks. ======================= /Success Preparing to local mount image 0 Running [sfdisk -l -o Size -q --bytes "/home/pi/teslacam/images/cam0" | tail -1] Success: 1072693248 Running [sfdisk -l -o Sectors -q "/home/pi/teslacam/images/cam0" | tail -1] Success: 2095104 Sector size: 512 Running [sfdisk -l -o Start -q "/home/pi/teslacam/images/cam0" | tail -1] Success: 2048 Running [sudo /sbin/losetup -o 1048576 /dev/loop0 /home/pi/teslacam/images/cam0] Running [sudo /sbin/mkfs.vfat /dev/loop0 -F 32 -I] Success: mkfs.fat 4.1 (2017-01-24) Preparing to unmount local image 0 Running [sudo /bin/umount /mnt] umount: /mnt: not mounted. Failed: code [32]: umount: /mnt: not mounted. Running [sudo /sbin/losetup -d /dev/loop0] Running [fallocate -l 1024M /home/pi/teslacam/images/cam1] Running [echo "type=c" | /sbin/sfdisk /home/pi/teslacam/images/cam1] ======================= Success Checking that no-one is using this disk right now ... OK

Disk /home/pi/teslacam/images/cam1: 1 GiB, 1073741824 bytes, 2097152 sectors Units: sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes

Created a new DOS disklabel with disk identifier 0xb8117a6c. /home/pi/teslacam/images/cam1p1: Created a new partition 1 of type 'W95 FAT32 (LBA)' and of size 1023 MiB. /home/pi/teslacam/images/cam1p2: Done.

New situation: Disklabel type: dos Disk identifier: 0xb8117a6c

Device Boot Start End Sectors Size Id Type /home/pi/teslacam/images/cam1p1 2048 2097151 2095104 1023M c W95 FAT32 (LBA)

The partition table has been altered. Syncing disks. ======================= /Success Preparing to local mount image 1 Running [sfdisk -l -o Size -q --bytes "/home/pi/teslacam/images/cam1" | tail -1] Success: 1072693248 Running [sfdisk -l -o Sectors -q "/home/pi/teslacam/images/cam1" | tail -1] Success: 2095104 Sector size: 512 Running [sfdisk -l -o Start -q "/home/pi/teslacam/images/cam1" | tail -1] Success: 2048 Running [sudo /sbin/losetup -o 1048576 /dev/loop1 /home/pi/teslacam/images/cam1] Running [sudo /sbin/mkfs.vfat /dev/loop1 -F 32 -I] Success: mkfs.fat 4.1 (2017-01-24) Preparing to unmount local image 1 Running [sudo /bin/umount /mnt] umount: /mnt: not mounted. Failed: code [32]: umount: /mnt: not mounted. Running [sudo /sbin/losetup -d /dev/loop1] Preparing to local mount image 0 Running [sfdisk -l -o Size -q --bytes "/home/pi/teslacam/images/cam0" | tail -1] Success: 1072693248 Running [sfdisk -l -o Sectors -q "/home/pi/teslacam/images/cam0" | tail -1] Success: 2095104 Sector size: 512 Running [sfdisk -l -o Start -q "/home/pi/teslacam/images/cam0" | tail -1] Success: 2048 Running [sudo /sbin/losetup -o 1048576 /dev/loop0 /home/pi/teslacam/images/cam0] Running [sudo /bin/mount -o gid=pi,uid=pi /dev/loop0 /mnt] No files found Preparing to unmount local image 0 Running [sudo /bin/umount /mnt] Running [sudo /sbin/losetup -d /dev/loop0] Preparing to local mount image 1 Running [sfdisk -l -o Size -q --bytes "/home/pi/teslacam/images/cam1" | tail -1] Success: 1072693248 Running [sfdisk -l -o Sectors -q "/home/pi/teslacam/images/cam1" | tail -1] Success: 2095104 Sector size: 512 Running [sfdisk -l -o Start -q "/home/pi/teslacam/images/cam1" | tail -1] Success: 2048 Running [sudo /sbin/losetup -o 1048576 /dev/loop1 /home/pi/teslacam/images/cam1] Running [sudo /bin/mount -o gid=pi,uid=pi /dev/loop1 /mnt] No files found Preparing to unmount local image 1 Running [sudo /bin/umount /mnt] Running [sudo /sbin/losetup -d /dev/loop1] Preparing to mount image 0 Running [sudo /sbin/modprobe g_mass_storage file=/home/pi/teslacam/images/cam0 removable=1 ro=0 stall=0 iSerialNumber=11610] Waiting for video files

As the pi user here's the output for npm:

pi@raspberrypi:/teslacam $ pwd /home/pi/teslacam pi@raspberrypi:/teslacam $ npm run start

teslacam@1.0.0 start /home/pi/teslacam node src/services start

Running [sudo svc -u /home/pi/teslacam/./services/dashcam-monitor] svc: warning: unable to control /home/pi/teslacam/./services/dashcam-monitor: file does not exist Running [sudo svc -u /home/pi/teslacam/./services/dropbox-upload] svc: warning: unable to control /home/pi/teslacam/./services/dropbox-upload: file does not exist Running [sudo svc -u /home/pi/teslacam/./services/rotate-video] svc: warning: unable to control /home/pi/teslacam/./services/rotate-video: file does not exist (node:812) ExperimentalWarning: The fs.promises API is experimental

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/milesburton/teslacam/issues/17?email_source=notifications&email_token=AAJGHM2KEERZG7EDSG35TATQAC7NBA5CNFSM4IEWOCT2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD2JQUVA#issuecomment-512952916, or mute the thread https://github.com/notifications/unsubscribe-auth/AAJGHM6AAG4ENEWRJ3CTBATQAC7NBANCNFSM4IEWOCTQ .

natrlhy commented 5 years ago

Not seeing anything to write to:

pi@raspberrypi:~/teslacam $ df Filesystem 1K-blocks Used Available Use% Mounted on /dev/root 61133444 3730916 54887156 7% / devtmpfs 217224 0 217224 0% /dev tmpfs 221552 0 221552 0% /dev/shm tmpfs 221552 3124 218428 2% /run tmpfs 5120 4 5116 1% /run/lock tmpfs 221552 0 221552 0% /sys/fs/cgroup /dev/mmcblk0p1 258096 39969 218127 16% /boot tmpfs 44308 0 44308 0% /run/user/1000

milesburton commented 5 years ago

The script activates the Raspberry Pi W's OTG port (the second port towards the central of the pi). If you plug that port in to your main computer it should mount as a standard USB Flash Drive.

The idea being we are trying to emulate a thumb drive which the Tesla uses. This fake drive wont show up on the pi, it needs a host machine to be visible. Plug it in to your computer, it should mount after a starting up (ie running the command)

On Thu, Jul 18, 2019 at 8:31 PM natrlhy notifications@github.com wrote:

Not seeing anything to write to:

pi@raspberrypi:~/teslacam $ df Filesystem 1K-blocks Used Available Use% Mounted on /dev/root 61133444 3730916 54887156 7% / devtmpfs 217224 0 217224 0% /dev tmpfs 221552 0 221552 0% /dev/shm tmpfs 221552 3124 218428 2% /run tmpfs 5120 4 5116 1% /run/lock tmpfs 221552 0 221552 0% /sys/fs/cgroup /dev/mmcblk0p1 258096 39969 218127 16% /boot tmpfs 44308 0 44308 0% /run/user/1000

— You are receiving this because you commented. Reply to this email directly, view it on GitHub, or mute the thread.

natrlhy commented 5 years ago

So I only have the USB cable connected to my PC now. I don't have external power running to the Pi at the moment. When I run the command connected like this I don't get a drive mounted on my PC. Should I be supplying external power in the outtermost USB port on the Pi then connecting it to a USB port on my PC with 2nd port towards the inside of the pi?

milesburton commented 5 years ago

You should be able to power the pi with only a single cable from your PC connected to the OTG port on the pi (the USB port towards the centre of the pi). When you run the node script I mentioned earlier, after a minute or so it should mount a drive on your computer

On Thu, Jul 18, 2019 at 9:20 PM natrlhy notifications@github.com wrote:

So I only have the USB cable connected to my PC now. I don't have external power running to the Pi at the moment. When I run the command connected like this I don't get a drive mounted on my PC. Should I be supplying external power in the outtermost USB port on the Pi then connecting it to a USB port on my PC with 2nd port towards the inside of the pi?

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/milesburton/teslacam/issues/17?email_source=notifications&email_token=AAJGHM3KNU5VIPL7LZXMKW3QADF77A5CNFSM4IEWOCT2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD2JVKAI#issuecomment-512972033, or mute the thread https://github.com/notifications/unsubscribe-auth/AAJGHM6HE2473IP5XKHQYG3QADF77ANCNFSM4IEWOCTQ .

natrlhy commented 5 years ago

:( Not doing it with either a single USB cable or externally powered. I'm going to try the stretch-lite flashing and see if that is a culprit. Not sure what I'm doing wrong here otherwise...

A quick breakdown of permission stuff though. I'm doing everything as root except when I clone the repo. I'm doing that as the pi user and I'm also running the node dashcam-monitor.js command as the pi user. I have the sudoers file in place as well....

milesburton commented 5 years ago

Strange.

My recommendation is focus on the dashcam script. Don't worry about the permissions if you are running as root.

Assuming the dashcam script doesn't fail (it'll throw up errors in the output) it should be working.

On Thu, Jul 18, 2019 at 9:25 PM natrlhy notifications@github.com wrote:

:( Not doing it with either a single USB cable or externally powered. I'm going to try the stretch-lite flashing and see if that is a culprit. Not sure what I'm doing wrong here otherwise...

A quick breakdown of permission stuff though. I'm doing everything as root except when I clone the repo. I'm doing that as the pi user and I'm also running the node dashcam-monitor.js command as the pi user. I have the sudoers file in place as well....

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/milesburton/teslacam/issues/17?email_source=notifications&email_token=AAJGHMYG7JHU2YSDQSRLLHLQADGT3A5CNFSM4IEWOCT2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD2JVXIQ#issuecomment-512973730, or mute the thread https://github.com/notifications/unsubscribe-auth/AAJGHM6PLTJQVJ2YTF2W5MLQADGT3ANCNFSM4IEWOCTQ .

natrlhy commented 5 years ago

Latest output when starting it:

pi@raspberrypi:~/teslacam/src $ node dashcam-monitor.js Starting Tesla Sync script Unmounting image All Running [sudo /sbin/modprobe -r g_mass_storage] Preparing to unmount local image 0 Running [sudo /bin/umount /mnt] umount: /mnt: not mounted. Failed: code [32]: umount: /mnt: not mounted. Running [sudo /sbin/losetup -d /dev/loop0] losetup: /dev/loop0: detach failed: No such device or address Failed: code [1]: losetup: /dev/loop0: detach failed: No such device or address (node:479) ExperimentalWarning: The fs.promises API is experimental Preparing to local mount image 0 Running [sfdisk -l -o Size -q --bytes "/home/pi/teslacam/images/cam0" | tail -1] Success: 1072693248 Running [sfdisk -l -o Sectors -q "/home/pi/teslacam/images/cam0" | tail -1] Success: 2095104 Sector size: 512 Running [sfdisk -l -o Start -q "/home/pi/teslacam/images/cam0" | tail -1] Success: 2048 Running [sudo /sbin/losetup -o 1048576 /dev/loop0 /home/pi/teslacam/images/cam0] Running [sudo /bin/mount -o gid=pi,uid=pi /dev/loop0 /mnt] No files found Preparing to unmount local image 0 Running [sudo /bin/umount /mnt] Running [sudo /sbin/losetup -d /dev/loop0] Preparing to local mount image 1 Running [sfdisk -l -o Size -q --bytes "/home/pi/teslacam/images/cam1" | tail -1] Success: 1072693248 Running [sfdisk -l -o Sectors -q "/home/pi/teslacam/images/cam1" | tail -1] Success: 2095104 Sector size: 512 Running [sfdisk -l -o Start -q "/home/pi/teslacam/images/cam1" | tail -1] Success: 2048 Running [sudo /sbin/losetup -o 1048576 /dev/loop1 /home/pi/teslacam/images/cam1] Running [sudo /bin/mount -o gid=pi,uid=pi /dev/loop1 /mnt] No files found Preparing to unmount local image 1 Running [sudo /bin/umount /mnt] Running [sudo /sbin/losetup -d /dev/loop1] Preparing to mount image 0 Running [sudo /sbin/modprobe g_mass_storage file=/home/pi/teslacam/images/cam0 removable=1 ro=0 stall=0 iSerialNumber=56691] Waiting for video files

I wait there and don't see any drive getting mounted to my Windows 10 PC.

milesburton commented 5 years ago

Those errors are fine, it's basically trying to unmount (detach) the USB drive ... but nothing is mounted. If the error is a real issue the script should crash.

Try running this:

This unmounts the faux USB drive

sudo /sbin/modprobe -r g_mass_storage sudo /bin/umount /mnt sudo /sbin/losetup -d /dev/loop0

This should mount the usb drive and show up on your windows pc

sudo /sbin/modprobe g_mass_storage file=/home/pi/teslacam/images/cam0 removable=1 ro=0 stall=0 iSerialNumber=56691

On Thu, Jul 18, 2019 at 9:29 PM natrlhy notifications@github.com wrote:

Latest output when starting it:

pi@raspberrypi:~/teslacam/src $ node dashcam-monitor.js Starting Tesla Sync script Unmounting image All Running [sudo /sbin/modprobe -r g_mass_storage] Preparing to unmount local image 0 Running [sudo /bin/umount /mnt] umount: /mnt: not mounted. Failed: code [32]: umount: /mnt: not mounted. Running [sudo /sbin/losetup -d /dev/loop0] losetup: /dev/loop0: detach failed: No such device or address Failed: code [1]: losetup: /dev/loop0: detach failed: No such device or address (node:479) ExperimentalWarning: The fs.promises API is experimental Preparing to local mount image 0 Running [sfdisk -l -o Size -q --bytes "/home/pi/teslacam/images/cam0" | tail -1] Success: 1072693248 Running [sfdisk -l -o Sectors -q "/home/pi/teslacam/images/cam0" | tail -1] Success: 2095104 Sector size: 512 Running [sfdisk -l -o Start -q "/home/pi/teslacam/images/cam0" | tail -1] Success: 2048 Running [sudo /sbin/losetup -o 1048576 /dev/loop0 /home/pi/teslacam/images/cam0] Running [sudo /bin/mount -o gid=pi,uid=pi /dev/loop0 /mnt] No files found Preparing to unmount local image 0 Running [sudo /bin/umount /mnt] Running [sudo /sbin/losetup -d /dev/loop0] Preparing to local mount image 1 Running [sfdisk -l -o Size -q --bytes "/home/pi/teslacam/images/cam1" | tail -1] Success: 1072693248 Running [sfdisk -l -o Sectors -q "/home/pi/teslacam/images/cam1" | tail -1] Success: 2095104 Sector size: 512 Running [sfdisk -l -o Start -q "/home/pi/teslacam/images/cam1" | tail -1] Success: 2048 Running [sudo /sbin/losetup -o 1048576 /dev/loop1 /home/pi/teslacam/images/cam1] Running [sudo /bin/mount -o gid=pi,uid=pi /dev/loop1 /mnt] No files found Preparing to unmount local image 1 Running [sudo /bin/umount /mnt] Running [sudo /sbin/losetup -d /dev/loop1] Preparing to mount image 0 Running [sudo /sbin/modprobe g_mass_storage file=/home/pi/teslacam/images/cam0 removable=1 ro=0 stall=0 iSerialNumber=56691] Waiting for video files

I wait there and don't see any drive getting mounted to my Windows 10 PC.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/milesburton/teslacam/issues/17?email_source=notifications&email_token=AAJGHM4ZSZMNVD6NLMO3DDTQADHA3A5CNFSM4IEWOCT2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD2JWABA#issuecomment-512974852, or mute the thread https://github.com/notifications/unsubscribe-auth/AAJGHMZR2FGEEKUUMOKSQ4DQADHA3ANCNFSM4IEWOCTQ .

natrlhy commented 5 years ago

No errors doing that but I don't see a USB disk appear on the PC:

pi@raspberrypi:~ $ sudo /sbin/modprobe -r g_mass_storage pi@raspberrypi:~ $ sudo /bin/umount /mnt umount: /mnt: not mounted. pi@raspberrypi:~ $ sudo /sbin/losetup -d /dev/loop0 losetup: /dev/loop0: detach failed: No such device or address pi@raspberrypi:~ $ sudo /sbin/modprobe g_mass_storage file=/home/pi/teslacam/images/cam0 removable=1 ro=0 stall=0 iSerialNumber=56691

milesburton commented 5 years ago

Hmm, something isn't quite right there. It could be the module drivers for the kernel (ie: go back to Stretch raspbien).

As an experiment you could try out this branch https://github.com/milesburton/teslacam/tree/add-ext4-filesystem << you'll need to delete your /home/pi/teslacam/images/cam* files

On Thu, Jul 18, 2019 at 9:44 PM natrlhy notifications@github.com wrote:

No errors doing that but I don't see a USB disk appear on the PC:

pi@raspberrypi:~ $ sudo /sbin/modprobe -r g_mass_storage pi@raspberrypi:~ $ sudo /bin/umount /mnt umount: /mnt: not mounted. pi@raspberrypi:~ $ sudo /sbin/losetup -d /dev/loop0 losetup: /dev/loop0: detach failed: No such device or address pi@raspberrypi:~ $ sudo /sbin/modprobe g_mass_storage file=/home/pi/teslacam/images/cam0 removable=1 ro=0 stall=0 iSerialNumber=56691

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/milesburton/teslacam/issues/17?email_source=notifications&email_token=AAJGHM7WKZ5K6KDSYCZC6TTQADI4HA5CNFSM4IEWOCT2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD2JXLAQ#issuecomment-512980354, or mute the thread https://github.com/notifications/unsubscribe-auth/AAJGHM4X2H2IVVREADFX76TQADI4HANCNFSM4IEWOCTQ .

natrlhy commented 5 years ago

I'll try Stretch and doing the main branch one more time then give the ext4 branch a go if that fails again. Thanks for all the help!

milesburton commented 5 years ago

No worries, tricky trying to figure it out from a distance :) Baby steps

On Thu, Jul 18, 2019 at 9:49 PM natrlhy notifications@github.com wrote:

I'll try Stretch and doing the main branch one more time then give the ext4 branch a go if that fails again. Thanks for all the help!

— You are receiving this because you commented. Reply to this email directly, view it on GitHub, or mute the thread.

natrlhy commented 5 years ago

Was going to ask if you wanted to do a WebEx at some point hehe

milesburton commented 5 years ago

See how you get on with Stretch, if I've got some time we can do a quick call.

On Thu, Jul 18, 2019 at 9:51 PM natrlhy notifications@github.com wrote:

Was going to ask if you wanted to do a WebEx at some point hehe

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/milesburton/teslacam/issues/17?email_source=notifications&email_token=AAJGHM2HCCK3J6M46SYQIATQADJUVA5CNFSM4IEWOCT2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD2JX4DY#issuecomment-512982543, or mute the thread https://github.com/notifications/unsubscribe-auth/AAJGHMZBD7QXBZZW2CPLYXLQADJUVANCNFSM4IEWOCTQ .

milesburton commented 5 years ago

ps did you see this (I forgot about it)

Modify the /boot partition to enable USB OTG. We need to enable g_mass_storage and dw2. 2b. Edit your cmdline.txt to include "loop.max_part=31". The file should look similar to: "dwc_otg.lpm_enable=0 console=serial0,115200 console=tty1 root=PARTUUID=53202854-02 rootfstype=ext4 elevator=deadline fsck.repair=yes loop.max_part=31 rootwait modules-load=dwc2,g_mass_storage

natrlhy commented 5 years ago

I only have this portion:

===== Enable OTG on the Pi Zero W =====

Follow this great guide to setup OTG on the Pi Zero W: https://blog.gbaman.info/?p=791

Browse to the /boot partition on the SDHC card on your PC Add this to the bottom of the config.txt file: dtoverlay=dwc2 Save the file

Add this to the cmdline.txt file. Place it right after rootwait with a space at the end of it. Be careful as syntax is critical: modules-load=dwc2,g_ether

Save the file

milesburton commented 5 years ago

Modify the config.txt and add modules-load=dwc2,g_mass_storage

Sorry I should have spotted that earlier. g_ether has nothing to do with this project

natrlhy commented 5 years ago

Ok i'm trying this out on stretch as is. I'll make the change to the cmdline.txt (you mentioned it's the config.txt file so correct me if I'm wrong) after I get it up and running again

natrlhy commented 5 years ago

Boom! When I added the g_mass_storage module to the cmdline.txt file, rebooted and ran node dashcam-monitor.js it mounted a 1GB USB drive on the PC. You're notes did call out having g_mass_storage setup but I was doing a copy from the URL that was referenced.

I do notice that services still aren't starting though. They don't seem to background processes so do they just run on boot and that's it?

milesburton commented 5 years ago

They should only start on startup. Let's look at that next once you've confirmed the dashcam-monitor script is working

On Thu, Jul 18, 2019 at 10:42 PM natrlhy notifications@github.com wrote:

Boom! When I added the g_mass_storage module to the cmdline.txt file, rebooted and ran node dashcam-monitor.js it mounted a 1GB USB drive on the PC. You're notes did call out having g_mass_storage setup but I was doing a copy from the URL that was referenced.

I do notice that services still aren't starting though. They don't seem to background processes so do they just run on boot and that's it?

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/milesburton/teslacam/issues/17?email_source=notifications&email_token=AAJGHMYF7TTKXYQLSMIQJHLQADPU3A5CNFSM4IEWOCT2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD2J4CWQ#issuecomment-512999770, or mute the thread https://github.com/notifications/unsubscribe-auth/AAJGHM4CPPYZ2INYLZFDKTLQADPU3ANCNFSM4IEWOCTQ .

natrlhy commented 5 years ago

Ok when I reboot the pi, I get an error on the PC saying USB mass storage device not recognized and I don't see a drive mounted.

I also don't see any log info here:

~/teslacam/services/dashcam-monitor/log/main

I was going by your instructions of creating the links to services:

/etc/service ln -s /home/pi/teslacam/services/* .

/etc/service doesn't exist so I'm creating it. /etc/services is a file that exists already so not sure if thing service wise are setup properly.

milesburton commented 5 years ago

At a high level that's usually a power issue, check you don't have any dodgy connections.

As for the logs, for now, you'll have to fire up the dashcam script manually.

Unfortunately it's rather late here, let's pick this up tomorrow

On Thu, Jul 18, 2019 at 10:52 PM natrlhy notifications@github.com wrote:

Ok when I reboot the pi, I get an error on the PC saying USB mass storage device not recognized and I don't see a drive mounted.

I also don't see any log info here:

~/teslacam/services/dashcam-monitor/log/main

— You are receiving this because you commented. Reply to this email directly, view it on GitHub, or mute the thread.

natrlhy commented 5 years ago

Thanks for all your help! Sounds good...

kfulgham commented 5 years ago

:( Not doing it with either a single USB cable or externally powered. I'm going to try the stretch-lite flashing and see if that is a culprit. Not sure what I'm doing wrong here otherwise...

A quick breakdown of permission stuff though. I'm doing everything as root except when I clone the repo. I'm doing that as the pi user and I'm also running the node dashcam-monitor.js command as the pi user. I have the sudoers file in place as well....

So, I'm EXACTLY the same place. I've been at this for hours and can't get this going. If you resolve this, please ping me.

Edit: I just noticed in your instructions I'm supposed to "cd /etc/service ln -s /home/pi/teslacam/services/* " /etc/service does not exist in my system. I just tried doing a mkdir but is this maybe an issue with DaemonTools not installing right?

kfulgham commented 5 years ago

OK let's try something simple. Let's start the dashcam-monitor.js directly. To do that, cd /home/pi/teslacam/src; node dashcam-monitor.js // whilst plugged in to your computer. The services could be something irrelevant. Now you've checked out the code again, what did npm run start do for you from /home/pi/teslacam?

Ok, after my above edit and a fourth attempt at redoing everything I now have node dashcam-monitor.js mount a drive to my local machine. It still doesn't run as a service but this is progress.

`pi@raspberrypi:~/teslacam $ npm start

teslacam@1.0.0 start /home/pi/teslacam node src/services start

Running [sudo svc -u /home/pi/teslacam/./services/dashcam-monitor] svc: warning: unable to control /home/pi/teslacam/./services/dashcam-monitor: file does not exist Running [sudo svc -u /home/pi/teslacam/./services/dropbox-upload] svc: warning: unable to control /home/pi/teslacam/./services/dropbox-upload: file does not exist Running [sudo svc -u /home/pi/teslacam/./services/rotate-video] svc: warning: unable to control /home/pi/teslacam/./services/rotate-video: file does not exist (node:1720) ExperimentalWarning: The fs.promises API is experimental `

Side note: is the /teslacam/./services an issue? that period in the folder stands out to me.

milesburton commented 5 years ago

Right, looks like services isn't correctly cloned down. You need the files in this directory to appear

https://github.com/milesburton/teslacam/tree/master/services

you could try a git reset --hard, that should revert any changes you may have made accidentally.

Vikinge commented 5 years ago

I am using buster-lite and had same issue of file does not exist. Not sure this was the fix, but try creating a symbolic link to /opt/node/bin/node in /bin. we already have node in /usr/bin, but add it to /bin folder. Let me know if this fixes anyone else.

I still have a problem where supervise is not running and the rc.local does not seem to kick off /command/svscanboot. Anyone have recommendation? Even if I sudo /command/svscanboot &, I see supervise not running. sudo supervise /etc/service/dashcam-monitor does run the service.

milesburton commented 5 years ago

Hopefully the image installer will resolve these issues. It shouldn't be long before that's merged to master.