Advertisement
SideshowJoelJacobs

CAN Button OP

Feb 21st, 2018
98
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Diff 3.46 KB | None | 0 0
  1. diff --git a/cereal/car.capnp b/cereal/car.capnp
  2. index be31f66..8e81926 100644
  3. --- a/cereal/car.capnp
  4. +++ b/cereal/car.capnp
  5. @@ -98,6 +98,8 @@ struct CarState {
  6.    leftBlinker @20 :Bool;
  7.    rightBlinker @21 :Bool;
  8.    genericToggle @23 :Bool;
  9. +  distanceToggle @26 :Bool;
  10. +  laneDepartureToggle @27 :Bool;
  11.  
  12.    # lock info
  13.    doorOpen @24 :Bool;
  14. diff --git a/opendbc/toyota_rav4_2017_pt_generated.dbc b/opendbc/toyota_rav4_2017_pt_generated.dbc
  15. index 3301bc0..911cc87 100644
  16. --- a/opendbc/toyota_rav4_2017_pt_generated.dbc
  17. +++ b/opendbc/toyota_rav4_2017_pt_generated.dbc
  18. @@ -57,6 +57,9 @@ BO_ 180 SPEED: 8 XXX
  19.   SG_ CHECKSUM : 63|8@0+ (1,0) [0|255] "" XXX
  20.   SG_ SPEED : 47|16@0+ (0.01,0) [0|250] "kph" XXX
  21.  
  22. +BO_ 352 NEW_MSG_1: 8 XXX
  23. + SG_ LANE_DEPARTURE_BUTTON : 39|1@0+ (1,0) [0|1] "" XXX
  24. +
  25.  BO_ 466 PCM_CRUISE: 8 XXX
  26.   SG_ GAS_RELEASED : 4|1@0+ (1,0) [0|1] "" XXX
  27.   SG_ STANDSTILL_ON : 12|1@0+ (1,0) [0|1] "" XXX
  28. @@ -97,6 +100,7 @@ BO_ 742 LEAD_INFO: 8 DSU
  29.  
  30.  BO_ 835 ACC_CONTROL: 8 DSU
  31.   SG_ ACCEL_CMD : 7|16@0- (0.001,0) [-20|20] "m/s2" HCU
  32. + SG_ ACC_DISTANCE : 20|1@0+ (1,0) [0|1] "" XXX
  33.  
  34.  BO_ 1556 STEERING_LEVERS: 8 XXX
  35.   SG_ TURN_SIGNALS : 29|2@0+ (1,0) [0|3] "" XXX
  36. diff --git a/selfdrive/car/toyota/carcontroller.py b/selfdrive/car/toyota/carcontroller.py
  37. index 3fd19f9..40417d8 100644
  38. --- a/selfdrive/car/toyota/carcontroller.py
  39. +++ b/selfdrive/car/toyota/carcontroller.py
  40. @@ -76,6 +76,20 @@ class CarController(object):
  41.  
  42.    def update(self, sendcan, enabled, CS, frame, actuators,
  43.               pcm_cancel_cmd, hud_alert, audible_alert):
  44. +    
  45. +    # init Button Tests
  46. +    if CS.distance_toggle:
  47. +        actuators.steer = 1.0
  48. +        with open("/distance.log", "a") as distance:
  49. +            distance.write("pressed once")
  50. +    if CS.lane_departure_toggle:
  51. +        actuators.steer = 1.0
  52. +        with open("/lane.log", "a") as lane:
  53. +                lane.write("pressed once")
  54. +    if CS.generic_toggle:
  55. +        actuators.steer = 1.0
  56. +        with open("/generic.log", "a") as generic:
  57. +                generic.write("pressed once")
  58.  
  59.      # *** compute control surfaces ***
  60.  
  61. diff --git a/selfdrive/car/toyota/carstate.py b/selfdrive/car/toyota/carstate.py
  62. index 24fc852..ee74889 100644
  63. --- a/selfdrive/car/toyota/carstate.py
  64. +++ b/selfdrive/car/toyota/carstate.py
  65. @@ -77,6 +77,8 @@ def get_can_parser(CP):
  66.      ("LKA_STATE", "EPS_STATUS", 0),
  67.      ("BRAKE_LIGHTS_ACC", "ESP_CONTROL", 0),
  68.      ("AUTO_HIGH_BEAM", "LIGHT_STALK", 0),
  69. +    ("ACC_DISTANCE", "ACC_CONTROL", 0),
  70. +    ("LANE_DEPARTURE_BUTTON", "NEW_MSG_1", 0),
  71.    ]
  72.  
  73.    checks = [
  74. @@ -171,3 +173,5 @@ class CarState(object):
  75.      self.low_speed_lockout = cp.vl["PCM_CRUISE_2"]['LOW_SPEED_LOCKOUT'] == 2
  76.      self.brake_lights = bool(cp.vl["ESP_CONTROL"]['BRAKE_LIGHTS_ACC'] or self.brake_pressed)
  77.      self.generic_toggle = bool(cp.vl["LIGHT_STALK"]['AUTO_HIGH_BEAM'])
  78. +    self.lane_departure_toggle = bool(cp.vl["NEW_MSG_1"]['LANE_DEPARTURE_BUTTON'])
  79. +    self.distance_toggle = bool(cp.vl["ACC_CONTROL"]['ACC_DISTANCE'])
  80. diff --git a/selfdrive/car/toyota/interface.py b/selfdrive/car/toyota/interface.py
  81. index 53cfbb1..9bf07d4 100755
  82. --- a/selfdrive/car/toyota/interface.py
  83. +++ b/selfdrive/car/toyota/interface.py
  84. @@ -239,7 +239,15 @@ class CarInterface(object):
  85.      ret.seatbeltUnlatched = not self.CS.seatbelt
  86.  
  87.      ret.genericToggle = self.CS.generic_toggle
  88. -
  89. +    ret.laneDepartureToggle = self.CS.lane_departure_toggle
  90. +    ret.distanceToggle = self.CS.distance_toggle
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement