canard_nuttx.h 1.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. /*
  2. * Copyright (c) 2016 UAVCAN Team
  3. *
  4. * Distributed under the MIT License, available in the file LICENSE.
  5. *
  6. */
  7. #ifndef CANARD_NUTTX_H
  8. #define CANARD_NUTTX_H
  9. #include <canard.h>
  10. #ifdef __cplusplus
  11. extern "C"
  12. {
  13. #endif
  14. typedef struct
  15. {
  16. int fd;
  17. } CanardNuttXInstance;
  18. /**
  19. * Initializes the NuttX instance.
  20. */
  21. int canardNuttXInit(CanardNuttXInstance* out_ins, const char* can_iface_name);
  22. /**
  23. * Deinitializes the NuttX instance.
  24. */
  25. int canardNuttXClose(CanardNuttXInstance* ins);
  26. /**
  27. * Transmits a CanardCANFrame to the CAN device.
  28. * Use negative timeout to block infinitely.
  29. */
  30. int canardNuttXTransmit(CanardNuttXInstance* ins, const CanardCANFrame* frame, int timeout_msec);
  31. /**
  32. * Receives a CanardCANFrame from the CAN device.
  33. * Use negative timeout to block infinitely.
  34. */
  35. int canardNuttXReceive(CanardNuttXInstance* ins, CanardCANFrame* out_frame, int timeout_msec);
  36. /**
  37. * Returns the file descriptor of the CAN device.
  38. */
  39. int canardNuttXGetDeviceFileDescriptor(const CanardNuttXInstance* ins);
  40. #ifdef __cplusplus
  41. }
  42. #endif
  43. #endif