diff --git a/hunks/link.js b/hunks/link.js
index b658cad6989e540a6f82daa1e29384ff8815babb..88afe05111e332270d2915994b4641fa7335c94a 100644
--- a/hunks/link.js
+++ b/hunks/link.js
@@ -167,11 +167,11 @@ function Link() {
let openup = (reqResponse) => {
// exit when already opening, this is called
// whenever an input port is occupied (wanting to send)
- if(isOpening) return
+ if (isOpening) return
// ??
let msg = [LK.HELLO]
MSGS.writeTo(msg, this.ind, 'uint16')
- if(reqResponse){
+ if (reqResponse) {
// if we're already open, we gucc
MSGS.writeTo(msg, true, 'boolean')
//console.log('link trying to open up', msg)
@@ -188,7 +188,7 @@ function Link() {
if (!isActive.value) {
console.error('attempt to put on not-active link')
} else {
- if(!Array.isArray(data)) console.error('non-array put at link')
+ if (!Array.isArray(data)) console.error('non-array put at link')
dtout.put(data)
}
}
@@ -199,14 +199,14 @@ function Link() {
// deserialize msgs: data is an array of bytes
let demsg = (data) => {
- if(!Array.isArray(data)){
+ if (!Array.isArray(data)) {
console.log(data)
throw new Error(`link demsg receives non-array, logged above`)
}
// WRITE IT
let msg = {}
// this is quick here, but in c ...
- if(data[0] === LK.HELLO){
+ if (data[0] === LK.HELLO) {
//console.log('demsg for hello', data)
msg.isHello = true
msg.otherLink = MSGS.readFrom(data, 1, 'uint16').item
@@ -272,24 +272,16 @@ function Link() {
}
// is clear upstream
this.inputs[msg.port].icus = true;
- } else if (msg.isHello){
+ } else if (msg.isHello) {
// HELLO OTHERLINK
// if we're not open, now we are
- if(!isActive.value){
- isOpening = false
+ if (!isActive.value) {
isActive.set(true)
- otherLink.set(msg.otherLink)
- if(msg.reqReturn){
- openup(false)
- }
- } else {
- // have hello, already open ?
- // update, double check
- isOpening = false
- otherLink.set(msg.otherLink)
- if(msg.reqReturn){
- openup(false)
- }
+ }
+ isOpening = false
+ otherLink.set(msg.otherLink)
+ if (msg.reqReturn) {
+ openup(false)
}
} else {
// not an ack or a hello, do regular msg stuff
@@ -330,6 +322,7 @@ function Link() {
for (let o = 1; o < this.outputs.length; o++) {
// if now clear, ack back
if (this.outputs[o].needsAck && !this.outputs[o].io) {
+ // CLEANUP: .needsAck to false -> ack fn ?
this.outputs[o].needsAck = false
ack(o)
}
diff --git a/hunks/manager.js b/hunks/manager.js
index cede9ad7af922b1ad9f9e9c4549a4252675560f3..fcf09f0cc53e74a72d2c17d7d98c06ffbee8f851 100644
--- a/hunks/manager.js
+++ b/hunks/manager.js
@@ -87,12 +87,19 @@ function Manager() {
MSGS.writeTo(bytes, op.name, 'string')
MSGS.writeTo(bytes, op.type, 'string')
let slat = bytes.length
- bytes.push(HK.CONNECTIONS)
- for (let cn of op.connections) {
- //console.log('conn', cn)
- bytes.push(HK.CONNECTION)
- bytes.push(cn.parent.ind)
- bytes.push(cn.findOwnIndex())
+ if(op.connections.length > 0){
+ bytes.push(HK.CONNECTIONS)
+ for (let cn of op.connections) {
+ //console.log('conn', cn)
+ bytes.push(HK.CONNECTION)
+ // yeah yeah ok,
+ let bsixteen = []
+ MSGS.writeTo(bsixteen, cn.parent.ind, 'uint16')
+ MSGS.writeTo(bsixteen, cn.findOwnIndex(), 'uint16')
+ // err here: parent indice may be > 8b wide !
+ // omitting keys,
+ bytes.push(bsixteen[1], bsixteen[2], bsixteen[4], bsixteen[5]);
+ }
}
}
}
@@ -559,7 +566,7 @@ function Manager() {
// i.e. pulling a hunk loads it into that import script hack, that just
// gets evaluated into the dom ...
this.addHunk(strname, state, hnknm).then((hunk) => {
- console.log('MGR successfully added hunk', hunk.name)
+ console.log('successfully added hunk', hunk.name)
// serialize
resp.push(MK.HUNKALIVE)
serializeHunk(hunk, resp)
@@ -751,7 +758,6 @@ function Manager() {
MSGS.writeTo(msg, message, 'string')
writeMessage(msg)
}
-
}
export default Manager
diff --git a/hunks/view.js b/hunks/view.js
index 115816062e2afa63d215c2797da8f715d49f83d3..ad30168859b44e545d590bd1368496eb18a950d9 100644
--- a/hunks/view.js
+++ b/hunks/view.js
@@ -971,8 +971,17 @@ function View() {
let cn = 0
i++
spec.outputs[spec.outputs.length - 1].connections = []
+ console.log("HK B4 CONN")
while (bytes[i] === HK.CONNECTION) {
- spec.outputs[spec.outputs.length - 1].connections[cn] = [bytes[i + 1], bytes[i + 2]]
+ console.log("HK CONNECTION");
+ let frdarr = bytes.slice(i + 1, i + 3).reverse()
+ let fbtarr = Uint8Array.from(frdarr)
+ let fvlarr = new Uint16Array(fbtarr.buffer)
+ i += 2
+ let srdarr = bytes.slice(i + 1, i + 3).reverse()
+ let sbtarr = Uint8Array.from(srdarr)
+ let svlarr = new Uint16Array(sbtarr.buffer)
+ spec.outputs[spec.outputs.length - 1].connections[cn] = [fvlarr[0], svlarr[0]]
i += 3
}
}
diff --git a/typeset.js b/typeset.js
index b4844fcbed9ed81328dccf6421f7cdd695fef9ca..1fbe00ef3b7d56f81363c4f9f0d7891042711b23 100644
--- a/typeset.js
+++ b/typeset.js
@@ -348,7 +348,7 @@ const MK = {
// bzzt
ERR: 254, // (str) message
// heartbeats, wakeup
- HELLO: 253, // (eom)
+ HELLO: 231, // (eom)
// request a top-level description
QUERY: 251, // (eom)
BRIEF: 250, // (str) name of interpreter, # hunks, # links (and then begin firing list back)