libcm is a C development framework with an emphasis on audio signal processing applications.
Du kannst nicht mehr als 25 Themen auswählen Themen müssen mit entweder einem Buchstaben oder einer Ziffer beginnen. Sie können Bindestriche („-“) enthalten und bis zu 35 Zeichen lang sein.

cmSerialPort.h 2.5KB

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