PROCESS_THREAD(rs232udp_process, ev, data) {
  PROCESS_BEGIN();

  _network_rs232udp_server_conn = udp_new(NULL, UIP_HTONS(0), NULL);
  udp_bind(_network_rs232udp_server_conn, UIP_HTONS(UDP_PORT));
  
  while (1) {
    PROCESS_WAIT_EVENT_UNTIL(ev == tcpip_event);
    if(uip_newdata()) {
      uip_ipaddr_copy(&_network_rs232udp_last_ip, &UDP_HDR->srcipaddr);
      _network_rs232udp_last_port = UIP_HTONS(UDP_HDR->srcport);
      
      ((char *)uip_appdata)[uip_datalen()] = 0;
      printf("rs232udp %d.%d.%d.%d:%d rx: '%s'\n",
	     _network_rs232udp_last_ip.u8[0],
	     _network_rs232udp_last_ip.u8[1],
	     _network_rs232udp_last_ip.u8[2],
	     _network_rs232udp_last_ip.u8[3],
	     _network_rs232udp_last_port,
	     (char *)uip_appdata);
      rs232_tx((char *)uip_appdata);
    }
  }

  PROCESS_END();
}
Beispiel #2
0
int main () {
        
    while (1) {
        rs232_tx ("Hello World!");
    }

    return (0);
}