| 96 | } |
| 97 | |
| 98 | int LibFTDISerial::set_serial_port_settings (int ms_timeout, bool timeout_only) |
| 99 | { |
| 100 | if (!timeout_only) |
| 101 | { |
| 102 | last_result = ftdi_set_line_property (&ftdi, BITS_8, STOP_BIT_1, NONE); |
| 103 | if (last_result != 0) |
| 104 | { |
| 105 | log_error ("set_serial_port_settings"); |
| 106 | return (int)SerialExitCodes::SET_PORT_STATE_ERROR; |
| 107 | } |
| 108 | last_result = set_custom_baudrate (115200); |
| 109 | if (last_result != (int)SerialExitCodes::OK) |
| 110 | { |
| 111 | return last_result; |
| 112 | } |
| 113 | last_result = ftdi_setdtr_rts (&ftdi, 1, 1); |
| 114 | last_result |= ftdi_setflowctrl (&ftdi, SIO_DISABLE_FLOW_CTRL); |
| 115 | if (last_result != 0) |
| 116 | { |
| 117 | // -1 setting failed, -2 usb device unavailable |
| 118 | log_error ("set_serial_port_settings"); |
| 119 | return (int)SerialExitCodes::SET_PORT_STATE_ERROR; |
| 120 | } |
| 121 | } |
| 122 | |
| 123 | ftdi.usb_read_timeout = ms_timeout; |
| 124 | |
| 125 | return (int)SerialExitCodes::OK; |
| 126 | } |
| 127 | |
| 128 | int LibFTDISerial::set_custom_baudrate (int baudrate) |
| 129 | { |
nothing calls this directly
no outgoing calls
no test coverage detected