work in progress
Experiment - work in progress...
RefRX.h@5:444939b4790a, 2013-07-20 (annotated)
- Committer:
- MatteoT
- Date:
- Sat Jul 20 12:36:22 2013 +0000
- Revision:
- 5:444939b4790a
- Parent:
- 4:87d3a005c4de
test good
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
MatteoT | 0:ac535bde6cd9 | 1 | #ifndef _REFRX_H_ |
MatteoT | 0:ac535bde6cd9 | 2 | #define _REFRX_H_ |
MatteoT | 0:ac535bde6cd9 | 3 | |
MatteoT | 3:9eb188e979ba | 4 | #include <stdint.h> |
MatteoT | 0:ac535bde6cd9 | 5 | #include "mbed.h" |
MatteoT | 0:ac535bde6cd9 | 6 | #include "rtos.h" |
MatteoT | 0:ac535bde6cd9 | 7 | #include "EthernetInterface.h" |
MatteoT | 0:ac535bde6cd9 | 8 | |
MatteoT | 0:ac535bde6cd9 | 9 | /** RefRX class used to receive pilot references with ethernet transmissions. |
MatteoT | 0:ac535bde6cd9 | 10 | * Receive on internally managed UDP socket and controls the transmission |
MatteoT | 0:ac535bde6cd9 | 11 | * with a TCP socket. |
MatteoT | 0:ac535bde6cd9 | 12 | */ |
MatteoT | 0:ac535bde6cd9 | 13 | class RefRX{ |
MatteoT | 3:9eb188e979ba | 14 | static bool _initialized; |
MatteoT | 0:ac535bde6cd9 | 15 | |
MatteoT | 3:9eb188e979ba | 16 | static Mutex _refs_access; |
MatteoT | 3:9eb188e979ba | 17 | static float _ref1; |
MatteoT | 3:9eb188e979ba | 18 | static float _ref2; |
MatteoT | 3:9eb188e979ba | 19 | static float _ref3; |
MatteoT | 3:9eb188e979ba | 20 | static float _ref4; |
MatteoT | 3:9eb188e979ba | 21 | |
MatteoT | 3:9eb188e979ba | 22 | static int _listen_port; |
MatteoT | 3:9eb188e979ba | 23 | static int _destination_control_port; |
MatteoT | 0:ac535bde6cd9 | 24 | |
MatteoT | 5:444939b4790a | 25 | static Thread* _RX_thread; |
MatteoT | 0:ac535bde6cd9 | 26 | |
MatteoT | 0:ac535bde6cd9 | 27 | public: |
MatteoT | 5:444939b4790a | 28 | |
MatteoT | 5:444939b4790a | 29 | /** Thread procedure |
MatteoT | 5:444939b4790a | 30 | */ |
MatteoT | 5:444939b4790a | 31 | static void worker (void const *args); |
MatteoT | 0:ac535bde6cd9 | 32 | |
MatteoT | 0:ac535bde6cd9 | 33 | /** Initialization procedure. |
MatteoT | 0:ac535bde6cd9 | 34 | * @param listen_port |
MatteoT | 0:ac535bde6cd9 | 35 | * @param destination_control_port remote port for the transmission control. |
MatteoT | 0:ac535bde6cd9 | 36 | * @param ref1 pilot references to be overwritten. |
MatteoT | 0:ac535bde6cd9 | 37 | */ |
MatteoT | 5:444939b4790a | 38 | static void init (const int listen_port, const int destination_control_port, Thread & worker_thread); |
MatteoT | 3:9eb188e979ba | 39 | |
MatteoT | 4:87d3a005c4de | 40 | /** Get references and store to parameters. |
MatteoT | 4:87d3a005c4de | 41 | * Involves the use of a Mutex with trylock(). |
MatteoT | 4:87d3a005c4de | 42 | */ |
MatteoT | 3:9eb188e979ba | 43 | static bool get (float &ref1, float &ref2, float &ref3, float &ref4); |
MatteoT | 0:ac535bde6cd9 | 44 | }; |
MatteoT | 0:ac535bde6cd9 | 45 | |
MatteoT | 0:ac535bde6cd9 | 46 | #endif |