Beispiel #1
0
void Runtime::debugStep(TextEditInput *edit, TextEditHelpWidget *help, bool cont) {
  if (g_debugee != -1) {
    char buf[OS_PATHNAME_SIZE + 1];
    int size;
    net_print(g_debugee, cont ? "c\n" : "n\n");
    pause(PAUSE_DEBUG_STEP);
    net_print(g_debugee, "l\n");
    size = net_input(g_debugee, buf, sizeof(buf), "\n");
    if (size > 0) {
      edit->gotoLine(buf);
      net_print(g_debugee, "v\n");
      help->reload(NULL);
      do {
        size = net_input(g_debugee, buf, sizeof(buf), "\1\n");
        if (buf[0] == '\1') {
          break;
        }
        if (size > 0) {
          help->append(buf, size);
          help->append("\n", 1);
        }
      } while (size > 0);
    }
  }
}
Beispiel #2
0
static void *iot_burst(void *arg) {
	struct iofix fix = *((struct iofix*)arg);
	odp_packet_t pkt_list [PKT_LIST_SIZE];
	int packets,i;
	for(;;){
		packets = odp_pktio_recv(fix.pktio, pkt_list, PKT_LIST_SIZE);
		//printf("packets: %d\n",packets);
		for(i=0;i<packets;++i){
			net_input(pkt_list[i]);
		}
	}
	return NULL;
}
Beispiel #3
0
void Runtime::debugStart(TextEditInput *editWidget, const char *file) {
  char buf[OS_PATHNAME_SIZE + 1];
  bool open;
  int size;

  if (g_debugee != -1) {
    net_print(g_debugee, "l\n");
    open = net_input(g_debugee, buf, sizeof(buf), "\n") > 0;
  } else {
    open = false;
  }

  if (!open) {
    launchDebug(file);
    pause(PAUSE_DEBUG_LAUNCH);
    SDL_RaiseWindow(_window);

    g_debugee = net_connect("localhost", g_debugPort);
    if (g_debugee != -1) {
      net_print(g_debugee, "l\n");
      size = net_input(g_debugee, buf, sizeof(buf), "\n");
      if (size > 0) {
        int *marker = editWidget->getMarkers();
        for (int i = 0; i < MAX_MARKERS; i++) {
          if (marker[i] != -1) {
            net_printf(g_debugee, "b %d\n", marker[i]);
          }
        }
        editWidget->gotoLine(buf);
        appLog("Debug session ready");
      }
    } else {
      appLog("Failed to attach to debug window");
    }
  } else {
    debugStop();
  }
}
void SoftplusLayer::activate()
{
  for(int i=0; i<this->getSize(); i++)
  {
    if(this->net_input(i) > 0.0)
    {
      this->activations(i) = net_input(i);
    }
    else
    {
      this->activations(i) = 0.0;
    }
  }
}
Beispiel #5
0
/*
 * Handles polling results from a previous (successful) select(2)
 * This is where new connections are handled and network input is
 * scheduled for reading
 */
int net_handle_polling_results(fd_set *rd, fd_set *wr)
{
	uint i;

	/* loop the nodes and see which ones have sent something */
	for (i = 0; i < num_nodes; i++) {
		merlin_node *node = node_table[i];

		/* skip obviously bogus sockets */
		if (node->sock < 0)
			continue;

		/* handle new connections first */
		if (FD_ISSET(node->sock, wr)) {
			if (net_is_connected(node)) {
				node_set_state(node, STATE_CONNECTED, "select()'ed for writing");

				if (binlog_has_entries(node->binlog)) {
					node_send_binlog(node, NULL);
				}
			}
			continue;
		}

		/*
		 * handle input, and missing input. All nodes should send
		 * a pulse at least once in a while, so we know it's still OK.
		 * If they fail to do that, we may have to take action.
		 */
		if (FD_ISSET(node->sock, rd)) {
			net_input(node);
		}
	}

	/* check_node_activity(node); */
	return 0;
}
Beispiel #6
0
/*
 * read from a socket
 */
int sockcl_read(dev_file_t *f, byte *data, dword size) {
  f->drv_dw[0] = (dword) net_input((socket_t) (long) f->handle, (char *)data, size, NULL);
  return (((long) f->drv_dw[0]) <= 0) ? 0 : (long) f->drv_dw[0];
}
Beispiel #7
0
/*---------------------------------------------------------------------------*/
PROCESS_THREAD(net_uart_process, ev, data)
{
  PROCESS_BEGIN();

  printf("CC26XX Net UART Process\n");

  set_config_defaults();

  udp_conn = udp_new(NULL, UIP_HTONS(0), NULL);
  udp_bind(udp_conn, UIP_HTONS(REMOTE_PORT));

  if(udp_conn == NULL) {
    printf("No UDP connection available, exiting the process!\n");
    PROCESS_EXIT();
  }

  httpd_simple_register_post_handler(&remote_port_handler);
  httpd_simple_register_post_handler(&remote_ipv6_handler);
  httpd_simple_register_post_handler(&on_off_handler);

  while(1) {

    PROCESS_YIELD();

    if(ev == serial_line_event_message) {
        
        printf("~Received line: %s\n", (char *)data);
      /*
       * If the message contains a new IP address, save it and go back to
       * waiting.
       */
      if(set_new_ip_address((char *)data) == ADDRESS_CONVERSION_ERROR) {
        /* Not an IP address in the message. Send to current destination */
        memset(buffer, 0, MAX_MSG_SIZE);
        
        memset(uart_reading_value, 0, MAX_MSG_SIZE);

        /* We need to add a line feed, thus never fill the entire buffer */
        msg_len = MIN(strlen(data), MAX_MSG_SIZE - 1);
        memcpy(buffer, data, msg_len);
        memcpy(uart_reading_value, data, msg_len);

        /* Add a line feed */
        buffer[msg_len] = 0x0A;
        msg_len++;

        uip_udp_packet_sendto(
          udp_conn, buffer, msg_len, &remote_addr,
          UIP_HTONS(cc26xx_web_demo_config.net_uart.remote_port));
      }
    } else if(ev == tcpip_event) {
      net_input();
    } else if(ev == cc26xx_web_demo_config_loaded_event) {
      /*
       * New config. Check if it's possible to update the remote address.
       * The port will have been updated already
       */
      set_new_ip_address(cc26xx_web_demo_config.net_uart.remote_address);

      if(cc26xx_web_demo_config.net_uart.enable == 1) {
        keep_uart_on();
      }
    } else if(ev == cc26xx_web_demo_load_config_defaults) {
      set_config_defaults();
    }
  }

  PROCESS_END();
}
Beispiel #8
0
int debugThread(void *data) {
  int port = ((intptr_t) data);
  socket_t socket = net_listen(port);
  char buf[OS_PATHNAME_SIZE + 1];

  if (socket == -1) {
    signalTrace(SDL_FALSE, SDL_TRUE);
    return -1;
  }

  while (socket != -1) {
    int size = net_input(socket, buf, sizeof(buf), "\r\n");
    if (size > 0) {
      char cmd = buf[0];
      switch (cmd) {
      case 'n':
        // step over next line
        signalTrace(SDL_TRUE);
        break;
      case 'c':
        // continue
        signalTrace(SDL_FALSE);
        break;
      case 'l':
        // current line number
        SDL_LockMutex(g_lock);
        net_printf(socket, "%d\n", g_debugLine);
        SDL_UnlockMutex(g_lock);
        break;
      case 'v':
        // variables
        SDL_LockMutex(g_lock);
        if (!runtime->isRunning()) {
          net_printf(socket, "\n");
        } else {
          net_print(socket, "Variables:\n");
          for (unsigned i = SYSVAR_COUNT; i < prog_varcount; i++) {
            if (!v_isempty(tvar[i])) {
              pv_writevar(tvar[i], PV_NET, socket);
              net_print(socket, "\n");
            }
          }
          net_print(socket, "Stack:\n");
          dumpStack(socket);
          net_print(socket, "\1");
        }
        SDL_UnlockMutex(g_lock);
        break;
      case 'b':
        // set breakpoint
        SDL_LockMutex(g_lock);
        g_breakPoints.add(new int(atoi(buf + 2)));
        SDL_UnlockMutex(g_lock);
        break;
      case 'q':
        // quit
        signalTrace(SDL_FALSE, SDL_TRUE);
        g_breakPoints.removeAll();
        net_disconnect(socket);
        socket = -1;
        break;
      case 'h':
        net_print(socket, "SmallBASIC debugger\n");
        break;
      default:
        // unknown command
        net_printf(socket, "Unknown command '%s'\n", buf);
        break;
      };
    }
  }
  return 0;
}