ua_architecture.h 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. /* This work is licensed under a Creative Commons CCZero 1.0 Universal License.
  2. * See http://creativecommons.org/publicdomain/zero/1.0/ for more information.
  3. *
  4. * Copyright 2016-2017 (c) Julius Pfrommer, Fraunhofer IOSB
  5. * Copyright 2017 (c) Stefan Profanter, fortiss GmbH
  6. */
  7. #ifndef PLUGINS_ARCH_FREERTOS_UA_ARCHITECTURE_H_
  8. #define PLUGINS_ARCH_FREERTOS_UA_ARCHITECTURE_H_
  9. //------------------------------------------------------------------
  10. // NOT WORKING YET!!!!!!!!!!!!!!!!!!!!!
  11. //------------------------------------------------------------------
  12. #define AI_PASSIVE 0x01
  13. #define UA_FREERTOS_HOSTNAME "10.200.4.114"
  14. #include <stdlib.h>
  15. #include <string.h>
  16. #define LWIP_TIMEVAL_PRIVATE 0
  17. //#define LWIP_COMPAT_MUTEX 0
  18. #define LWIP_POSIX_SOCKETS_IO_NAMES 0
  19. #ifdef LWIP_COMPAT_SOCKETS
  20. #undef LWIP_COMPAT_SOCKETS
  21. #endif
  22. #define LWIP_COMPAT_SOCKETS 0
  23. //#define __USE_W32_SOCKETS 1 //needed to avoid redefining of select in sys/select.h
  24. #include <lwip/tcpip.h>
  25. #include <lwip/netdb.h>
  26. #define sockaddr_storage sockaddr
  27. #ifdef BYTE_ORDER
  28. # undef BYTE_ORDER
  29. #endif
  30. #define UA_sleep_ms(X) vTaskDelay(pdMS_TO_TICKS(X))
  31. #define OPTVAL_TYPE int
  32. #include <unistd.h> // read, write, close
  33. #define UA_fd_set(fd, fds) FD_SET((unsigned int)fd, fds)
  34. #define UA_fd_isset(fd, fds) FD_ISSET((unsigned int)fd, fds)
  35. #define UA_access access
  36. #define UA_IPV6 0
  37. #define UA_SOCKET int
  38. #define UA_INVALID_SOCKET -1
  39. #define UA_ERRNO errno
  40. #define UA_INTERRUPTED EINTR
  41. #define UA_AGAIN EAGAIN
  42. #define UA_EAGAIN EAGAIN
  43. #define UA_WOULDBLOCK EWOULDBLOCK
  44. #define UA_ERR_CONNECTION_PROGRESS EINPROGRESS
  45. #define UA_send lwip_send
  46. #define UA_recv lwip_recv
  47. #define UA_close lwip_close
  48. #define UA_select lwip_select
  49. #define UA_shutdown lwip_shutdown
  50. #define UA_socket lwip_socket
  51. #define UA_bind lwip_bind
  52. #define UA_listen lwip_listen
  53. #define UA_accept lwip_accept
  54. #define UA_connect lwip_connect
  55. #define UA_getsockopt lwip_getsockopt
  56. #define UA_setsockopt lwip_setsockopt
  57. #define UA_freeaddrinfo lwip_freeaddrinfo
  58. #define UA_gethostname gethostname_freertos
  59. #define UA_free vPortFree
  60. #define UA_malloc pvPortMalloc
  61. #define UA_calloc pvPortCalloc
  62. #define UA_realloc pvPortRealloc
  63. #include <stdio.h>
  64. #define UA_snprintf snprintf
  65. int gethostname_freertos(char* name, size_t len);
  66. #define UA_LOG_SOCKET_ERRNO_WRAP(LOG) { \
  67. char *errno_str = ""; \
  68. LOG; \
  69. }
  70. #define UA_LOG_SOCKET_ERRNO_GAI_WRAP UA_LOG_SOCKET_ERRNO_WRAP
  71. #include "../ua_architecture_functions.h"
  72. #endif /* PLUGINS_ARCH_FREERTOS_UA_ARCHITECTURE_H_ */