Skip to content
This repository has been archived by the owner on Dec 24, 2020. It is now read-only.

Commit

Permalink
Dual VT100 bi-directional communication is now limping along
Browse files Browse the repository at this point in the history
  • Loading branch information
jeffpar committed Aug 16, 2016
1 parent 9a09990 commit 804eb6f
Show file tree
Hide file tree
Showing 8 changed files with 449 additions and 367 deletions.
5 changes: 2 additions & 3 deletions devices/pc8080/machine/vt100/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,8 @@ layout: page
title: DEC VT100 Terminal
permalink: /devices/pc8080/machine/vt100/
machines:
- type: pc8080
id: vt100
debugger: true
- id: vt100
type: pc8080
---

DEC VT100 Terminal
Expand Down
4 changes: 2 additions & 2 deletions devices/pc8080/machine/vt100/debugger/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ layout: page
title: DEC VT100 Terminal with Debugger
permalink: /devices/pc8080/machine/vt100/debugger/
machines:
- type: pc8080
id: vt100
- id: vt100
type: pc8080
debugger: true
---

Expand Down
2 changes: 1 addition & 1 deletion devices/pc8080/machine/vt100/debugger/machine.xml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
<keyboard id="keyboard" model="VT100">
<control type="button" binding="setup" padleft="8px">SET-UP</control>
</keyboard>
<serial id="serial0" adapter="0" binding="print">
<serial id="serialPort" adapter="0" binding="print">
<control type="button" binding="test" value="HELLO WORLD!\r\n" padleft="8px">TEST RECEIVER</control>
</serial>
<panel ref="/devices/pc8080/panel/wide.xml"/>
Expand Down
21 changes: 21 additions & 0 deletions devices/pc8080/machine/vt100/dual/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
---
layout: page
title: Dual VT100 Terminals
permalink: /devices/pc8080/machine/vt100/dual/
machines:
- id: vt100a
type: pc8080
config: /devices/pc8080/machine/vt100/machine.xml
connection: serialPort=vt100b.serialPort
- id: vt100b
type: pc8080
config: /devices/pc8080/machine/vt100/machine.xml
connection: serialPort=vt100a.serialPort
---

Dual VT100 Terminals
--------------------

{% include machine.html id="vt100a" %}

{% include machine.html id="vt100b" %}
2 changes: 1 addition & 1 deletion devices/pc8080/machine/vt100/machine.xml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
<keyboard id="keyboard" model="VT100">
<control type="button" binding="setup" padleft="8px" padbottom="8px">SET-UP</control>
</keyboard>
<serial id="serial0" adapter="0">
<serial id="serialPort" adapter="0">
<control type="button" binding="test" value="HELLO WORLD!\r\n" padleft="8px" padbottom="8px">TEST RECEIVER</control>
</serial>
</machine>
81 changes: 70 additions & 11 deletions modules/pc8080/lib/serialport.js
Original file line number Diff line number Diff line change
Expand Up @@ -85,15 +85,15 @@ function SerialPort(parmsSerial) {
this.consoleOutput = null;

/**
* controlIOBuffer is a DOM element, if any, bound to the port (currently used for output only; see echoByte()).
* controlIOBuffer is a DOM element bound to the port (currently used for output only; see transmitByte()).
*
* @type {Object}
*/
this.controlIOBuffer = null;

/*
* If controlIOBuffer is being used AND 'tabSize' is set, then we make an attempt to monitor the characters
* being echoed via echoByte(), maintain a logical column position, and convert any tabs into the appropriate
* being echoed via transmitByte(), maintain a logical column position, and convert any tabs into the appropriate
* number of spaces.
*
* charBOL, if nonzero, is a character to automatically output at the beginning of every line. This probably
Expand Down Expand Up @@ -123,14 +123,26 @@ function SerialPort(parmsSerial) {
serial.receiveData();
}
}(this);

/*
* No connection until initBus() invokes initConnection().
*/
this.connection = this.sendByte = null;

/*
* Export all functions required by initConnection(); currently, this is the bare minimum, with no flow control.
*/
this['exports'] = {
'receiveByte': this.receiveByte
};
}

/*
* class SerialPort
* property {number} iAdapter
* property {number} portBase
* property {number} nIRQ
* property {Object} controlIOBuffer is a DOM element, if any, bound to the port (for rudimentary output; see echoByte())
* property {Object} controlIOBuffer is a DOM element bound to the port (for rudimentary output; see transmitByte())
*
* NOTE: This class declaration started as a way of informing the code inspector of the controlIOBuffer property,
* which remained undefined until a setBinding() call set it later, but I've since decided that explicitly
Expand Down Expand Up @@ -359,9 +371,47 @@ SerialPort.prototype.initBus = function(cmp, bus, cpu, dbg)
this.chipset = /** @type {ChipSet} */ (cmp.getMachineComponent("ChipSet"));
bus.addPortInputTable(this, SerialPort.aPortInput, this.portBase);
bus.addPortOutputTable(this, SerialPort.aPortOutput, this.portBase);
this.initConnection();
this.setReady();
};

/**
* initConnection()
*
* If a machine 'connection' parameter exists of the form "<sourcePort>=<targetMachine>.<targetPort>",
* and "<sourcePort>" matches our idComponent, then look for a component with id "<targetMachine>.<targetPort>".
*
* If the target component is found, then verify that it has exported functions with the following names:
*
* receiveByte(b): called by us when we have a byte to transmit; aliased internally to sendByte(b)
*
* For now, we're not going to worry about communication in the other direction, because when the target component
* performs its own initConnection(), it will find our receiveByte(b) function, at which point communication in both
* directions should be established.
*
* @this {SerialPort}
*/
SerialPort.prototype.initConnection = function()
{
var sConnection = this.cmp.getMachineParm("connection");
if (sConnection) {
var asParts = sConnection.split('=');
if (asParts.length == 2) {
var sSourceID = str.trim(asParts[0]);
var sTargetID = str.trim(asParts[1]);
if (sSourceID == this.idComponent) {
this.connection = Component.getComponentByID(sTargetID);
if (this.connection) {
var exports = this.connection['exports'];
if (exports) {
this.sendByte = exports['receiveByte'];
}
}
}
}
}
};

/**
* powerUp(data, fRepower)
*
Expand Down Expand Up @@ -545,14 +595,22 @@ SerialPort.prototype.receiveData = function()
};

/**
* echoByte(b)
* transmitByte(b)
*
* @this {SerialPort}
* @param {number} b
* @return {boolean} true if echoed, false if not
* @return {boolean} true if transmitted, false if not
*/
SerialPort.prototype.echoByte = function(b)
SerialPort.prototype.transmitByte = function(b)
{
var fTransmitted = false;

if (this.sendByte) {
if (this.sendByte.call(this.connection, b)) {
fTransmitted = true;
}
}

if (this.controlIOBuffer) {
if (b == 0x0D) {
this.iLogicalCol = 0;
Expand All @@ -577,19 +635,20 @@ SerialPort.prototype.echoByte = function(b)
this.controlIOBuffer.scrollTop = this.controlIOBuffer.scrollHeight;
this.iLogicalCol += nChars;
}
return true;
fTransmitted = true;
}
if (this.consoleOutput != null) {
else if (this.consoleOutput != null) {
if (b == 0x0A || this.consoleOutput.length >= 1024) {
this.println(this.consoleOutput);
this.consoleOutput = "";
}
if (b != 0x0A) {
this.consoleOutput += String.fromCharCode(b);
}
return true;
fTransmitted = true;
}
return false;

return fTransmitted;
};

/**
Expand Down Expand Up @@ -649,7 +708,7 @@ SerialPort.prototype.outData = function(port, bOut, addrFrom)
this.printMessageIO(port, bOut, addrFrom, "DATA");
this.bDataOut = bOut;
this.bStatus &= ~(SerialPort.UART8251.STATUS.XMIT_READY | SerialPort.UART8251.STATUS.XMIT_EMPTY);
if (this.echoByte(bOut)) {
if (this.transmitByte(bOut)) {
this.bStatus |= (SerialPort.UART8251.STATUS.XMIT_READY | SerialPort.UART8251.STATUS.XMIT_EMPTY);
}
};
Expand Down
Loading

0 comments on commit 804eb6f

Please sign in to comment.