Statistics
| Branch: | Tag: | Revision:

amiro-os / include / amiro / ControllerAreaNetworkRx.h @ 3f899f5d

History | View | Annotate | Download (1.479 KB)

1 58fe0e0b Thomas Schöpping
#ifndef AMIRO_CONTROLLER_AREA_NETWORK_RX_H_
2
#define AMIRO_CONTROLLER_AREA_NETWORK_RX_H_
3
4
#include <evtimer.h>
5
#include <amiro/Color.h>
6
#include <Types.h>  // ::kinematic
7
8
#include <amiro/Constants.h>  // CAN::* macros
9
10
namespace amiro {
11
12
  class ControllerAreaNetworkRx : public chibios_rt::BaseStaticThread<128> {
13
  public:
14
    ControllerAreaNetworkRx(CANDriver *can, const uint8_t boardId);
15
    virtual ~ControllerAreaNetworkRx() = 0;
16
17
    uint16_t getProximityRingValue(int index);
18
    uint16_t getProximityFloorValue(int index);
19
    void getActualSpeed(types::kinematic &targetSpeed);
20
    types::position getOdometry();
21
    types::power_status& getPowerStatus();
22
    uint8_t getRobotID();
23
24
    void calibrateProximityRingValues();
25
    void calibrateProximityFloorValues();
26
27
    int rxCmdShell(CANRxFrame *frame);
28
29
  protected:
30
    virtual msg_t main();
31
    virtual msg_t receiveMessage(CANRxFrame *frame);
32
33
    int decodeBoardId(CANRxFrame *frame);
34
    int decodeDeviceId(CANRxFrame *frame);
35
    int decodeIndexId(CANRxFrame *frame);
36
37
    int boardId;
38
    uint16_t proximityRingValue[8];
39
    int actualSpeed[2];
40
    uint16_t proximityFloorValue[4];
41
    types::position robotPosition;
42
    types::power_status powerStatus;
43
    uint8_t robotId;
44
    chibios_rt::EvtListener rxFullCanEvtListener;
45
    chibios_rt::EvtSource *rxFullCanEvtSource;
46
47
  private:
48
    msg_t receiveSensorVal(CANRxFrame *frame);
49
50
    CANDriver *canDriver;
51
    CANConfig canConfig;
52
53
  };
54
55
}
56
57
#endif /* AMIRO_CONTROLLER_AREA_NETWORK_RX_H_ */