| 182 | static ssize_t serial_fops_write(struct dfs_file *fd, const void *buf, size_t count, off_t *pos) |
| 183 | #else |
| 184 | static ssize_t serial_fops_write(struct dfs_file *fd, const void *buf, size_t count) |
| 185 | #endif |
| 186 | { |
| 187 | ssize_t size = 0; |
| 188 | rt_device_t device; |
| 189 | rt_int32_t tx_timeout; |
| 190 | |
| 191 | device = (rt_device_t)fd->vnode->data; |
| 192 | |
| 193 | if (fd->flags & O_NONBLOCK) |
| 194 | { |
| 195 | tx_timeout = RT_WAITING_NO; |
| 196 | rt_device_control(device, RT_SERIAL_CTRL_SET_TX_TIMEOUT, (void *)&tx_timeout); |
| 197 | size = rt_device_write(device, -1, buf, count); |
| 198 | if (size <= 0) |
| 199 | { |
| 200 | size = -1; |
| 201 | rt_set_errno(EAGAIN); |
| 202 | } |
| 203 | } |
| 204 | else |
| 205 | { |
| 206 | tx_timeout = RT_WAITING_FOREVER; |
| 207 | rt_device_control(device, RT_SERIAL_CTRL_SET_TX_TIMEOUT, (void *)&tx_timeout); |
| 208 | size = rt_device_write(device, -1, buf, count); |
| 209 | } |
| 210 | |
| 211 | return size; |
| 212 | } |
| 213 | |
| 214 | static int serial_fops_flush(struct dfs_file *fd) |
| 215 | { |
nothing calls this directly
no test coverage detected