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@2:5c9125d3ddae, 2017-07-21 (annotated)
- Committer:
- thedude35
- Date:
- Fri Jul 21 01:56:38 2017 +0000
- Revision:
- 2:5c9125d3ddae
- Child:
- 3:221997836268
Implemented separate threads for periodic reporting and the cycle time interrupt with mutex locking on the application buffer
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 | 2:5c9125d3ddae | 8 | #define SERVER_PORT 7 |
thedude35 | 2:5c9125d3ddae | 9 | #define RATE 10000 |
thedude35 | 2:5c9125d3ddae | 10 | |
thedude35 | 2:5c9125d3ddae | 11 | int data = 711; //Example test data to be sent across the network |
thedude35 | 2:5c9125d3ddae | 12 | int i = 0; |
thedude35 | 2:5c9125d3ddae | 13 | char appbuffer[105]; //Application buffer |
thedude35 | 2:5c9125d3ddae | 14 | int len = 105; //Length of the buffer |
thedude35 | 2:5c9125d3ddae | 15 | float cycle_time; |
thedude35 | 2:5c9125d3ddae | 16 | int p_press = 0; |
thedude35 | 2:5c9125d3ddae | 17 | int id_press = 0; |
thedude35 | 2:5c9125d3ddae | 18 | |
thedude35 | 2:5c9125d3ddae | 19 | //int samples[]; |
thedude35 | 2:5c9125d3ddae | 20 | |
thedude35 | 2:5c9125d3ddae | 21 | void cycle_time_isr_rise(void); |
thedude35 | 2:5c9125d3ddae | 22 | //ISR on the rising edge of the digital input starting the cycle timer and stopping the periodic reporting thread |
thedude35 | 2:5c9125d3ddae | 23 | |
thedude35 | 2:5c9125d3ddae | 24 | void cycle_time_isr_fall(void); |
thedude35 | 2:5c9125d3ddae | 25 | //ISR on the falling edge of the digital input stopping the cycle timer and restarting the periodic reporting thread |
thedude35 | 2:5c9125d3ddae | 26 | |
thedude35 | 2:5c9125d3ddae | 27 | void pressure_report(void); |
thedude35 | 2:5c9125d3ddae | 28 | //sends the XML markup payload with idle hydraulic line pressure data at a prescribed rate |