| 155 | } |
| 156 | |
| 157 | int finsh_getchar(void) |
| 158 | { |
| 159 | #ifdef RT_USING_DEVICE |
| 160 | char ch = 0; |
| 161 | #ifdef RT_USING_POSIX_STDIO |
| 162 | if(read(rt_posix_stdio_get_console(), &ch, 1) > 0) |
| 163 | { |
| 164 | return ch; |
| 165 | } |
| 166 | else |
| 167 | { |
| 168 | return -1; /* EOF */ |
| 169 | } |
| 170 | #else |
| 171 | rt_device_t device; |
| 172 | |
| 173 | RT_ASSERT(shell != RT_NULL); |
| 174 | |
| 175 | device = shell->device; |
| 176 | if (device == RT_NULL) |
| 177 | { |
| 178 | return -1; /* EOF */ |
| 179 | } |
| 180 | |
| 181 | while (rt_device_read(device, -1, &ch, 1) != 1) |
| 182 | { |
| 183 | rt_sem_take(&shell->rx_sem, RT_WAITING_FOREVER); |
| 184 | if (shell->device != device) |
| 185 | { |
| 186 | device = shell->device; |
| 187 | if (device == RT_NULL) |
| 188 | { |
| 189 | return -1; |
| 190 | } |
| 191 | } |
| 192 | } |
| 193 | return ch; |
| 194 | #endif /* RT_USING_POSIX_STDIO */ |
| 195 | #else |
| 196 | extern signed char rt_hw_console_getchar(void); |
| 197 | return rt_hw_console_getchar(); |
| 198 | #endif /* RT_USING_DEVICE */ |
| 199 | } |
| 200 | |
| 201 | #if !defined(RT_USING_POSIX_STDIO) && defined(RT_USING_DEVICE) |
| 202 | static rt_err_t finsh_rx_ind(rt_device_t dev, rt_size_t size) |
no test coverage detected