RTno is communicating library and framework which allows you to make your embedded device capable of communicating with RT-middleware world. RT-middleware is a platform software to realize Robotic system. In RTM, robots are developed by constructing robotics technologies\' elements (components) named RT-component. Therefore, the RTno helps you to create your own RT-component with your mbed and arduino. To know how to use your RTno device, visit here: http://ysuga.net/robot_e/rtm_e/rtc_e/1065?lang=en To know about RT-middleware and RT-component, visit http://www.openrtm.org

Dependencies:   EthernetInterface mbed-rtos

Committer:
ysuga
Date:
Thu Aug 29 05:29:55 2013 +0000
Revision:
7:6c7af1d50fb3
Parent:
0:5f7bc45bc2e8
update v5

Who changed what in which revision?

UserRevisionLine numberNew contents of line
ysuga 0:5f7bc45bc2e8 1 #ifndef INPORT_HEADER_INCLUDED
ysuga 0:5f7bc45bc2e8 2 #define INPORT_HEADER_INCLUDED
ysuga 0:5f7bc45bc2e8 3
ysuga 0:5f7bc45bc2e8 4 /*******************************************
ysuga 0:5f7bc45bc2e8 5 * InPort.h
ysuga 0:5f7bc45bc2e8 6 * @author Yuki Suga
ysuga 0:5f7bc45bc2e8 7 * @copyright Yuki Suga (ysuga.net) Nov, 10th, 2010.
ysuga 0:5f7bc45bc2e8 8 * @license LGPLv3
ysuga 0:5f7bc45bc2e8 9 *****************************************/
ysuga 0:5f7bc45bc2e8 10
ysuga 0:5f7bc45bc2e8 11 #include <stdint.h>
ysuga 0:5f7bc45bc2e8 12 #include "PortBase.h"
ysuga 0:5f7bc45bc2e8 13 #include "NullBuffer.h"
ysuga 0:5f7bc45bc2e8 14 #include <string.h>
ysuga 0:5f7bc45bc2e8 15 #include <stdlib.h>
ysuga 0:5f7bc45bc2e8 16
ysuga 0:5f7bc45bc2e8 17 class InPortBase : public PortBase{
ysuga 0:5f7bc45bc2e8 18 private:
ysuga 0:5f7bc45bc2e8 19
ysuga 0:5f7bc45bc2e8 20 public:
ysuga 0:5f7bc45bc2e8 21 InPortBase(char* name, char tCode) {
ysuga 0:5f7bc45bc2e8 22 PortBase_init(this, name, tCode, NullBuffer_create());
ysuga 0:5f7bc45bc2e8 23 }
ysuga 0:5f7bc45bc2e8 24
ysuga 0:5f7bc45bc2e8 25 public:
ysuga 0:5f7bc45bc2e8 26
ysuga 0:5f7bc45bc2e8 27 };
ysuga 0:5f7bc45bc2e8 28
ysuga 0:5f7bc45bc2e8 29 template<typename T>
ysuga 0:5f7bc45bc2e8 30 class InPort : public InPortBase {
ysuga 0:5f7bc45bc2e8 31 public:
ysuga 0:5f7bc45bc2e8 32 T* m_pData;
ysuga 0:5f7bc45bc2e8 33 public:
ysuga 0:5f7bc45bc2e8 34 InPort(char* name, T& data) : InPortBase(name, data.typeCode) {
ysuga 0:5f7bc45bc2e8 35 m_pData = &data;
ysuga 0:5f7bc45bc2e8 36 }
ysuga 0:5f7bc45bc2e8 37
ysuga 0:5f7bc45bc2e8 38 ~InPort() {}
ysuga 0:5f7bc45bc2e8 39 public:
ysuga 0:5f7bc45bc2e8 40 uint8_t isNew() {
ysuga 0:5f7bc45bc2e8 41 return pPortBuffer->hasNext(pPortBuffer);
ysuga 0:5f7bc45bc2e8 42 }
ysuga 0:5f7bc45bc2e8 43
ysuga 0:5f7bc45bc2e8 44 uint8_t read() {
ysuga 0:5f7bc45bc2e8 45 uint8_t dataSize = pPortBuffer->getNextDataSize(pPortBuffer);
ysuga 0:5f7bc45bc2e8 46 if(TypeCode_isSequence(m_pData->typeCode)) {
ysuga 0:5f7bc45bc2e8 47 ((SequenceBase*)&(m_pData->data))->length(dataSize/TypeCode_getElementSize(m_pData->typeCode));
ysuga 0:5f7bc45bc2e8 48 pPortBuffer->pop(pPortBuffer, (int8_t*)((SequenceBase*)&(m_pData->data))->getData(), dataSize);
ysuga 0:5f7bc45bc2e8 49 } else {
ysuga 0:5f7bc45bc2e8 50 // This code must be okay for little endian system.
ysuga 0:5f7bc45bc2e8 51 pPortBuffer->pop(pPortBuffer, (int8_t*)&(m_pData->data), dataSize);
ysuga 0:5f7bc45bc2e8 52 }
ysuga 0:5f7bc45bc2e8 53 return dataSize;
ysuga 0:5f7bc45bc2e8 54 }
ysuga 0:5f7bc45bc2e8 55
ysuga 0:5f7bc45bc2e8 56 };
ysuga 0:5f7bc45bc2e8 57
ysuga 0:5f7bc45bc2e8 58
ysuga 0:5f7bc45bc2e8 59
ysuga 0:5f7bc45bc2e8 60 #endif