| 55 | } |
| 56 | |
| 57 | int FanBusInterface::read |
| 58 | ( |
| 59 | unsigned char dev_addr, |
| 60 | unsigned char int_addr |
| 61 | ) |
| 62 | { |
| 63 | unsigned char fanbus_msg[] = { 0x01, int_addr, dev_addr, 0x00, 0xFF }; |
| 64 | |
| 65 | serialport->serial_write((char *)fanbus_msg, 5); |
| 66 | |
| 67 | std::this_thread::sleep_for(10ms); |
| 68 | |
| 69 | char read_buf[6]; |
| 70 | |
| 71 | if(half_duplex) |
| 72 | { |
| 73 | if(serialport->serial_read(read_buf, 6) == 6) |
| 74 | { |
| 75 | return(read_buf[5]); |
| 76 | } |
| 77 | else |
| 78 | { |
| 79 | return(-1); |
| 80 | } |
| 81 | } |
| 82 | else |
| 83 | { |
| 84 | if(serialport->serial_read(read_buf, 1) == 1) |
| 85 | { |
| 86 | return(read_buf[0]); |
| 87 | } |
| 88 | else |
| 89 | { |
| 90 | return(-1); |
| 91 | } |
| 92 | } |
| 93 | } |
| 94 | |
| 95 | int FanBusInterface::write |
| 96 | ( |
nothing calls this directly
no test coverage detected