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

Go to the source code of this file.

Macros

#define ETH_CLK_PIN   39
#define ETH_MISO_PIN   41
#define ETH_MOSI_PIN   40
#define ETH_CS_PIN   38

Functions

void setup ()
void printBoardInfo ()
 Prints all board networking information to Serial.
void sendExampleMessage ()
 Sends an example message in the old format (string-based) This is the original implementation for testing basic UDP communication.
bool sendHeartbeatPacket ()
 Creates and sends a Board Heartbeat packet using DiabloComms library This uses the proper packet encoding format defined in the DAQv2-Comms library.
void startHeartbeatLoop ()
 Continuously sends heartbeat packets until user cancels Checks for Serial input to allow cancellation.
void printMenu ()
 Prints the CLI menu options.
void processCLI ()
 Processes CLI commands from Serial input.
void loop ()

Variables

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 receiverIP (192, 168, 2, 20)
const int receiverPort = 5006
EthernetUDP udp
byte mac [] = {0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED}

Macro Definition Documentation

◆ ETH_CLK_PIN

#define ETH_CLK_PIN   39

Definition at line 8 of file main.cpp.

◆ ETH_CS_PIN

#define ETH_CS_PIN   38

Definition at line 11 of file main.cpp.

◆ ETH_MISO_PIN

#define ETH_MISO_PIN   41

Definition at line 9 of file main.cpp.

◆ ETH_MOSI_PIN

#define ETH_MOSI_PIN   40

Definition at line 10 of file main.cpp.

Function Documentation

◆ loop()

void loop ( )

Definition at line 258 of file main.cpp.

References delay(), and processCLI().

◆ printBoardInfo()

void printBoardInfo ( )

Prints all board networking information to Serial.

Definition at line 61 of file main.cpp.

References dns, Ethernet, gateway, HEX, mac, receiverIP, receiverPort, Serial, and subnet.

◆ printMenu()

void printMenu ( )

Prints the CLI menu options.

Definition at line 219 of file main.cpp.

References Serial.

Referenced by processCLI(), and setup().

◆ processCLI()

void processCLI ( )

Processes CLI commands from Serial input.

Definition at line 231 of file main.cpp.

References printBoardInfo(), printMenu(), Serial, and startHeartbeatLoop().

Referenced by loop().

◆ sendExampleMessage()

void sendExampleMessage ( )

Sends an example message in the old format (string-based) This is the original implementation for testing basic UDP communication.

Definition at line 114 of file main.cpp.

References millis(), receiverIP, receiverPort, Serial, and udp.

◆ sendHeartbeatPacket()

bool sendHeartbeatPacket ( )

Creates and sends a Board Heartbeat packet using DiabloComms library This uses the proper packet encoding format defined in the DAQv2-Comms library.

Returns
true if packet was sent successfully, false otherwise

Definition at line 140 of file main.cpp.

References daq::ACTIVE, daq::create_board_heartbeat_packet(), MAX_PACKET_SIZE, millis(), packetBuffer, receiverIP, receiverPort, daq::SAFE, Serial, and udp.

Referenced by startHeartbeatLoop().

◆ setup()

void setup ( void )

◆ startHeartbeatLoop()

void startHeartbeatLoop ( )

Continuously sends heartbeat packets until user cancels Checks for Serial input to allow cancellation.

Definition at line 179 of file main.cpp.

References delay(), millis(), sendHeartbeatPacket(), and Serial.

Referenced by processCLI().

Variable Documentation

◆ dns

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

◆ gateway

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

◆ mac

byte mac[] = {0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED}

Definition at line 21 of file main.cpp.

◆ receiverIP

IPAddress receiverIP(192, 168, 2, 20) ( 192 ,
168 ,
2 ,
20  )

◆ receiverPort

const int receiverPort = 5006

Definition at line 18 of file main.cpp.

◆ 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 19 of file main.cpp.