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
Revision 6:86d72601ff54, committed 2013-08-29
- Comitter:
- ysuga
- Date:
- Thu Aug 29 05:26:09 2013 +0000
- Parent:
- 5:c4f627187f9b
- Child:
- 7:6c7af1d50fb3
- Commit message:
- RTno updt
Changed in this revision
--- a/EtherTcp.cpp Mon Jul 08 13:09:22 2013 +0000 +++ b/EtherTcp.cpp Thu Aug 29 05:26:09 2013 +0000 @@ -1,7 +1,12 @@ #include "mbed.h" +#define RTNO_SUBMODULE_DEFINE +#include "RTno.h" + +#ifdef USE_ETHERNET_CONNECTION + #include "EtherTcp.h" -#include "EthernetNetIf.h" -#include "TCPSocket.h" +#include "EthernetInterface.h" + #include "ip_addr.h" /** @@ -11,16 +16,16 @@ static EthernetServer *m_pServer; static EthernetClient *m_pClient; */ -static EthernetNetIf* m_pInterface; -static TCPSocket* m_pServerSocket; -static TCPSocket* m_pClientSocket; +//static EthernetInterface* m_pInterface; +static TCPSocketServer* m_pServerSocket; +static TCPSocketConnection m_ClientSocket; #define ETCP_RX_BUFFER_SIZE 128 uint8_t etcp_rx_buffer[ETCP_RX_BUFFER_SIZE]; int etcp_rx_buffer_pointer_head = 0; int etcp_rx_buffer_pointer_tail = 0; -Host m_Client; +///Host m_Client; Serial *pSerial; @@ -56,6 +61,7 @@ return size; } +/* static void EtherTcp_onClientEvent(TCPSocketEvent e) { switch (e) { // If the socket is readable, do stuff @@ -88,28 +94,27 @@ m_pClientSocket->setOnEvent(EtherTcp_onClientEvent); } } +*/ -void EtherTcp_init(uint8_t* mac, uint8_t* ip, - uint8_t* gateway, uint8_t* subnet, +void EtherTcp_init(/*const char* mac, */const char* ip, + const char* gateway, const char* subnet, uint16_t port) { pSerial = new Serial(USBTX, USBRX); - m_pInterface = new EthernetNetIf( - IpAddr(ip[0], ip[1], ip[2], ip[3]), - IpAddr(subnet[0], subnet[1], subnet[2], subnet[3]), - IpAddr(gateway[0], gateway[1], gateway[2], gateway[3]), - IpAddr(gateway[0], gateway[1], gateway[2], gateway[3])); - printf("Hello %d %d %d %d\r\n", ip[0], ip[1], ip[2], ip[3]); - EthernetErr ethErr = m_pInterface->setup(); - if (ethErr) { - return; - } + EthernetInterface::init( + ip, subnet, gateway); + //printf("Hello %d %d %d %d\r\n", ip[0], ip[1], ip[2], ip[3]); + //EthernetErr ethErr = m_pInterface->setup(); + //if (ethErr) { + // return; + // } - m_pServerSocket = new TCPSocket(); - m_pServerSocket->setOnEvent(EtherTcp_onServerEvent); - m_pServerSocket->bind(Host(IP_ADDR_ANY, port)); + m_pServerSocket = new TCPSocketServer(); + //m_pServerSocket->setOnEvent(EtherTcp_onServerEvent); + m_pServerSocket->bind(port); m_pServerSocket->listen(); + m_pServerSocket->accept(m_ClientSocket); SerialDevice_available = EtherTcp_available; SerialDevice_getc = EtherTcp_getc; SerialDevice_putc = EtherTcp_putc; @@ -117,20 +122,22 @@ uint8_t EtherTcp_available() { - Net::poll(); + //Net::poll(); return etcp_rx_buffer_get_size(); } void EtherTcp_putc(const char c) { - if(m_pClientSocket != NULL) { - m_pClientSocket->send(&c, 1); + char d = c; + m_ClientSocket.send(&d, 1); } -} uint8_t EtherTcp_getc() { uint8_t c; - etcp_rx_buffer_pop(&c); + m_ClientSocket.receive((char*)&c, 1); + //etcp_rx_buffer_pop(&c); return c; } + +#endif \ No newline at end of file
--- a/EtherTcp.h Mon Jul 08 13:09:22 2013 +0000 +++ b/EtherTcp.h Thu Aug 29 05:26:09 2013 +0000 @@ -5,8 +5,11 @@ #include <stdint.h> #include "SerialDevice.h" -void EtherTcp_init(uint8_t* mac, uint8_t *ip, uint8_t *gateway, uint8_t *subnet, uint16_t port); - +//void EtherTcp_init(uint8_t* mac, uint8_t *ip, uint8_t *gateway, uint8_t *subnet, uint16_t port); +void EtherTcp_init(/*const char* mac, */const char* ip, + const char* gateway, const char* subnet, + uint16_t port) ; + void EtherTcp_putc(const char c); uint8_t EtherTcp_available(); uint8_t EtherTcp_getc();
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/EthernetInterface.lib Thu Aug 29 05:26:09 2013 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/mbed_official/code/EthernetInterface/#3018af573638
--- a/EthernetNetIf.lib Mon Jul 08 13:09:22 2013 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,1 +0,0 @@ -https://mbed.org/users/sherckuith/code/EthernetNetIf/#479ce5546098
--- a/RTno.h Mon Jul 08 13:09:22 2013 +0000 +++ b/RTno.h Thu Aug 29 05:26:09 2013 +0000 @@ -17,7 +17,7 @@ #define USE_UART_CONNECTION -#define USE_ETHERNET_CONNECTION +//#define USE_ETHERNET_CONNECTION #define USE_TIMER1_EC #include "mbed.h" @@ -32,7 +32,7 @@ #ifdef USE_ETHERNET_CONNECTION #include "EtherTcp.h" -#include "EthernetNetIf.h" +#include "EthernetInterface.h" #endif #ifdef USE_TIMER1_EC @@ -132,10 +132,10 @@ switch(conf._default.connection_type) { #ifdef USE_ETHERNET_CONNECTION case ConnectionTypeEtherTcp: - EtherTcp_init((uint8_t*)&conf._default.mac_address, - (uint8_t*)&conf._default.ip_address, - (uint8_t*)&conf._default.default_gateway, - (uint8_t*)&conf._default.subnet_mask, + EtherTcp_init(//(uint8_t*)&conf._default.mac_address, + conf._default.ip_address, + conf._default.default_gateway, + conf._default.subnet_mask, conf._default.port); break; #endif // USE_ETHERNET_CONNECTION @@ -164,9 +164,6 @@ int main(void) { setup(); while(1) { -#ifdef USE_ETHERNET_CONNECTION - Net::poll(); -#endif loop(); } }
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed-rtos.lib Thu Aug 29 05:26:09 2013 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/mbed_official/code/mbed-rtos/#58b30ac3f00e
--- a/rtcconf.h Mon Jul 08 13:09:22 2013 +0000 +++ b/rtcconf.h Thu Aug 29 05:26:09 2013 +0000 @@ -18,9 +18,9 @@ //#ifdef USE_ETHERNET_CONNECTION uint64_t mac_address; uint16_t port; - uint32_t default_gateway; - uint32_t ip_address; - uint32_t subnet_mask; + char* default_gateway; + char* ip_address; + char* subnet_mask; //#endif //#ifdef USE_UART_CONNECTION