Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: mbed SimpleSerialProtocol MODSERIAL
TestProtocol.h@6:d33e929ebaa9, 2012-07-29 (annotated)
- Committer:
- p3p
- Date:
- Sun Jul 29 19:31:31 2012 +0000
- Revision:
- 6:d33e929ebaa9
- Parent:
- 5:f693f68e9de6
- Child:
- 10:f6862abba2d5
Dma tests removed
Who changed what in which revision?
| User | Revision | Line number | New contents of line |
|---|---|---|---|
| p3p |
4:c0a69c32d054 | 1 | #ifndef _TEST_PROTOCOL_H |
| p3p |
4:c0a69c32d054 | 2 | #define _TEST_PROTOCOL_H |
| p3p |
4:c0a69c32d054 | 3 | |
| p3p |
4:c0a69c32d054 | 4 | #include <mbed.h> |
| p3p |
4:c0a69c32d054 | 5 | #include <SimpleSerialProtocol/Protocol.h> |
| p3p |
4:c0a69c32d054 | 6 | |
| p3p |
4:c0a69c32d054 | 7 | //class will receive a packet and echo it back out |
| p3p |
4:c0a69c32d054 | 8 | class TestProtocol : public SimpleSerialProtocol::Protocol { |
| p3p |
4:c0a69c32d054 | 9 | public: |
| p3p | 5:f693f68e9de6 | 10 | TestProtocol() : Protocol(USBTX, USBRX, LED1) { //LED1 to 4 for a status led, NC to disable |
| p3p | 5:f693f68e9de6 | 11 | receiveCallback(1, this, &TestProtocol::onEchoPacket); |
| p3p |
4:c0a69c32d054 | 12 | } |
| p3p |
4:c0a69c32d054 | 13 | virtual ~TestProtocol() {}; |
| p3p | 5:f693f68e9de6 | 14 | void onEchoPacket(SimpleSerialProtocol::Packet* packet); |
| p3p |
4:c0a69c32d054 | 15 | void reply(); |
| p3p |
4:c0a69c32d054 | 16 | |
| p3p |
4:c0a69c32d054 | 17 | class EchoPacket : public SimpleSerialProtocol::Packet { |
| p3p |
4:c0a69c32d054 | 18 | public: |
| p3p |
4:c0a69c32d054 | 19 | EchoPacket() {} |
| p3p |
4:c0a69c32d054 | 20 | virtual ~EchoPacket() {} |
| p3p |
4:c0a69c32d054 | 21 | |
| p3p |
4:c0a69c32d054 | 22 | #pragma pack(push, 1) //must pack the structure to byte boundary for raw recast to work reliably |
| p3p |
4:c0a69c32d054 | 23 | struct Interface { |
| p3p |
4:c0a69c32d054 | 24 | Interface() { |
| p3p |
4:c0a69c32d054 | 25 | type = 1; // initialise the type |
| p3p |
4:c0a69c32d054 | 26 | } |
| p3p |
4:c0a69c32d054 | 27 | uint8_t type; |
| p3p |
4:c0a69c32d054 | 28 | uint8_t data; |
| p3p |
4:c0a69c32d054 | 29 | uint16_t datashort; |
| p3p |
4:c0a69c32d054 | 30 | uint32_t dataint; |
| p3p |
4:c0a69c32d054 | 31 | float datafloat; |
| p3p |
4:c0a69c32d054 | 32 | } interface; |
| p3p |
4:c0a69c32d054 | 33 | #pragma pack(pop) |
| p3p |
4:c0a69c32d054 | 34 | |
| p3p |
4:c0a69c32d054 | 35 | }; |
| p3p |
4:c0a69c32d054 | 36 | |
| p3p |
4:c0a69c32d054 | 37 | uint8_t temp; |
| p3p |
4:c0a69c32d054 | 38 | short temp1; |
| p3p |
4:c0a69c32d054 | 39 | int temp2; |
| p3p |
4:c0a69c32d054 | 40 | float temp3; |
| p3p |
4:c0a69c32d054 | 41 | }; |
| p3p |
4:c0a69c32d054 | 42 | |
| p3p |
4:c0a69c32d054 | 43 | #endif |