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.

ArduinoSerial.h 695B

1234567891011121314151617181920212223242526272829303132333435363738
  1. //
  2. // Created by robin on 5/6/16.
  3. //
  4. #ifndef DIGICODE_HOST_ARDUINOSERIAL_H
  5. #define DIGICODE_HOST_ARDUINOSERIAL_H
  6. #include <string>
  7. #include "../DBO/Result.h"
  8. #include "../config.h"
  9. class ArduinoSerial
  10. {
  11. public:
  12. ArduinoSerial(std::string port, int baudrate);
  13. virtual ~ArduinoSerial();
  14. BResult open();
  15. void close();
  16. Result<std::pair<SERIAL_PACKET_TYPE, std::string>> read();
  17. BResult write(const char* data, SERIAL_PACKET_LENGTH_TYPE length);
  18. protected:
  19. BResult readBytes(char* buffer, size_t length);
  20. BResult writeBytes(const char* data, size_t length);
  21. std::string port_;
  22. int bauderate_;
  23. int fd_;
  24. };
  25. #endif //DIGICODE_HOST_ARDUINOSERIAL_H