mirror of
https://gitee.com/zlgopen/awtk.git
synced 2024-11-30 11:08:34 +08:00
improve iostream_serial
This commit is contained in:
parent
1b4cdaccfd
commit
57d49dc9d9
@ -104,9 +104,11 @@ static ret_t tk_iostream_serial_exec(object_t* obj, const char* name, const char
|
||||
static ret_t tk_iostream_serial_on_destroy(object_t* obj) {
|
||||
tk_iostream_serial_t* iostream_serial = TK_IOSTREAM_SERIAL(obj);
|
||||
|
||||
serial_close(iostream_serial->fd);
|
||||
tk_istream_flush(iostream_serial->istream);
|
||||
tk_ostream_flush(iostream_serial->ostream);
|
||||
object_unref(OBJECT(iostream_serial->istream));
|
||||
object_unref(OBJECT(iostream_serial->ostream));
|
||||
serial_close(iostream_serial->fd);
|
||||
|
||||
return RET_OK;
|
||||
}
|
||||
@ -161,6 +163,8 @@ tk_iostream_t* tk_iostream_serial_create(const char* port) {
|
||||
TK_IOSTREAM(obj)->get_ostream = tk_iostream_serial_get_ostream;
|
||||
|
||||
object_exec(obj, TK_IOSTREAM_SERIAL_CMD_CONFIG, NULL);
|
||||
tk_istream_flush(iostream_serial->istream);
|
||||
tk_ostream_flush(iostream_serial->ostream);
|
||||
|
||||
return TK_IOSTREAM(obj);
|
||||
}
|
||||
|
@ -21,7 +21,7 @@ void do_echo(tk_iostream_t* iostream) {
|
||||
|
||||
if (ret >= 0) {
|
||||
buff[ret] = '\0';
|
||||
log_debug("read: %s\n", buff);
|
||||
log_debug("read(%d): %s\n", ret, buff);
|
||||
ret = tk_ostream_write(ostream, (uint8_t*)buff, ret);
|
||||
log_debug("write: %d %s\n", ret, buff);
|
||||
sleep_ms(2000);
|
||||
|
Loading…
Reference in New Issue
Block a user