|
STAR
Cal STAR — firmware, DAQ server, and engine design
|
#include <Arduino.h>#include <Ethernet.h>#include <EthernetUdp.h>#include <SPI.h>#include <daq-protocol.h>#include <esp_mac.h>#include <cstring>#include "actuator_board_pins.h"Go to the source code of this file.
Classes | |
| struct | PWMState |
Functions | |
| void | initializeActuators () |
| void | processActuatorCommand (const std::vector< daq::ActuatorCommand > &commands) |
| void | processPWMActuatorCommand (const std::vector< daq::PWMActuatorCommand > &commands) |
| void | updatePWM () |
| void | readCurrentSensePins () |
| void | sendSensorDataPacket (const daq::SensorDataChunkCollection &chunk) |
| void | setup () |
| void | loop () |
Variables | |
| const unsigned long | ADC_READ_INTERVAL_MS |
| byte | mac [6] |
| IPAddress | staticIP (192, 168, 2, 202) |
| IPAddress | gateway (0, 0, 0, 0) |
| IPAddress | subnet (255, 255, 255, 0) |
| IPAddress | dns (192, 168, 2, 1) |
| const int | udpPort = 5005 |
| IPAddress | receiverIP (192, 168, 2, 20) |
| const int | receiverPort = 5006 |
| EthernetUDP | udp |
| uint8_t | actuator_states [NUM_ACTUATORS] |
| PWMState | pwm_states [NUM_ACTUATORS] |
| const uint8_t | NUM_SENSORS = NUM_ACTUATORS |
| unsigned long | lastAdcReadTime = 0 |
| void initializeActuators | ( | ) |
Definition at line 194 of file main.cpp.
References actuator_states, digitalWrite(), actuator_board_pins::getActuatorPin(), LOW, actuator_board_pins::NUM_ACTUATORS, OUTPUT, pinMode(), pwm_states, and Serial.
Referenced by setup().
| void loop | ( | ) |
Definition at line 130 of file main.cpp.
References daq::ACTUATOR_COMMAND, ADC_READ_INTERVAL_MS, commands, lastAdcReadTime, MAX_PACKET_SIZE, millis(), packetBuffer, daq::parse_actuator_command_packet(), daq::parse_pwm_actuator_packet(), processActuatorCommand(), processPWMActuatorCommand(), daq::PWM_ACTUATOR_COMMAND, readCurrentSensePins(), Serial, udp, and updatePWM().
| void processActuatorCommand | ( | const std::vector< daq::ActuatorCommand > & | commands | ) |
Definition at line 229 of file main.cpp.
References active, actuator_states, array_index(), commands, digitalWrite(), actuator_board_pins::getActuatorPin(), HIGH, LOW, actuator_board_pins::NUM_ACTUATORS, pwm_states, and Serial.
Referenced by loop().
| void processPWMActuatorCommand | ( | const std::vector< daq::PWMActuatorCommand > & | commands | ) |
Definition at line 282 of file main.cpp.
References actuator_states, array_index(), commands, actuator_board_pins::getActuatorPin(), millis(), actuator_board_pins::NUM_ACTUATORS, pwm_states, and Serial.
Referenced by loop().
| void readCurrentSensePins | ( | ) |
Definition at line 372 of file main.cpp.
References analogRead(), chunk, actuator_board_pins::getCurrentSensePin(), millis(), NUM_SENSORS, sendSensorDataPacket(), and Serial.
Referenced by loop().
| void sendSensorDataPacket | ( | const daq::SensorDataChunkCollection & | chunk | ) |
Definition at line 406 of file main.cpp.
References chunk, chunks, daq::create_sensor_data_packet(), MAX_PACKET_SIZE, millis(), NUM_SENSORS, packetBuffer, receiverIP, receiverPort, Serial, and udp.
| void setup | ( | void | ) |
Definition at line 56 of file main.cpp.
References actuator_board_pins::Actuator_Board, delay(), dns, Ethernet, gateway, actuator_board_pins::getCurrentSensePin(), HEX, initializeActuators(), INPUT, mac, NUM_SENSORS, pinMode(), Serial, staticIP, subnet, udp, and udpPort.
| void updatePWM | ( | ) |
Definition at line 347 of file main.cpp.
References active, actuator_states, digitalWrite(), actuator_board_pins::getActuatorPin(), LOW, millis(), actuator_board_pins::NUM_ACTUATORS, pwm_states, and Serial.
Referenced by loop().
| uint8_t actuator_states[NUM_ACTUATORS] |
| const unsigned long ADC_READ_INTERVAL_MS |
| IPAddress dns(192, 168, 2, 1) | ( | 192 | , |
| 168 | , | ||
| 2 | , | ||
| 1 | ) |
| IPAddress gateway(0, 0, 0, 0) | ( | 0 | , |
| 0 | , | ||
| 0 | , | ||
| 0 | ) |
| const uint8_t NUM_SENSORS = NUM_ACTUATORS |
| PWMState pwm_states[NUM_ACTUATORS] |
Definition at line 41 of file main.cpp.
Referenced by initializeActuators(), initializePWMStates(), processActuatorCommand(), processActuatorCommands(), processPWMActuatorCommand(), processPWMActuatorCommand(), updatePWM(), and updatePWM().
| IPAddress receiverIP(192, 168, 2, 20) | ( | 192 | , |
| 168 | , | ||
| 2 | , | ||
| 20 | ) |
Referenced by loop(), printBoardInfo(), sendExampleMessage(), sendHeartbeatPacket(), sendSensorDataPacket(), sendSensorDataPacket(), and setup().
| const int receiverPort = 5006 |
Definition at line 26 of file main.cpp.
Referenced by loop(), printBoardInfo(), sendExampleMessage(), sendHeartbeatPacket(), sendSensorDataPacket(), sendSensorDataPacket(), and setup().
| IPAddress staticIP(192, 168, 2, 202) | ( | 192 | , |
| 168 | , | ||
| 2 | , | ||
| 202 | ) |
| IPAddress subnet(255, 255, 255, 0) | ( | 255 | , |
| 255 | , | ||
| 255 | , | ||
| 0 | ) |