Ethernet test for ECE 4180 and others to find your IP address and do a simple HTTP GET request over port 80.

Dependencies:   mbed Socket lwip-eth lwip-sys lwip

Committer:
mkersh3
Date:
Thu Apr 04 05:26:09 2013 +0000
Revision:
0:e7ca326e76ee
Ethernet Test for ECE4180 and others to find their IP Address and do a simple HTTP GET request over port 80.

Who changed what in which revision?

UserRevisionLine numberNew contents of line
mkersh3 0:e7ca326e76ee 1 /* Copyright (c) 2012 mbed.org */
mkersh3 0:e7ca326e76ee 2 #ifndef QUEUE_H
mkersh3 0:e7ca326e76ee 3 #define QUEUE_H
mkersh3 0:e7ca326e76ee 4
mkersh3 0:e7ca326e76ee 5 #include <stdint.h>
mkersh3 0:e7ca326e76ee 6 #include <string.h>
mkersh3 0:e7ca326e76ee 7
mkersh3 0:e7ca326e76ee 8 #include "cmsis_os.h"
mkersh3 0:e7ca326e76ee 9 #include "error.h"
mkersh3 0:e7ca326e76ee 10
mkersh3 0:e7ca326e76ee 11 namespace rtos {
mkersh3 0:e7ca326e76ee 12
mkersh3 0:e7ca326e76ee 13 /*! The Queue class allow to control, send, receive, or wait for messages.
mkersh3 0:e7ca326e76ee 14 A message can be a integer or pointer value to a certain type T that is send
mkersh3 0:e7ca326e76ee 15 to a thread or interrupt service routine.
mkersh3 0:e7ca326e76ee 16 \tparam T data type of a single message element.
mkersh3 0:e7ca326e76ee 17 \tparam queue_sz maximum number of messages in queue.
mkersh3 0:e7ca326e76ee 18 */
mkersh3 0:e7ca326e76ee 19 template<typename T, uint32_t queue_sz>
mkersh3 0:e7ca326e76ee 20 class Queue {
mkersh3 0:e7ca326e76ee 21 public:
mkersh3 0:e7ca326e76ee 22 /*! Create and initialise a message Queue. */
mkersh3 0:e7ca326e76ee 23 Queue() {
mkersh3 0:e7ca326e76ee 24 #ifdef CMSIS_OS_RTX
mkersh3 0:e7ca326e76ee 25 memset(_queue_q, 0, sizeof(_queue_q));
mkersh3 0:e7ca326e76ee 26 _queue_def.pool = _queue_q;
mkersh3 0:e7ca326e76ee 27 _queue_def.queue_sz = queue_sz;
mkersh3 0:e7ca326e76ee 28 #endif
mkersh3 0:e7ca326e76ee 29 _queue_id = osMessageCreate(&_queue_def, NULL);
mkersh3 0:e7ca326e76ee 30 if (_queue_id == NULL) {
mkersh3 0:e7ca326e76ee 31 error("Error initialising the queue object\n");
mkersh3 0:e7ca326e76ee 32 }
mkersh3 0:e7ca326e76ee 33 }
mkersh3 0:e7ca326e76ee 34
mkersh3 0:e7ca326e76ee 35 /*! Put a message in a Queue.
mkersh3 0:e7ca326e76ee 36 \param data message pointer.
mkersh3 0:e7ca326e76ee 37 \param millisec timeout value or 0 in case of no time-out. (default: 0)
mkersh3 0:e7ca326e76ee 38 \return status code that indicates the execution status of the function.
mkersh3 0:e7ca326e76ee 39 */
mkersh3 0:e7ca326e76ee 40 osStatus put(T* data, uint32_t millisec=0) {
mkersh3 0:e7ca326e76ee 41 return osMessagePut(_queue_id, (uint32_t)data, millisec);
mkersh3 0:e7ca326e76ee 42 }
mkersh3 0:e7ca326e76ee 43
mkersh3 0:e7ca326e76ee 44 /*! Get a message or Wait for a message from a Queue.
mkersh3 0:e7ca326e76ee 45 \param millisec timeout value or 0 in case of no time-out. (default: osWaitForever).
mkersh3 0:e7ca326e76ee 46 \return event information that includes the message and the status code.
mkersh3 0:e7ca326e76ee 47 */
mkersh3 0:e7ca326e76ee 48 osEvent get(uint32_t millisec=osWaitForever) {
mkersh3 0:e7ca326e76ee 49 return osMessageGet(_queue_id, millisec);
mkersh3 0:e7ca326e76ee 50 }
mkersh3 0:e7ca326e76ee 51
mkersh3 0:e7ca326e76ee 52 private:
mkersh3 0:e7ca326e76ee 53 osMessageQId _queue_id;
mkersh3 0:e7ca326e76ee 54 osMessageQDef_t _queue_def;
mkersh3 0:e7ca326e76ee 55 #ifdef CMSIS_OS_RTX
mkersh3 0:e7ca326e76ee 56 uint32_t _queue_q[4+(queue_sz)];
mkersh3 0:e7ca326e76ee 57 #endif
mkersh3 0:e7ca326e76ee 58 };
mkersh3 0:e7ca326e76ee 59
mkersh3 0:e7ca326e76ee 60 }
mkersh3 0:e7ca326e76ee 61 #endif