awtk/tests/fscripts/demo_serial.fs

19 lines
394 B
Forth
Raw Normal View History

2021-01-12 14:29:47 +08:00
//
// start serial echo server first
// ./bin/serial_recv 4000
//
2021-01-06 18:05:50 +08:00
2022-08-23 11:21:48 +08:00
var a = iostream_serial_create("/dev/ttys001", 0)
var b = iostream_get_ostream(a)
var c = iostream_get_istream(a)
2021-01-06 18:05:50 +08:00
assert(ostream_write_uint32(b, 6) == 4)
assert(ostream_write_string(b, "hello\n") == 6)
assert(istream_read_uint32(c, 3000) == 6)
assert(istream_read_string(c, 6, 3000) == "hello\n")
unset(c)
unset(b)
unset(a)