Browse Source

Signed-off-by: caner <5658514@qq.com>

caner 3 years ago
parent
commit
bed350fd24
3 changed files with 9 additions and 3 deletions
  1. 6 3
      index.js
  2. 1 0
      lib/Pwm.js
  3. 2 0
      start.sh

+ 6 - 3
index.js

@@ -44,10 +44,12 @@ class CarServer {
             } else if (data.type === 'startRTC') {
                 this.startVideo()
             } if (data.type === 'conctrl') {
-                PWM.changPWM(data.conctrl)
+                const state = this.Peer.iceConnectionState;
+                if(state === 'connected') PWM.changPWM(data.conctrl);
             }
         } catch (error) {
-            console.log('msg error:', error);
+            console.log(error);
+            throw error
         }
     }
 
@@ -99,7 +101,8 @@ class CarServer {
             });
 
         } catch (error) {
-            console.log('startvideo:', error)
+            console.log(error);
+            throw error
         }
     }
 }

+ 1 - 0
lib/Pwm.js

@@ -149,6 +149,7 @@ class ContrlService {
         RPIO.open(13, RPIO.OUTPUT, RPIO.LOW);
         RPIO.open(19, RPIO.OUTPUT, RPIO.LOW);
         this.PWM = null
+        process.exit(1)
     }
 }
 module.exports = new ContrlService()

+ 2 - 0
start.sh

@@ -0,0 +1,2 @@
+sleep 30
+sudo /usr/bin/node /home/pi/car/index.js