Revision 8c99e03a

View differences:

devices/DiWheelDrive/DiWheelDrive.cpp
2 2
#include "hal.h"
3 3
#include "qei.h"
4 4
#include "DiWheelDrive.h"
5
#include <chprintf.h>
5
// #include <chprintf.h>
6 6

  
7 7

  
8 8
#include <global.hpp>
......
120 120
      }
121 121
      break;
122 122
    case CAN::SET_LINE_FOLLOW_MSG:
123
      chprintf((BaseSequentialStream*) &SD1, "Received Strategy!\n");
123
      // chprintf((BaseSequentialStream*) &SD1, "Received Strategy!\n");
124 124
      if (frame->DLC == 1) {
125 125
        global.lfStrategy = frame->data8[0];
126 126
        global.msgReceived = true;
127
        return RDY_OK;
127
        // return RDY_OK;
128 128
      }
129 129
      break;
130 130
    case CAN::SET_KINEMATIC_CONST_ID:
......
150 150
    case CAN::POWER_STATUS_ID:
151 151
      if (frame->DLC == 6) {
152 152
        // The power status is evaluated by inherited ControllerAreaNetworkRx object, but depending on the flags the power path controller needs to enabled or disabled.
153

  
153 154
        types::power_status::ChargingState charging_flags;
154 155
        charging_flags.value = frame->data8[0];
155 156
        global.ltc4412.enable(charging_flags.content.diwheeldrive_enable_power_path);
157
        
156 158
        // Do not return with RDY_OK, or the inherited ControllerAreaNetworkRx object would not evaluate the rest of this message.
157 159
      }
158 160
    break;
......
190 192
  return 0;
191 193
}
192 194

  
195
void DiWheelDrive::requestCharging(uint8_t power){
196
  CANTxFrame frame;
197
  frame.SID = 0;
198
  this->encodeDeviceId(&frame, CAN::REQUEST_CHARGING_OVER_PIN);
199
  frame.data8[0] = power;
200
  frame.DLC = 1;
201
  this->transmitMessage(&frame);
202
}
203

  
193 204
void DiWheelDrive::periodicBroadcast() {
194 205
  CANTxFrame frame;
195 206
  frame.SID = 0;
......
200 211
  frame.data32[1] = this->actualSpeed[1];
201 212
  frame.DLC = 8;
202 213
  this->transmitMessage(&frame);
214
  // Send Message for either activate or deactivate it
215

  
216

  
217

  
218
 
203 219

  
204 220
  // Send the valocites µm/s of the x axis and µrad/s around z axis: end
205 221
  // Send the odometry: start
devices/DiWheelDrive/DiWheelDrive.h
26 26

  
27 27
    /** \brief Handle the start of ControllerAreaNetworkTx and ControllerAreaNetworkRx threads */
28 28
    ThreadReference start(tprio_t PRIO);
29
    /**
30
    * Set Request to disable or enable the Charging.
31
    * @param power 0 to disable, 1 to enable
32
    */
33
    void requestCharging(uint8_t power);
29 34

  
30 35
  protected:
31 36
    virtual msg_t receiveMessage(CANRxFrame *frame);
32 37
    virtual msg_t updateSensorVal();
33 38
    virtual void periodicBroadcast();
34 39

  
40
    
41

  
35 42
    void  calibrateProximityFloorValues();
36 43

  
37 44
  private:
devices/PowerManagement/PowerManagement.cpp
57 57
        return RDY_OK;
58 58
      }
59 59
      break;
60
    case CAN::REQUEST_CHARGING_OVER_PIN:
61
      if (frame->DLC == 1) {
62
        // Error handling 
63
        // TODO: Error Handling, for now just set the given value
64
        this->powerStatus.charging_flags.content.diwheeldrive_enable_power_path = frame->data8[0];
65
        return RDY_OK;
66
      }
67
      break;
60 68

  
61 69
    default:
62 70
      break;
......
69 77

  
70 78
  // update charger status
71 79
  this->powerStatus.charging_flags.content.powermanagement_plugged_in = global.ltc4412.isPluggedIn();
80
  // this->powerStatus.charging_flags.content.powermanagement_plugged_in = (palReadPad((GPIO_TypeDef*)GPIOC, GPIOC_PATHDC) == PAL_HIGH); 
72 81

  
73 82
  // update fuel gauges values
74 83
  const BQ27500::Driver::UpdateData* power[2] {
......
115 124
  return 0;
116 125
}
117 126

  
127
void PowerManagement::setStrategy(uint8_t strategy){
128
  CANTxFrame frame;
129
  chprintf((BaseSequentialStream*) &SD1, "Message Triggered!\n");
130
  // global.triggerCan = false;
131
  frame.SID = 0;
132
  this->encodeDeviceId(&frame, CAN::SET_LINE_FOLLOW_MSG);
133
  frame.data8[0] = strategy;
134
  frame.DLC = 1;
135
  this->transmitMessage(&frame);
136
}
137

  
118 138
void PowerManagement::periodicBroadcast() {
119 139
  CANTxFrame frame;
120 140
  if (this->bc_counter % 10 == 0) {
......
127 147
    frame.DLC = 6;
128 148
    this->transmitMessage(&frame);
129 149
  }
150

  
130 151
  for (int i = 0; i < 8; i++) {
131 152
    frame.SID = 0;
132 153
    this->encodeDeviceId(&frame, CAN::PROXIMITY_RING_ID(i));
devices/PowerManagement/PowerManagement.h
24 24

  
25 25
    /** \brief Handle the start of ControllerAreaNetworkTx and ControllerAreaNetworkRx threads */
26 26
    ThreadReference start(tprio_t PRIO);
27
    void setStrategy(uint8_t strategy);
27 28

  
28 29
    types::power_status& getPowerStatus();
29 30

  
......
31 32
    virtual msg_t receiveMessage(CANRxFrame *frame);
32 33
    virtual msg_t updateSensorVal();
33 34
    virtual void periodicBroadcast();
34

  
35
    
35 36
    void  calibrateProximityRingValues();
36 37

  
37 38
  private:

Also available in: Unified diff