Skip to content
Snippets Groups Projects

Arduino networking code

Merged Kyrre Ness Sjobaek requested to merge arduinoServer into master
Compare and
9 files
+ 1408
0
Compare changes
  • Side-by-side
  • Inline
Files
9
+ 76
0
/*
* Server for controling 4D robot for moving samples in/out of the beam at CLEAR.
* Access via telnet-like interface at port 23.
*
* Example for accessing over text interface:
* nc 192.168.1.31 23
* Netcat (nc) is the best client: it is a clean TCP client,
* which makes no attempts to negotiate anything.
*
* Kyrre Ness Sjobak, 24 April 2021
* University of Oslo / CERN
*
* Inspired by PositionGaugeServer, also in use at CLEAR.
*/
#include <Arduino.h>
#include <SPI.h>
#include <Ethernet.h>
#include <OneWire.h>
#include <DallasTemperature.h>
#include <Servo.h>
//This file holds all the configurations
// to be modified for deployment
#include "4DrobotServer_config.h"
//This file holds all the global variables
// it does not need to be modified
#include "4DrobotServer_globalVars.h"
void setup() {
//Serial setup, for debugging
Serial.begin(9600);
// wait for serial port to connect. Needed for native USB port only
int serialCounter=0;
while (!Serial) {
//However only wait for 1 second before giving up,
// so that it can work also when not connected to USB
delay(100);
serialCounter++;
if (serialCounter > 10) break;
}
Serial.print('\n');
Serial.print("4DrobotServer initializing...\n");
setup_networkIO();
setup_servo();
setup_stepper();
setup_temperatures();
//Serial is ready for input!
Serial.print(F("@ INFO MSG Say 'HELP' to get started\n"));
}
//Run all the "programs" in order
void loop() {
// Run actuators (one at a time)
servo_control();
stepper_control();
// Update sensor readings
temperatures_update();
// Communicate
telnet_server();
// Housekeeping
#ifdef USE_DHCP
DHCPhousekeeping();
#endif
}
Loading