Skip to content

Commit

Permalink
working DC11
Browse files Browse the repository at this point in the history
  • Loading branch information
folkertvanheusden committed Jun 10, 2024
1 parent 135a111 commit f7816df
Show file tree
Hide file tree
Showing 15 changed files with 79 additions and 7 deletions.
1 change: 1 addition & 0 deletions ESP32/main.ino
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down
11 changes: 8 additions & 3 deletions comm_tcp_socket_server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down
14 changes: 10 additions & 4 deletions dc11.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,7 @@ dc11::dc11(bus *const b, const std::vector<comm *> & 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()
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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;

Expand Down Expand Up @@ -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)];
Expand Down
2 changes: 2 additions & 0 deletions dc11.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ class dc11: public device
dc11(bus *const b, const std::vector<comm *> & comm_interfaces);
virtual ~dc11();

bool begin();

JsonDocument serialize() const;
static dc11 *deserialize(const JsonVariantConst j, bus *const b);

Expand Down
25 changes: 25 additions & 0 deletions dc11.json
Original file line number Diff line number Diff line change
@@ -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
}
1 change: 1 addition & 0 deletions main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -609,6 +609,7 @@ int main(int argc, char *argv[])
}

dc11 *dc11_ = new dc11(b, comm_interfaces);
dc11_->begin();
b->add_DC11(dc11_);
//

Expand Down
Binary file added work/werkend-mu/base/unix_v7m_rl0.dsk.xz
Binary file not shown.
Binary file added work/werkend-mu/base/unix_v7m_rl1.dsk.xz
Binary file not shown.
12 changes: 12 additions & 0 deletions work/werkend-mu/run-term.sh
Original file line number Diff line number Diff line change
@@ -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
14 changes: 14 additions & 0 deletions work/werkend-mu/run.sh
Original file line number Diff line number Diff line change
@@ -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
Binary file added work/werkend-mu/unix_v7m_rl0.dsk
Binary file not shown.
Binary file added work/werkend-mu/unix_v7m_rl0.dsk.xz
Binary file not shown.
Binary file added work/werkend-mu/unix_v7m_rl1.dsk
Binary file not shown.
Binary file added work/werkend-mu/unix_v7m_rl1.dsk.xz
Binary file not shown.
6 changes: 6 additions & 0 deletions work/werkend-mu/unpack-replace.sh
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit f7816df

Please sign in to comment.