ua_architecture.h 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  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-2018 (c) Stefan Profanter, fortiss GmbH
  6. * Copyright 2018 (c) Jose Cabral, fortiss GmbH
  7. */
  8. #ifdef UA_ARCHITECTURE_FREERTOS
  9. #ifndef PLUGINS_ARCH_FREERTOS_UA_ARCHITECTURE_H_
  10. #define PLUGINS_ARCH_FREERTOS_UA_ARCHITECTURE_H_
  11. //------------------------------------------------------------------
  12. // NOT WORKING YET!!!!!!!!!!!!!!!!!!!!!
  13. //------------------------------------------------------------------
  14. #define AI_PASSIVE 0x01
  15. #define UA_THREAD_LOCAL
  16. #include <stdlib.h>
  17. #include <string.h>
  18. #define LWIP_TIMEVAL_PRIVATE 0
  19. //#define LWIP_COMPAT_MUTEX 0
  20. #define LWIP_POSIX_SOCKETS_IO_NAMES 0
  21. #ifdef LWIP_COMPAT_SOCKETS
  22. #undef LWIP_COMPAT_SOCKETS
  23. #endif
  24. #define LWIP_COMPAT_SOCKETS 0
  25. //#define __USE_W32_SOCKETS 1 //needed to avoid redefining of select in sys/select.h
  26. #include <lwip/tcpip.h>
  27. #include <lwip/netdb.h>
  28. #define sockaddr_storage sockaddr
  29. #ifdef BYTE_ORDER
  30. # undef BYTE_ORDER
  31. #endif
  32. #define UA_sleep_ms(X) vTaskDelay(pdMS_TO_TICKS(X))
  33. #define OPTVAL_TYPE int
  34. #include <unistd.h> // read, write, close
  35. #define UA_fd_set(fd, fds) FD_SET((unsigned int)fd, fds)
  36. #define UA_fd_isset(fd, fds) FD_ISSET((unsigned int)fd, fds)
  37. #define UA_access access
  38. #define UA_IPV6 0
  39. #define UA_SOCKET int
  40. #define UA_INVALID_SOCKET -1
  41. #define UA_ERRNO errno
  42. #define UA_INTERRUPTED EINTR
  43. #define UA_AGAIN EAGAIN
  44. #define UA_EAGAIN EAGAIN
  45. #define UA_WOULDBLOCK EWOULDBLOCK
  46. #define UA_ERR_CONNECTION_PROGRESS EINPROGRESS
  47. // No log colors on FreeRTOS
  48. // #define UA_ENABLE_LOG_COLORS
  49. #define UA_send lwip_send
  50. #define UA_recv lwip_recv
  51. #define UA_close lwip_close
  52. #define UA_select lwip_select
  53. #define UA_shutdown lwip_shutdown
  54. #define UA_socket lwip_socket
  55. #define UA_bind lwip_bind
  56. #define UA_listen lwip_listen
  57. #define UA_accept lwip_accept
  58. #define UA_connect lwip_connect
  59. #define UA_getsockopt lwip_getsockopt
  60. #define UA_setsockopt lwip_setsockopt
  61. #define UA_freeaddrinfo lwip_freeaddrinfo
  62. #define UA_gethostname gethostname_freertos
  63. #define UA_free vPortFree
  64. #define UA_malloc pvPortMalloc
  65. #define UA_calloc pvPortCalloc
  66. #define UA_realloc pvPortRealloc
  67. #include <stdio.h>
  68. #define UA_snprintf snprintf
  69. int gethostname_freertos(char* name, size_t len);
  70. #define UA_LOG_SOCKET_ERRNO_WRAP(LOG) { \
  71. char *errno_str = ""; \
  72. LOG; \
  73. }
  74. #define UA_LOG_SOCKET_ERRNO_GAI_WRAP UA_LOG_SOCKET_ERRNO_WRAP
  75. #include "../ua_architecture_functions.h"
  76. #endif /* PLUGINS_ARCH_FREERTOS_UA_ARCHITECTURE_H_ */
  77. #endif /* UA_ARCHITECTURE_FREERTOS */