An embedded server sending sensor information over the network to a remote client side process parsing the data
Dependencies: EthernetInterface NTPClient TimeInterface WebSocketClient mbed-rtos mbed ST_Events-old
data_logger.h@6:b59d85d0e67d, 2017-09-17 (annotated)
- Committer:
- thedude35
- Date:
- Sun Sep 17 20:49:09 2017 +0000
- Revision:
- 6:b59d85d0e67d
- Parent:
- 3:221997836268
Updated server port to be outside of the "well known port number" range
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
thedude35 | 2:5c9125d3ddae | 1 | #include "mbed.h" |
thedude35 | 2:5c9125d3ddae | 2 | #include "EthernetInterface.h" |
thedude35 | 2:5c9125d3ddae | 3 | #include "NTPClient.h" |
thedude35 | 2:5c9125d3ddae | 4 | #include "TimeInterface.h" |
thedude35 | 2:5c9125d3ddae | 5 | #include "rtos.h" |
thedude35 | 2:5c9125d3ddae | 6 | #include "Timer.h" |
thedude35 | 2:5c9125d3ddae | 7 | #include "mbed_events.h" |
thedude35 | 6:b59d85d0e67d | 8 | #define SERVER_PORT 2073 |
thedude35 | 2:5c9125d3ddae | 9 | #define RATE 10000 |
thedude35 | 3:221997836268 | 10 | #define NOMINAL_R 350 //In Ohms |
thedude35 | 3:221997836268 | 11 | #define GAUGE_FACTOR 2.1 |
thedude35 | 3:221997836268 | 12 | #define CURRENT 2 //In amps |
thedude35 | 2:5c9125d3ddae | 13 | |
thedude35 | 3:221997836268 | 14 | int data = 711; //Example test data to be sent across the network |
thedude35 | 2:5c9125d3ddae | 15 | int i = 0; |
thedude35 | 3:221997836268 | 16 | char appbuffer[105]; //Application buffer |
thedude35 | 3:221997836268 | 17 | int len = 105; //Length of the buffer |
thedude35 | 2:5c9125d3ddae | 18 | float cycle_time; |
thedude35 | 2:5c9125d3ddae | 19 | int p_press = 0; |
thedude35 | 2:5c9125d3ddae | 20 | int id_press = 0; |
thedude35 | 3:221997836268 | 21 | float p_strain = 0; |
thedude35 | 3:221997836268 | 22 | float id_strain = 0; |
thedude35 | 3:221997836268 | 23 | |
thedude35 | 2:5c9125d3ddae | 24 | |
thedude35 | 2:5c9125d3ddae | 25 | //int samples[]; |
thedude35 | 2:5c9125d3ddae | 26 | |
thedude35 | 2:5c9125d3ddae | 27 | void cycle_time_isr_rise(void); |
thedude35 | 2:5c9125d3ddae | 28 | //ISR on the rising edge of the digital input starting the cycle timer and stopping the periodic reporting thread |
thedude35 | 2:5c9125d3ddae | 29 | |
thedude35 | 2:5c9125d3ddae | 30 | void cycle_time_isr_fall(void); |
thedude35 | 2:5c9125d3ddae | 31 | //ISR on the falling edge of the digital input stopping the cycle timer and restarting the periodic reporting thread |
thedude35 | 2:5c9125d3ddae | 32 | |
thedude35 | 3:221997836268 | 33 | void idle_report(void); |
thedude35 | 3:221997836268 | 34 | //sends the XML markup payload while the machine is idle |
thedude35 | 3:221997836268 | 35 | |
thedude35 | 3:221997836268 | 36 | float strainCalc(void); |
thedude35 | 3:221997836268 | 37 | //Calculate the strain from the analog input signal received from the strain gauge |
thedude35 | 3:221997836268 | 38 | |
thedude35 | 3:221997836268 | 39 |