void Serial::set_block(bool b)
{
- mode = b?(mode&~M_NONBLOCK):(mode|M_NONBLOCK);
+ adjust_mode(mode, M_NONBLOCK, !b);
sys_set_blocking(handle, b);
}
+void Serial::set_inherit(bool i)
+{
+ adjust_mode(mode, M_INHERIT, i);
+ sys_set_inherit(handle, i);
+}
+
void Serial::set_baud_rate(unsigned rate)
{
DeviceState state;
state.apply_to(handle);
}
-unsigned Serial::do_write(const char *buf, unsigned size)
+size_t Serial::do_write(const char *buf, size_t size)
{
if(size==0)
return 0;
return sys_write(handle, buf, size);
}
-unsigned Serial::do_read(char *buf, unsigned size)
+size_t Serial::do_read(char *buf, size_t size)
{
if(size==0)
return 0;
- unsigned ret = reader.read(buf, size);
+ size_t ret = reader.read(buf, size);
if(ret==0)
set_eof();
return ret;
}
+const Handle &Serial::get_handle(Mode m)
+{
+ check_access(m);
+ return handle;
+}
+
} // namespace IO
} // namespace Msp