GeezerVisonThe World Wide Web, restored to 800 pixels of glory. |
| Home|About|Gaming cabinet|Archives|How it works|Starter sites |
GeezerVison is showing github.com — PICoBoot_Utility/SerialOps.cpp at master · SudoMaker/PICoBoot_Utility Expand file tree/ Copy pathSerialOps.cppMore file actions 63 lines (47 loc) · 1.85 KB / Copy pathSerialOps.cppFile metadata and controls63 lines (47 loc) · 1.85 KB 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 /* This file is part of PICoBoot Utility. Copyright (C) 2021 ReimuNotMoe <[email protected]> This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. You should have received a copy of the GNU Affero General Public License along with this program. If not, see <https://www.gnu.org/licenses/>. */ #include "PICoBoot_Utility.hpp" std::vector<uint8_t> serial_chat(Serial& tty, uint8_t cmd, void *arg, time_t timeout_ms) { size_t ret_len = flasher_cmd_return_length_table[cmd]; std::vector<uint8_t> ret(ret_len); size_t ret_pos = 0; tty.putc(cmd); if (tty.write_all(arg, flasher_cmd_arg_length_table[cmd]) == -1) { throw std::system_error(errno, std::system_category(), "failed to write to serial port"); } if (ret_len) { tty.set_nonblocking(); EventLoop<> el; el.set_idle_time(timeout_ms); el.add(tty, EventType::In); el.on_events([&](auto &event_loop, File &file, EventType event_type, auto &) { auto rc = file.read(ret.data() + ret_pos, ret_len - ret_pos); if (rc > 0) { ret_pos += rc; } else { throw std::system_error(errno, std::system_category(), "failed to read from serial port"); } }); el.on_idle([&](auto &event_loop) { errno = ETIMEDOUT; throw std::system_error(errno, std::system_category(), "timeout reading from serial port"); }); while (ret_pos != ret_len) { el.run_once(); } tty.set_nonblocking(false); } return ret; } |
| You are visitor 01402775 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |