/* * \brief Terminal echo program * \author Norman Feske * \date 2009-10-16 */ /* * Copyright (C) 2009-2013 Genode Labs GmbH * * This file is part of the Genode OS framework, which is distributed * under the terms of the GNU General Public License version 2. */ #include #include #include using namespace Genode; static const bool verbose = false; int main(int, char **) { static Terminal::Connection terminal; enum { READ_BUFFER_SIZE = 100 }; static char read_buffer[READ_BUFFER_SIZE]; Signal_receiver sig_rec; Signal_context sig_ctx; terminal.read_avail_sigh(sig_rec.manage(&sig_ctx)); static const char *intro_text = "--- Terminal echo test started - now you can type characters to be echoed. ---\n"; terminal.write(intro_text, strlen(intro_text) + 1); for (;;) { sig_rec.wait_for_signal(); int num_bytes = terminal.read(read_buffer, sizeof(read_buffer)); if (verbose && (num_bytes > 0)) PDBG("got %d bytes", num_bytes); for (int i = 0; i < num_bytes; i++) terminal.write(&read_buffer[i], 1); } return 0; }