2022-02-21 13:58:38 +01:00
|
|
|
#pragma once
|
|
|
|
#include "rust/cxx.h"
|
|
|
|
|
|
|
|
#include <memory>
|
|
|
|
#include <string>
|
|
|
|
|
|
|
|
struct CxxSerial
|
|
|
|
{
|
2022-02-22 14:55:39 +01:00
|
|
|
CxxSerial(rust::String port, uint32_t baud, uint32_t read_timeout, uint32_t write_timeout, bool hardware);
|
2022-02-21 13:58:38 +01:00
|
|
|
|
|
|
|
uint32_t write(const rust::Vec<uint8_t> &data) const;
|
|
|
|
|
2022-02-22 14:55:39 +01:00
|
|
|
uint32_t read(rust::Vec<uint8_t> &data) const;
|
2022-02-21 13:58:38 +01:00
|
|
|
|
|
|
|
void flush() const;
|
|
|
|
|
|
|
|
bool check() const;
|
|
|
|
|
|
|
|
private:
|
|
|
|
struct impl;
|
|
|
|
std::shared_ptr<impl> impl;
|
|
|
|
};
|
|
|
|
|
|
|
|
// port: String, baud: u32, timeout: u32, hardware: bool
|
2022-02-22 14:55:39 +01:00
|
|
|
std::unique_ptr<CxxSerial> new_cxx_serial(rust::String port, uint32_t baud, uint32_t read_timeout, uint32_t write_timeout, bool hardware);
|