libcm is a C development framework with an emphasis on audio signal processing applications.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

cmSerialPort.h 2.6KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. #ifndef cmSerialPort_h
  2. #define cmSerialPort_h
  3. #ifdef __cplusplus
  4. extern "C" {
  5. #endif
  6. //( { file_desc:"Serial port interface." kw[system devices rt] }
  7. typedef unsigned cmSeRC_t;
  8. enum
  9. {
  10. kOkSeRC = cmOkRC,
  11. kFlushFailSeRC,
  12. kSetAttrFailSeRC,
  13. kCloseFailSeRC,
  14. kOpenFailSeRC,
  15. kResourceNotAvailableSeRC,
  16. kGetAttrFailSeRC,
  17. kWriteFailSeRC,
  18. kReadFailSeRC,
  19. kTimeOutSeRC,
  20. kThreadErrSeRC
  21. };
  22. enum
  23. {
  24. kDataBits5SeFl = 0x0001,
  25. kDataBits6SeFl = 0x0002,
  26. kDataBits7SeFl = 0x0004,
  27. kDataBits8SeFl = 0x0008,
  28. kDataBitsSeMask = 0x000f,
  29. k1StopBitSeFl = 0x0010,
  30. k2StopBitSeFl = 0x0020,
  31. kEvenParitySeFl = 0x0040,
  32. kOddParitySeFl = 0x0080,
  33. kNoParitySeFl = 0x0000,
  34. kDefaultCfgSeFlags = kDataBits8SeFl | k1StopBitSeFl | kNoParitySeFl
  35. };
  36. typedef void (*cmSeCallbackFunc_t)( void* cbArg, const void* byteA, unsigned byteN );
  37. typedef cmHandle_t cmSeH_t;
  38. cmSeH_t cmSeCreate( cmCtx_t* ctx, cmSeH_t* hp, const char* device, unsigned baudRate, unsigned cfgFlags, cmSeCallbackFunc_t cbFunc, void* cbArg, unsigned pollPeriodMs );
  39. cmSeRC_t cmSeDestroy(cmSeH_t* hp );
  40. cmSeRC_t cmSeSetCallback( cmSeH_t h, cmSeCallbackFunc_t cbFunc, void* cbArg );
  41. cmSeRC_t cmSeStart( cmSeH_t h );
  42. bool cmSeIsOpen( cmSeH_t h);
  43. cmSeRC_t cmSeSend( cmSeH_t h, const void* byteA, unsigned byteN );
  44. // Make callback to listener with result of read - Non-blocking
  45. cmSeRC_t cmSeReceiveCbNb( cmSeH_t h, unsigned* readN_Ref);
  46. // Make callback to listener with result of read - Block for up to timeOutMs.
  47. cmSeRC_t cmSeReceiveCbTimeOut( cmSeH_t h, unsigned timeOutMs, unsigned* readN_Ref);
  48. // Return result of read in buf[bufByteN] - Non-blocking.
  49. cmSeRC_t cmSeReceiveNb( cmSeH_t h, void* buf, unsigned bufByteN, unsigned* readN_Ref);
  50. // Return result of read in buf[bufByteN] - Block for up to timeOutMs.
  51. cmSeRC_t cmSeReceive( cmSeH_t h, void* buf, unsigned bufByteN, unsigned timeOutMs, unsigned* readN_Ref );
  52. const char* cmSeDevice( cmSeH_t h);
  53. // Get the baud rate and cfgFlags used to initialize the port
  54. unsigned cmSeBaudRate( cmSeH_t h);
  55. unsigned cmSeCfgFlags( cmSeH_t h);
  56. // Get the baud rate and cfg flags by reading the device.
  57. // Note the the returned buad rate is a system id rather than the actual baud rate,
  58. // however the cfgFlags are converted to the same kXXXFl defined in this class.
  59. unsigned cmSeReadInBaudRate( cmSeH_t h );
  60. unsigned cmSeReadOutBaudRate( cmSeH_t h);
  61. unsigned cmSeReadCfgFlags( cmSeH_t h);
  62. cmSeRC_t cmSePortTest(cmCtx_t* ctx);
  63. //)
  64. #ifdef __cplusplus
  65. }
  66. #endif
  67. #endif