| 11 | using namespace std::chrono_literals; |
| 12 | |
| 13 | FanBusInterface::FanBusInterface(const char* portname) |
| 14 | { |
| 15 | port_name = portname; |
| 16 | serialport = new serial_port(portname, 38400); |
| 17 | |
| 18 | /*-----------------------------------------------------*\ |
| 19 | | Flush any data in the receive queue | |
| 20 | \*-----------------------------------------------------*/ |
| 21 | char read_buf[6]; |
| 22 | |
| 23 | while(serialport->serial_read(read_buf, 6) > 0) |
| 24 | { |
| 25 | |
| 26 | } |
| 27 | |
| 28 | read_buf[0] = 0xFF; |
| 29 | |
| 30 | serialport->serial_write(read_buf, 1); |
| 31 | |
| 32 | std::this_thread::sleep_for(10ms); |
| 33 | |
| 34 | int test = serialport->serial_read(read_buf, 1); |
| 35 | |
| 36 | if(test > 0) |
| 37 | { |
| 38 | half_duplex = true; |
| 39 | } |
| 40 | else |
| 41 | { |
| 42 | half_duplex = false; |
| 43 | } |
| 44 | } |
| 45 | |
| 46 | FanBusInterface::~FanBusInterface() |
| 47 | { |
nothing calls this directly
no test coverage detected