| 134 | } |
| 135 | |
| 136 | void RCInput_RCProtocol::_timer_tick(void) |
| 137 | { |
| 138 | uint8_t b[80]; |
| 139 | |
| 140 | if (fd_inverted != -1) { |
| 141 | ssize_t n = ::read(fd_inverted, &b[0], sizeof(b)); |
| 142 | if (n > 0) { |
| 143 | for (uint8_t i=0; i<n; i++) { |
| 144 | AP::RC().process_byte(b[i], inverted_is_115200?115200:100000); |
| 145 | } |
| 146 | } |
| 147 | } |
| 148 | if (fd_115200 != -1) { |
| 149 | ssize_t n = ::read(fd_115200, &b[0], sizeof(b)); |
| 150 | if (n > 0 && !inverted_is_115200) { |
| 151 | for (uint8_t i=0; i<n; i++) { |
| 152 | AP::RC().process_byte(b[i], 115200); |
| 153 | } |
| 154 | } |
| 155 | } |
| 156 | |
| 157 | if (AP::RC().new_input()) { |
| 158 | last_frame_ms = AP_HAL::millis(); |
| 159 | uint8_t n = AP::RC().num_channels(); |
| 160 | for (uint8_t i=0; i<n; i++) { |
| 161 | _pwm_values[i] = AP::RC().read(i); |
| 162 | } |
| 163 | _num_channels = n; |
| 164 | rc_input_count++; |
| 165 | } |
| 166 | |
| 167 | uint32_t now = AP_HAL::millis(); |
| 168 | if (fd_inverted != -1 && now - last_frame_ms > 2000) { |
| 169 | // no inverted data for 2s, flip baudrate |
| 170 | close(fd_inverted); |
| 171 | inverted_is_115200 = !inverted_is_115200; |
| 172 | if (inverted_is_115200) { |
| 173 | fd_inverted = open_115200(dev_inverted); |
| 174 | } else { |
| 175 | fd_inverted = open_sbus(dev_inverted); |
| 176 | } |
| 177 | last_frame_ms = now; |
| 178 | } |
| 179 | } |
| 180 | |
| 181 | #endif // HAL |
nothing calls this directly
no test coverage detected