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
Diff: RTno.cpp
- Revision:
- 1:f74116b37bc9
- Parent:
- 0:5f7bc45bc2e8
diff -r 5f7bc45bc2e8 -r f74116b37bc9 RTno.cpp --- a/RTno.cpp Mon Jun 24 06:42:11 2013 +0000 +++ b/RTno.cpp Mon Jul 08 07:14:30 2013 +0000 @@ -21,10 +21,7 @@ // module private variables. #define PRIVATE static -// static value declaration. -void(*SerialDevice_putc)(const char c); -uint8_t(*SerialDevice_available)(); -char(*SerialDevice_getc)(); +extern DigitalOut led3; PRIVATE int8_t m_pPacketBuffer[PACKET_BUFFER_SIZE]; @@ -71,16 +68,16 @@ } } - /** * Arduino Loop routine. * This function is repeadedly called when arduino is turned on. */ void loop() { int8_t ret; - ret = Transport_ReceivePacket(m_pPacketBuffer); + int32_t timeout = 20*1000; + ret = Transport_ReceivePacket((uint8_t*)m_pPacketBuffer, timeout); if(ret < 0) { // Timeout Error or Checksum Error - Transport_SendPacket(PACKET_ERROR, 1, &ret); + Transport_SendPacket(PACKET_ERROR, 1, (int8_t*)&ret); } else if (ret == 0) { } else if (ret > 0) { // Packet is successfully received if (m_pPacketBuffer[INTERFACE] == GET_PROFILE) { @@ -94,17 +91,17 @@ } else { switch(EC_get_component_state()) { case RTC_STATE_ERROR: - _PacketHandlerOnError(); - break; + _PacketHandlerOnError(); + break; case RTC_STATE_INACTIVE: - _PacketHandlerOnInactive(); - break; + _PacketHandlerOnInactive(); + break; case RTC_STATE_ACTIVE: - _PacketHandlerOnActive(); - break; + _PacketHandlerOnActive(); + break; case RTC_STATE_NONE: - ret = RTNO_NONE; - Transport_SendPacket(m_pPacketBuffer[INTERFACE], 1, &ret); + ret = RTNO_NONE; + Transport_SendPacket(m_pPacketBuffer[INTERFACE], 1, (int8_t*)&ret); break; default: // if m_Condition is unknown... @@ -226,15 +223,16 @@ Transport_SendPacket(EXECUTE, 1, &ret); break; case SEND_DATA: { - PortBase* pInPort = RTnoProfile_getInPort((const char*)&(m_pPacketBuffer[DATA_START_ADDR+2]), m_pPacketBuffer[DATA_START_ADDR]); + PortBase* pInPort = RTnoProfile_getInPort((char*)m_pPacketBuffer + 2 + 2, m_pPacketBuffer[2]); if(pInPort == NULL) { - + ret = RTNO_ERROR; + Transport_SendPacket(SEND_DATA, 1, &ret); } else { - PortBuffer* pBuffer = pInPort->pPortBuffer; - EC_suspend(); - pBuffer->push(pBuffer,&(m_pPacketBuffer[DATA_START_ADDR+2+m_pPacketBuffer[DATA_START_ADDR]]), m_pPacketBuffer[DATA_START_ADDR+1]); - EC_resume(); - Transport_SendPacket(SEND_DATA, 1, &ret); + PortBuffer* pBuffer = pInPort->pPortBuffer; + EC_suspend(); + pBuffer->push(pBuffer,&(m_pPacketBuffer[2 + 2 + m_pPacketBuffer[2]]), m_pPacketBuffer[2+1]); + EC_resume(); + Transport_SendPacket(SEND_DATA, 1, &ret); } } break;