STAR
Cal STAR — firmware, DAQ server, and engine design
Loading...
Searching...
No Matches
main.cpp File Reference
#include <Arduino.h>
#include <Ethernet.h>
#include <EthernetUdp.h>
#include <SPI.h>
#include <daq-protocol.h>
#include <esp_mac.h>
#include <cstring>
#include <vector>
#include "actuator_board_pins.h"
Include dependency graph for main.cpp:

Go to the source code of this file.

Functions

static const char * packetTypeName (uint8_t t)
void printReceivedPacket (const uint8_t *buf, size_t len, IPAddress fromIP, uint16_t fromPort)
void sendSensorPacket ()
void setup ()
void loop ()

Variables

byte mac [6]
 Multi-Board Comms Testing - PRIMARY.
IPAddress staticIP (192, 168, 2, 100)
IPAddress gateway (192, 168, 2, 1)
IPAddress subnet (255, 255, 255, 0)
IPAddress dns (192, 168, 2, 1)
IPAddress secondaryIP (192, 168, 2, 101)
const int secondaryPort = 5006
const int localPort = 5005
EthernetUDP udp
uint8_t packetBuffer [MAX_PACKET_SIZE]
const uint8_t NUM_SENSORS = 2
const unsigned long SEND_INTERVAL_MS = 1000
unsigned long lastSendMs = 0

Function Documentation

◆ loop()

void loop ( )

◆ packetTypeName()

const char * packetTypeName ( uint8_t t)
static

◆ printReceivedPacket()

void printReceivedPacket ( const uint8_t * buf,
size_t len,
IPAddress fromIP,
uint16_t fromPort )

Definition at line 77 of file main.cpp.

References packetTypeName(), and Serial.

Referenced by loop().

◆ sendSensorPacket()

void sendSensorPacket ( )

◆ setup()

void setup ( void )

Variable Documentation

◆ dns

IPAddress dns(192, 168, 2, 1) ( 192 ,
168 ,
2 ,
1  )

◆ gateway

IPAddress gateway(192, 168, 2, 1) ( 192 ,
168 ,
2 ,
1  )

◆ lastSendMs

unsigned long lastSendMs = 0

Definition at line 47 of file main.cpp.

Referenced by loop().

◆ localPort

const int localPort = 5005

Definition at line 37 of file main.cpp.

◆ mac

byte mac[6]

Multi-Board Comms Testing - PRIMARY.

Sends SENSOR_DATA packets to the secondary board (192.168.2.101:5006), receives reply SENSOR_DATA packets on port 5005, and prints both sent and received packets to Serial.

Uses: Arduino Ethernet, EthernetUDP, DAQv2-Comms (sensor packet format).

Definition at line 29 of file main.cpp.

◆ NUM_SENSORS

const uint8_t NUM_SENSORS = 2

Definition at line 45 of file main.cpp.

◆ packetBuffer

uint8_t packetBuffer[MAX_PACKET_SIZE]

Definition at line 40 of file main.cpp.

◆ secondaryIP

IPAddress secondaryIP(192, 168, 2, 101) ( 192 ,
168 ,
2 ,
101  )

Referenced by sendSensorPacket().

◆ secondaryPort

const int secondaryPort = 5006

Definition at line 36 of file main.cpp.

Referenced by sendSensorPacket().

◆ SEND_INTERVAL_MS

const unsigned long SEND_INTERVAL_MS = 1000

Definition at line 46 of file main.cpp.

Referenced by loop().

◆ staticIP

IPAddress staticIP(192, 168, 2, 100) ( 192 ,
168 ,
2 ,
100  )

◆ subnet

IPAddress subnet(255, 255, 255, 0) ( 255 ,
255 ,
255 ,
0  )

◆ udp

EthernetUDP udp

Definition at line 39 of file main.cpp.