diff --git a/ESP32/main.ino b/ESP32/main.ino index 27a0e51..1c60cc3 100644 --- a/ESP32/main.ino +++ b/ESP32/main.ino @@ -230,6 +230,7 @@ void start_network(console *const c) } dc11 *dc11_ = new dc11(b, comm_interfaces); + dc11_->begin(); b->add_DC11(dc11_); cs->println("* Starting (NTP-) clock"); diff --git a/comm_tcp_socket_server.cpp b/comm_tcp_socket_server.cpp index 57e2e73..c66057f 100644 --- a/comm_tcp_socket_server.cpp +++ b/comm_tcp_socket_server.cpp @@ -224,13 +224,18 @@ void comm_tcp_socket_server::operator()() cfd = accept(fd, nullptr, nullptr); + if (cfd != INVALID_SOCKET) { + set_nodelay(cfd); + + DOLOG(info, false, "Connected with %s", get_endpoint_name(cfd).c_str()); + } + +#if 0 if (setup_telnet_session(cfd) == false) { close(cfd); cfd = INVALID_SOCKET; } - - if (cfd != INVALID_SOCKET) - set_nodelay(cfd); +#endif } DOLOG(info, true, "comm_tcp_socket_server thread terminating"); diff --git a/dc11.cpp b/dc11.cpp index 0e2ef96..4b13034 100644 --- a/dc11.cpp +++ b/dc11.cpp @@ -31,10 +31,7 @@ dc11::dc11(bus *const b, const std::vector & comm_interfaces): b(b), comm_interfaces(comm_interfaces) { - connected.resize(comm_interfaces.size()); - - // TODO move to begin() - th = new std::thread(std::ref(*this)); + connected.resize(4); // FIXME keep same size as comm_interfaces } dc11::~dc11() @@ -78,6 +75,13 @@ void dc11::show_state(console *const cnsl) const } } +bool dc11::begin() +{ + th = new std::thread(std::ref(*this)); + + return true; +} + void dc11::test_port(const size_t nr, const std::string & txt) const { DOLOG(info, false, "DC11 test line %zu", nr); @@ -115,6 +119,7 @@ void dc11::operator()() if (is_connected != connected[line_nr]) { DOLOG(debug, false, "DC11 line %d state changed to %d", line_nr, is_connected); + Serial.printf("DC11 line %d state changed to %d\r\n", line_nr, is_connected); connected[line_nr] = is_connected; @@ -306,6 +311,7 @@ dc11 *dc11::deserialize(const JsonVariantConst j, bus *const b) interfaces.push_back(comm::deserialize(v, b)); dc11 *r = new dc11(b, interfaces); + r->begin(); for(int regnr=0; regnr<4; regnr++) r->registers[regnr] = j[format("register-%d", regnr)]; diff --git a/dc11.h b/dc11.h index 96563d9..63d9e8f 100644 --- a/dc11.h +++ b/dc11.h @@ -46,6 +46,8 @@ class dc11: public device dc11(bus *const b, const std::vector & comm_interfaces); virtual ~dc11(); + bool begin(); + JsonDocument serialize() const; static dc11 *deserialize(const JsonVariantConst j, bus *const b); diff --git a/dc11.json b/dc11.json new file mode 100644 index 0000000..7ff93e4 --- /dev/null +++ b/dc11.json @@ -0,0 +1,25 @@ +{ + "interfaces": [ + { + "comm-backend-type": "tcp-server", + "port": 1100 + }, + { + "comm-backend-type": "tcp-server", + "port": 1101 + }, + { + "comm-backend-type": "tcp-server", + "port": 1102 + }, + { + "comm-backend-type": "posix", + "device": "/tmp/virtualcom0", + "bitrate": 38400 + } + ], + "register-0": 0, + "register-1": 0, + "register-2": 0, + "register-3": 0 +} \ No newline at end of file diff --git a/main.cpp b/main.cpp index e708dcc..fba632a 100644 --- a/main.cpp +++ b/main.cpp @@ -609,6 +609,7 @@ int main(int argc, char *argv[]) } dc11 *dc11_ = new dc11(b, comm_interfaces); + dc11_->begin(); b->add_DC11(dc11_); // diff --git a/work/werkend-mu/base/unix_v7m_rl0.dsk.xz b/work/werkend-mu/base/unix_v7m_rl0.dsk.xz new file mode 100644 index 0000000..f45c5c0 Binary files /dev/null and b/work/werkend-mu/base/unix_v7m_rl0.dsk.xz differ diff --git a/work/werkend-mu/base/unix_v7m_rl1.dsk.xz b/work/werkend-mu/base/unix_v7m_rl1.dsk.xz new file mode 100644 index 0000000..986da51 Binary files /dev/null and b/work/werkend-mu/base/unix_v7m_rl1.dsk.xz differ diff --git a/work/werkend-mu/run-term.sh b/work/werkend-mu/run-term.sh new file mode 100755 index 0000000..3c59356 --- /dev/null +++ b/work/werkend-mu/run-term.sh @@ -0,0 +1,12 @@ +#! /bin/sh + +echo boot +echo 'rl(0,0)munix' + +rm ~/temp/ramdisk/test2.log + +RS=128 + +echo 'socat TCP-LISTEN:2334,reuseaddr pty,link=/tmp/virtualcom0,raw' + +./build/kek -r work/werkend-mu/unix_v7m_rl0.dsk -r work/werkend-mu/unix_v7m_rl1.dsk -b -S $RS -L info,debug -l ~/temp/ramdisk/test2.log -P -1 /tmp/virtualcom0 -d # -t diff --git a/work/werkend-mu/run.sh b/work/werkend-mu/run.sh new file mode 100755 index 0000000..b7d758c --- /dev/null +++ b/work/werkend-mu/run.sh @@ -0,0 +1,14 @@ +#! /bin/sh + +echo boot +echo 'rl(0,0)unix' + +rm ~/temp/ramdisk/test2.log + +if [ "$1" = "fast" ] ; then +./build/kek -r work/werkend-mu/unix_v7m_rl0.dsk -r work/werkend-mu/unix_v7m_rl1.dsk -b -S 256 -L error,info -l ~/temp/ramdisk/test2.log -P +elif [ "$1" = "medium" ] ; then +./build/kek -r work/werkend-mu/unix_v7m_rl0.dsk -r work/werkend-mu/unix_v7m_rl1.dsk -b -L error,info -l ~/temp/ramdisk/test2.log -d -S 256 -P +else +./build/kek -r work/werkend-mu/unix_v7m_rl0.dsk -r work/werkend-mu/unix_v7m_rl1.dsk -b -L error,debug -l ~/temp/ramdisk/test2.log -d -t -X -S 256 -P +fi diff --git a/work/werkend-mu/unix_v7m_rl0.dsk b/work/werkend-mu/unix_v7m_rl0.dsk new file mode 100644 index 0000000..c36ce36 Binary files /dev/null and b/work/werkend-mu/unix_v7m_rl0.dsk differ diff --git a/work/werkend-mu/unix_v7m_rl0.dsk.xz b/work/werkend-mu/unix_v7m_rl0.dsk.xz new file mode 100644 index 0000000..705f32e Binary files /dev/null and b/work/werkend-mu/unix_v7m_rl0.dsk.xz differ diff --git a/work/werkend-mu/unix_v7m_rl1.dsk b/work/werkend-mu/unix_v7m_rl1.dsk new file mode 100644 index 0000000..05f0d51 Binary files /dev/null and b/work/werkend-mu/unix_v7m_rl1.dsk differ diff --git a/work/werkend-mu/unix_v7m_rl1.dsk.xz b/work/werkend-mu/unix_v7m_rl1.dsk.xz new file mode 100644 index 0000000..986da51 Binary files /dev/null and b/work/werkend-mu/unix_v7m_rl1.dsk.xz differ diff --git a/work/werkend-mu/unpack-replace.sh b/work/werkend-mu/unpack-replace.sh new file mode 100755 index 0000000..b9c02ec --- /dev/null +++ b/work/werkend-mu/unpack-replace.sh @@ -0,0 +1,6 @@ +#! /bin/sh + +cd /home/folkert/Projects/PDP-11/work/werkend-mu + +xzcat unix_v7m_rl0.dsk.xz > unix_v7m_rl0.dsk +xzcat unix_v7m_rl1.dsk.xz > unix_v7m_rl1.dsk