You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

node.c 1.2 kB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. #include <stdio.h>
  2. #include <string.h>
  3. #include <assert.h>
  4. #include "../../apis/c/node/node_api.h"
  5. // sleep
  6. #ifdef _WIN32
  7. #include <Windows.h>
  8. #else
  9. #include <unistd.h>
  10. #endif
  11. int main()
  12. {
  13. printf("[c node] Hello World\n");
  14. void *dora_context = init_dora_context_from_env();
  15. if (dora_context == NULL)
  16. {
  17. fprintf(stderr, "failed to init dora context\n");
  18. return -1;
  19. }
  20. printf("[c node] dora context initialized\n");
  21. for (char i = 0; i < 10; i++)
  22. {
  23. printf("[c node] waiting for next input\n");
  24. void *input = dora_next_input(dora_context);
  25. if (input == NULL)
  26. {
  27. printf("[c node] ERROR: unexpected end of input\n");
  28. return -1;
  29. }
  30. char *data;
  31. size_t data_len;
  32. read_dora_input_data(input, &data, &data_len);
  33. assert(data_len == 0);
  34. char out_id[] = "tick";
  35. dora_send_output(dora_context, out_id, strlen(out_id), &i, 1);
  36. free_dora_input(input);
  37. }
  38. printf("[c node] received 10 inputs\n");
  39. free_dora_context(dora_context);
  40. printf("[c node] finished successfully\n");
  41. return 0;
  42. }

DORA (Dataflow-Oriented Robotic Architecture) is middleware designed to streamline and simplify the creation of AI-based robotic applications. It offers low latency, composable, and distributed datafl