MCPcopy Create free account
hub / github.com/RT-Thread/rt-thread / serial_fops_write

Function serial_fops_write

components/drivers/serial/dev_serial_v2.c:184–212  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

182static ssize_t serial_fops_write(struct dfs_file *fd, const void *buf, size_t count, off_t *pos)
183#else
184static 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
214static int serial_fops_flush(struct dfs_file *fd)
215{

Callers

nothing calls this directly

Calls 3

rt_device_controlFunction · 0.85
rt_device_writeFunction · 0.85
rt_set_errnoFunction · 0.85

Tested by

no test coverage detected