Revision dd8738ea os/core/src/aos_iostream.c
os/core/src/aos_iostream.c | ||
---|---|---|
40 | 40 |
*/ |
41 | 41 |
static size_t _channelread(void *instance, uint8_t *bp, size_t n) |
42 | 42 |
{ |
43 |
return streamRead(((AosIOChannel*)instance)->asyncchannel, bp, n); |
|
43 |
if (((AosIOChannel*)instance)->flags & AOS_IOCHANNEL_INPUT_ENABLE) { |
|
44 |
return streamRead(((AosIOChannel*)instance)->asyncchannel, bp, n); |
|
45 |
} else { |
|
46 |
return 0; |
|
47 |
} |
|
44 | 48 |
} |
45 | 49 |
|
46 | 50 |
/** |
... | ... | |
60 | 64 |
*/ |
61 | 65 |
static msg_t _channelget(void *instance) |
62 | 66 |
{ |
63 |
return streamGet(((AosIOChannel*)instance)->asyncchannel); |
|
67 |
if (((AosIOChannel*)instance)->flags & AOS_IOCHANNEL_INPUT_ENABLE) { |
|
68 |
return streamGet(((AosIOChannel*)instance)->asyncchannel); |
|
69 |
} else { |
|
70 |
return MSG_RESET; |
|
71 |
} |
|
64 | 72 |
} |
65 | 73 |
|
66 | 74 |
/** |
... | ... | |
80 | 88 |
*/ |
81 | 89 |
static msg_t _channelgett(void *instance, systime_t time) |
82 | 90 |
{ |
83 |
return chnGetTimeout(((AosIOChannel*)instance)->asyncchannel, time); |
|
91 |
if (((AosIOChannel*)instance)->flags & AOS_IOCHANNEL_INPUT_ENABLE) { |
|
92 |
return chnGetTimeout(((AosIOChannel*)instance)->asyncchannel, time); |
|
93 |
} else { |
|
94 |
return MSG_RESET; |
|
95 |
} |
|
84 | 96 |
} |
85 | 97 |
|
86 | 98 |
/** |
... | ... | |
100 | 112 |
*/ |
101 | 113 |
static size_t _channelreadt(void *instance, uint8_t *bp, size_t n, systime_t time) |
102 | 114 |
{ |
103 |
return chnReadTimeout(((AosIOChannel*)instance)->asyncchannel, bp, n, time); |
|
115 |
if (((AosIOChannel*)instance)->flags & AOS_IOCHANNEL_INPUT_ENABLE) { |
|
116 |
return chnReadTimeout(((AosIOChannel*)instance)->asyncchannel, bp, n, time); |
|
117 |
} else { |
|
118 |
return 0; |
|
119 |
} |
|
104 | 120 |
} |
105 | 121 |
|
106 | 122 |
/** |
... | ... | |
160 | 176 |
|
161 | 177 |
// local variables |
162 | 178 |
AosIOChannel* channel = ((AosIOStream*)instance)->channel; |
163 |
msg_t ret; |
|
179 |
msg_t ret = MSG_OK;
|
|
164 | 180 |
|
165 | 181 |
// iterate through the list of channels |
166 | 182 |
while (channel != NULL) { |
167 |
ret = streamPut(channel, b); |
|
168 |
if (ret != MSG_OK) { |
|
169 |
return ret; |
|
170 |
} |
|
183 |
msg_t ret_ = streamPut(channel, b); |
|
184 |
ret = (ret_ < ret) ? ret_ : ret; |
|
171 | 185 |
channel = channel->next; |
172 | 186 |
} |
173 | 187 |
|
174 |
return MSG_OK;
|
|
188 |
return ret;
|
|
175 | 189 |
} |
176 | 190 |
|
177 | 191 |
/** |
... | ... | |
294 | 308 |
} |
295 | 309 |
|
296 | 310 |
/** |
311 |
* @brief Enable input for a AosIOChannel. |
|
312 |
* |
|
313 |
* @param[in] channel The AosIOChannel to enable as input. |
|
314 |
*/ |
|
315 |
void aosIOChannelInputEnable(AosIOChannel* channel) |
|
316 |
{ |
|
317 |
aosDbgCheck(channel != NULL); |
|
318 |
|
|
319 |
channel->flags |= AOS_IOCHANNEL_INPUT_ENABLE; |
|
320 |
|
|
321 |
return; |
|
322 |
} |
|
323 |
|
|
324 |
/** |
|
325 |
* @brief Disable input for a AosIOChannel. |
|
326 |
* |
|
327 |
* @param[in] channel The AosIOChannel to disable as input. |
|
328 |
*/ |
|
329 |
void aosIOChannelInputDisable(AosIOChannel* channel) |
|
330 |
{ |
|
331 |
aosDbgCheck(channel != NULL); |
|
332 |
|
|
333 |
channel->flags &= ~AOS_IOCHANNEL_INPUT_ENABLE; |
|
334 |
|
|
335 |
return; |
|
336 |
} |
|
337 |
|
|
338 |
/** |
|
297 | 339 |
* @brief Enable output for a AosIOChannel. |
298 | 340 |
* |
299 | 341 |
* @param[in] channel The AosIOChannel to enable as output. |
Also available in: Unified diff