st-one-io / node-open-protocol

This node is an implementation of the Atlas Copco's Open Protocol. This node was created by Smart-Tech as part of the ST-One project.
GNU General Public License v3.0
39 stars 38 forks source link

Support for MID900 #45

Open alexmc1510 opened 1 year ago

alexmc1510 commented 1 year ago

Hello,

I have a machine in my lab. If someone helps we can work on it. I have tried several combinations of MID0008 with MID0900 but does not work.

Regards,

ferm10n commented 1 year ago

Hey! So, you said you get an error on this over here https://github.com/st-one-io/node-open-protocol/issues/40

Can you do what you're trying and share a debug log? To enable it, set the environment variable NODE_DEBUG=open-protocol

alexmc1510 commented 1 year ago

Hello, thank you very much for your support.

Here is the code I am executing, trying to get the traces with MID0900:

const openProtocol = require('node-open-protocol');

let op = openProtocol.createClient(4545, "192.168.0.199", () => {
    console.log("Connected!");

let opts = {
    mid: 8,
    revision: 1,
    payload: "09000013500000000000000000000000000000001001"
}
    op.on("data", (data) => {
        console.log("Data received", data);        
    });

    op.sendMid(8, opts, (err) => {

        if (err) {
            console.log("Error", err);
            return;
        }

    });

    });

And here you are the log:

node C:\Users\alex\node_modules\node-open-protocol\test\alex.js
OPEN-PROTOCOL 7564: new SessionControlClient
OPEN-PROTOCOL 7564: new LinkLayer {
  stream: <ref *1> Socket {
    connecting: true,
    _hadError: false,
    _parent: null,
    _host: null,
    _closeAfterHandlingError: false,
    _readableState: ReadableState {
      objectMode: false,
      highWaterMark: 16384,
      buffer: BufferList { head: null, tail: null, length: 0 },
      length: 0,
      pipes: [],
      flowing: null,
      ended: false,
      endEmitted: false,
      reading: false,
      constructed: true,
      sync: true,
      needReadable: false,
      emittedReadable: false,
      readableListening: false,
      resumeScheduled: false,
      errorEmitted: false,
      emitClose: false,
      autoDestroy: true,
      destroyed: false,
      errored: null,
      closed: false,
      closeEmitted: false,
      defaultEncoding: 'utf8',
      awaitDrainWriters: null,
      multiAwaitDrain: false,
      readingMore: false,
      dataEmitted: false,
      decoder: null,
      encoding: null,
      [Symbol(kPaused)]: null
    },
    _events: [Object: null prototype] {
      end: [Function: onReadableStreamEnd],
      connect: [Function],
      timeout: [Function]
    },
    _eventsCount: 3,
    _maxListeners: undefined,
    _writableState: WritableState {
      objectMode: false,
      highWaterMark: 16384,
      finalCalled: false,
      needDrain: false,
      ending: false,
      ended: false,
      finished: false,
      destroyed: false,
      decodeStrings: false,
      defaultEncoding: 'utf8',
      length: 0,
      writing: false,
      corked: 0,
      sync: true,
      bufferProcessing: false,
      onwrite: [Function: bound onwrite],
      writecb: null,
      writelen: 0,
      afterWriteTickInfo: null,
      buffered: [],
      bufferedIndex: 0,
      allBuffers: true,
      allNoop: true,
      pendingcb: 0,
      constructed: true,
      prefinished: false,
      errorEmitted: false,
      emitClose: false,
      autoDestroy: true,
      errored: null,
      closed: false,
      closeEmitted: false,
      [Symbol(kOnFinished)]: []
    },
    allowHalfOpen: false,
    _sockname: null,
    _pendingData: null,
    _pendingEncoding: '',
    server: null,
    _server: null,
    timeout: 20000,
    [Symbol(async_id_symbol)]: 2,
    [Symbol(kHandle)]: TCP {
      reading: false,
      onconnection: null,
      [Symbol(owner_symbol)]: [Circular *1]
    },
    [Symbol(lastWriteQueueSize)]: 0,
    [Symbol(timeout)]: Timeout {
      _idleTimeout: 20000,
      _idlePrev: [TimersList],
      _idleNext: [TimersList],
      _idleStart: 123,
      _onTimeout: [Function: bound ],
      _timerArgs: undefined,
      _repeat: null,
      _destroyed: false,
      [Symbol(refed)]: false,
      [Symbol(kHasPrimitive)]: false,
      [Symbol(asyncId)]: 4,
      [Symbol(triggerId)]: 1
    },
    [Symbol(kBuffer)]: null,
    [Symbol(kBufferCb)]: null,
    [Symbol(kBufferGen)]: null,
    [Symbol(kCapture)]: false,
    [Symbol(kSetNoDelay)]: false,
    [Symbol(kSetKeepAlive)]: false,
    [Symbol(kSetKeepAliveInitialDelay)]: 0,
    [Symbol(kBytesRead)]: 0,
    [Symbol(kBytesWritten)]: 0
  },
  timeOut: undefined,
  retryTimes: undefined,
  rawData: undefined,
  disableMidParsing: undefined
}
OPEN-PROTOCOL 7564: new OpenProtocolParser
OPEN-PROTOCOL 7564: new openProtocolSerializer
OPEN-PROTOCOL 7564: new MIDParser
OPEN-PROTOCOL 7564: new MIDSerializer
OPEN-PROTOCOL 7564: SessionControlClient connect
OPEN-PROTOCOL 7564: SessionControlClient sendMidOne
OPEN-PROTOCOL 7564: LinkLayer _write { mid: 1, revision: 6 }
OPEN-PROTOCOL 7564: MIDSerializer _transform { mid: 1, revision: 6 }
OPEN-PROTOCOL 7564: LinkLayer _onDataMidSerializer { mid: 1, revision: 6, payload: <Buffer > }
OPEN-PROTOCOL 7564: openProtocolSerializer _transform { mid: 1, revision: 6, payload: <Buffer > }
OPEN-PROTOCOL 7564: openProtocolSerializer _transform publish <Buffer 30 30 32 30 30 30 30 31 30 30 36 30 30 31 30 31 30 30 30 30 00>
OPEN-PROTOCOL 7564: LinkLayer _onDataOpSerializer <Buffer 30 30 32 30 30 30 30 31 30 30 36 30 30 31 30 31 30 30 30 30 00>
OPEN-PROTOCOL 7564: LinkLayer _read 16
OPEN-PROTOCOL 7564: LinkLayer _onDataStream <Buffer 30 32 32 31 30 30 30 32 30 30 36 20 30 31 30 31 20 20 20 20 30 31 30 30 30 30 30 32 30 30 30 33 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 ... 172 more bytes>
OPEN-PROTOCOL 7564: OpenProtocolParser _transform <Buffer 30 32 32 31 30 30 30 32 30 30 36 20 30 31 30 31 20 20 20 20 30 31 30 30 30 30 30 32 30 30 30 33 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 ... 172 more bytes>
OPEN-PROTOCOL 7564: LinkLayer _onDataOpParser {
  mid: 2,
  revision: 6,
  noAck: false,
  stationID: 1,
  spindleID: 1,
  sequenceNumber: 0,
  messageParts: 0,
  messageNumber: 0,
  payload: <Buffer 30 31 30 30 30 30 30 32 30 30 30 33 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 30 34 41 43 54 30 35 76 32 2e 30 20 20 ... 151 more bytes>
}
OPEN-PROTOCOL 7564: new MIDParser _transform {
  mid: 2,
  revision: 6,
  noAck: false,
  stationID: 1,
  spindleID: 1,
  sequenceNumber: 0,
  messageParts: 0,
  messageNumber: 0,
  payload: <Buffer 30 31 30 30 30 30 30 32 30 30 30 33 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 30 34 41 43 54 30 35 76 32 2e 30 20 20 ... 151 more bytes>
}
OPEN-PROTOCOL 7564: LinkLayer _onDataMidParser {
  mid: 2,
  revision: 6,
  noAck: false,
  stationID: 1,
  spindleID: 1,
  sequenceNumber: 0,
  messageParts: 0,
  messageNumber: 0,
  payload: {
    cellID: 0,
    channelID: 0,
    controllerName: '',
    supplierCode: 'ACT',
    openProtocolVersion: 'v2.0',
    controllerSoftwareVersion: 'IXB_R_3.6.13.10880_',
    toolSoftwareVersion: '3.6.13',
    rbuType: 'None',
    controllerSerialNumber: 'A3500191',
    systemType: 3,
    systemSubtype: 1,
    sequenceNumberSupport: 0,
    linkingHandlingSupport: 0
  }
}
OPEN-PROTOCOL 7564: SessionControlClient receivedReply {
  mid: 2,
  revision: 6,
  noAck: false,
  stationID: 1,
  spindleID: 1,
  sequenceNumber: 0,
  messageParts: 0,
  messageNumber: 0,
  payload: {
    cellID: 0,
    channelID: 0,
    controllerName: '',
    supplierCode: 'ACT',
    openProtocolVersion: 'v2.0',
    controllerSoftwareVersion: 'IXB_R_3.6.13.10880_',
    toolSoftwareVersion: '3.6.13',
    rbuType: 'None',
    controllerSerialNumber: 'A3500191',
    systemType: 3,
    systemSubtype: 1,
    sequenceNumberSupport: 0,
    linkingHandlingSupport: 0
  }
}
OPEN-PROTOCOL 7564: LinkLayer finishCycle undefined
OPEN-PROTOCOL 7564: LinkLayer deactivateLinkLayer
OPEN-PROTOCOL 7564: SessionControlClient _sendingProcess
Connected!
OPEN-PROTOCOL 7564: SessionControlClient _sendMid 8 {
  mid: 8,
  revision: 1,
  payload: '09000013500000000000000000000000000000001001'
}
OPEN-PROTOCOL 7564: SessionControlClient new Message
OPEN-PROTOCOL 7564: SessionControlClient _sendingProcess
OPEN-PROTOCOL 7564: SessionControlClient _transmitMid Message {
  _mid: {
    mid: 8,
    revision: 1,
    payload: '09000013500000000000000000000000000000001001'
  },
  _callback: [Function (anonymous)],
  _type: 'manual',
  _group: undefined,
  _baseMid: {
    mid: 8,
    revision: 1,
    payload: '09000013500000000000000000000000000000001001'
  }
}
OPEN-PROTOCOL 7564: SessionControlClient _calcRevision undefined undefined undefined undefined
OPEN-PROTOCOL 7564: LinkLayer _write {
  mid: 8,
  revision: 1,
  payload: '09000013500000000000000000000000000000001001'
}
OPEN-PROTOCOL 7564: MIDSerializer _transform {
  mid: 8,
  revision: 1,
  payload: '09000013500000000000000000000000000000001001'
}
node:buffer:410
    throw new ERR_INVALID_ARG_VALUE.RangeError('size', size);
    ^

RangeError [ERR_INVALID_ARG_VALUE]: The argument 'size' is invalid. Received NaN
    at Function.alloc (node:buffer:419:3)
    at Object.serializer (C:\Users\alex\node_modules\node-open-protocol\src\mid\0008.js:61:26)
    at MIDSerializer._transform (C:\Users\alex\node_modules\node-open-protocol\src\MIDSerializer.js:39:29)
    at Transform._write (node:internal/streams/transform:175:8)
    at writeOrBuffer (node:internal/streams/writable:392:12)
    at _write (node:internal/streams/writable:333:10)
    at Writable.write (node:internal/streams/writable:337:10)
    at LinkLayer._write (C:\Users\alex\node_modules\node-open-protocol\src\linkLayer.js:344:28)
    at writeOrBuffer (node:internal/streams/writable:392:12)
    at _write (node:internal/streams/writable:333:10) {
  code: 'ERR_INVALID_ARG_VALUE'
}

Node.js v18.16.0

If I use the Open Protocol Interface Tester, here you are part of the result because MID0900 also contains binary data in the last part of the telegram (I captured it with Wireshark):

2023-4-5:19:43:8:768 Generic Data Subscribe
To PF   30 30 36 34 30 30 30 38  30 30 31 30 20 20 20 20  00640008 0010    
Tö PF   30 30 20 20 30 39 30 30  30 30 31 33 35 30 30 30  00  0900 00135000
Tö PF   30 30 30 30 30 30 30 30  30 30 30 30 30 30 30 30  00000000 00000000
Tö PF   30 30 30 30 30 30 30 30  30 30 30 30 31 30 30 31  00000000 00001001
Tö PF   00 

2023-4-5:19:43:8:782 Command Accepted
From PF 30 30 32 34 30 30 30 35  30 30 31 20 30 30 30 30  00240005 001 0000
Fröm PF 20 20 20 20 30 30 30 38  00                           0008 .

2023-4-5:19:46:28:949 Trace curve
From PF 31 33 32 35 30 39 30 30  30 30 31 20 30 30 30 30  13250900 001 0000
Fröm PF 20 20 20 20 30 30 30 30  30 30 30 31 30 34 32 30      0000 00010420
Fröm PF 32 33 2d 30 34 2d 30 35  3a 31 39 3a 34 35 3a 31  23-04-05 :19:45:1
Fröm PF 33 30 30 30 30 31 30 31  30 35 30 30 30 36 30 31  30000101 05000601
Fröm PF 30 30 30 30 30 31 30 31  30 30 30 30 30 30 30 31  00000101 00000001
Fröm PF 30 30 30 31 30 30 30 30  30 34 30 30 30 30 30 30  00010000 04000000
Fröm PF 30 30 31 32 30 32 30 30  38 30 34 30 30 30 30 30  00120200 80400000
Fröm PF 30 30 41 33 34 33 32 38  36 37 30 30 30 35 31 30  00A34328 67000510
Fröm PF 30 33 30 31 30 30 30 30  30 30 30 31 30 34 30 30  03010000 00010400
Fröm PF 30 35 33 30 31 30 30 31  30 30 30 30 30 30 30 31  05301001 00000001
Fröm PF 36 38 30 37 32 33 39 31  33 30 32 32 31 34 30 30  68072391 30221400
Fröm PF 38 30 33 30 30 30 30 30  30 30 30 2e 31 31 31 36  80300000 000.1116
Fröm PF 37 32 30 30 31 30 30 30  30 30 30 30 35 34 37 30  72001000 00005470
Fröm PF 30 38 30 33 32 30 32 32  2e 30 30 30 30 30 30 30  08032022 .0000000
Fröm PF 30 35 34 38 00                                    0548.
ferm10n commented 1 year ago

From your log, it looks like it breaks down when mid 8 is getting serialized into a buffer.

RangeError [ERR_INVALID_ARG_VALUE]: The argument 'size' is invalid. Received NaN

Is referencing this call: https://github.com/st-one-io/node-open-protocol/blob/f514d00d5ddc7b0d84f222c2e481e2a07cf16c91/src/mid/0008.js#L61

Which means that 9 + msg.payload.dataLength evaluates to NaN.

It looks like the object payload you're providing to sendMid is incorrect. Try passing it an object that matches this https://github.com/st-one-io/node-open-protocol/blob/f514d00d5ddc7b0d84f222c2e481e2a07cf16c91/src/mid/0008.js#L10-L14

More examples can be found in the unit tests for mid 8: https://github.com/st-one-io/node-open-protocol/blob/master/test/0008.spec.js


What is this Open Protocol Interface Tester? I haven't heard of this tool before but it sounds useful haha

alexmc1510 commented 1 year ago

Same error....

const openProtocol = require('node-open-protocol');

//* @param {object} MID0008 
//* @param {number} MID0008.midNumber 
//* @param {number} MID0008.revision 
//* @param {number} MID0008.dataLength 
//* @param {string} MID0008.extraData 

let op = openProtocol.createClient(4545, "192.168.0.199", () => {
    console.log("Connected!");

//To MIDs not implemented
let opts = {
    midNumber: 900,
    revision: 1,
    dataLength: 35,
    extraData: "00000000000000000000000000000001001"
}
    op.on("data", (data) => {
        console.log("Data received", data);        
    });

    op.sendMid(8, opts, (err) => {

        if (err) {
            console.log("Error", err);
            return;
        }

    });

    });
node C:\Users\C41581\node_modules\node-open-protocol\test\alex.js
OPEN-PROTOCOL 7208: new SessionControlClient
OPEN-PROTOCOL 7208: new LinkLayer {
  stream: <ref *1> Socket {
    connecting: true,
    _hadError: false,
    _parent: null,
    _host: null,
    _closeAfterHandlingError: false,
    _readableState: ReadableState {
      objectMode: false,
      highWaterMark: 16384,
      buffer: BufferList { head: null, tail: null, length: 0 },
      length: 0,
      pipes: [],
      flowing: null,
      ended: false,
      endEmitted: false,
      reading: false,
      constructed: true,
      sync: true,
      needReadable: false,
      emittedReadable: false,
      readableListening: false,
      resumeScheduled: false,
      errorEmitted: false,
      emitClose: false,
      autoDestroy: true,
      destroyed: false,
      errored: null,
      closed: false,
      closeEmitted: false,
      defaultEncoding: 'utf8',
      awaitDrainWriters: null,
      multiAwaitDrain: false,
      readingMore: false,
      dataEmitted: false,
      decoder: null,
      encoding: null,
      [Symbol(kPaused)]: null
    },
    _events: [Object: null prototype] {
      end: [Function: onReadableStreamEnd],
      connect: [Function],
      timeout: [Function]
    },
    _eventsCount: 3,
    _maxListeners: undefined,
    _writableState: WritableState {
      objectMode: false,
      highWaterMark: 16384,
      finalCalled: false,
      needDrain: false,
      ending: false,
      ended: false,
      finished: false,
      destroyed: false,
      decodeStrings: false,
      defaultEncoding: 'utf8',
      length: 0,
      writing: false,
      corked: 0,
      sync: true,
      bufferProcessing: false,
      onwrite: [Function: bound onwrite],
      writecb: null,
      writelen: 0,
      afterWriteTickInfo: null,
      buffered: [],
      bufferedIndex: 0,
      allBuffers: true,
      allNoop: true,
      pendingcb: 0,
      constructed: true,
      prefinished: false,
      errorEmitted: false,
      emitClose: false,
      autoDestroy: true,
      errored: null,
      closed: false,
      closeEmitted: false,
      [Symbol(kOnFinished)]: []
    },
    allowHalfOpen: false,
    _sockname: null,
    _pendingData: null,
    _pendingEncoding: '',
    server: null,
    _server: null,
    timeout: 20000,
    [Symbol(async_id_symbol)]: 2,
    [Symbol(kHandle)]: TCP {
      reading: false,
      onconnection: null,
      [Symbol(owner_symbol)]: [Circular *1]
    },
    [Symbol(lastWriteQueueSize)]: 0,
    [Symbol(timeout)]: Timeout {
      _idleTimeout: 20000,
      _idlePrev: [TimersList],
      _idleNext: [TimersList],
      _idleStart: 118,
      _onTimeout: [Function: bound ],
      _timerArgs: undefined,
      _repeat: null,
      _destroyed: false,
      [Symbol(refed)]: false,
      [Symbol(kHasPrimitive)]: false,
      [Symbol(asyncId)]: 4,
      [Symbol(triggerId)]: 1
    },
    [Symbol(kBuffer)]: null,
    [Symbol(kBufferCb)]: null,
    [Symbol(kBufferGen)]: null,
    [Symbol(kCapture)]: false,
    [Symbol(kSetNoDelay)]: false,
    [Symbol(kSetKeepAlive)]: false,
    [Symbol(kSetKeepAliveInitialDelay)]: 0,
    [Symbol(kBytesRead)]: 0,
    [Symbol(kBytesWritten)]: 0
  },
  timeOut: undefined,
  retryTimes: undefined,
  rawData: undefined,
  disableMidParsing: undefined
}
OPEN-PROTOCOL 7208: new OpenProtocolParser
OPEN-PROTOCOL 7208: new openProtocolSerializer
OPEN-PROTOCOL 7208: new MIDParser
OPEN-PROTOCOL 7208: new MIDSerializer
OPEN-PROTOCOL 7208: SessionControlClient connect
OPEN-PROTOCOL 7208: SessionControlClient sendMidOne
OPEN-PROTOCOL 7208: LinkLayer _write { mid: 1, revision: 6 }
OPEN-PROTOCOL 7208: MIDSerializer _transform { mid: 1, revision: 6 }
OPEN-PROTOCOL 7208: LinkLayer _onDataMidSerializer { mid: 1, revision: 6, payload: <Buffer > }
OPEN-PROTOCOL 7208: openProtocolSerializer _transform { mid: 1, revision: 6, payload: <Buffer > }
OPEN-PROTOCOL 7208: openProtocolSerializer _transform publish <Buffer 30 30 32 30 30 30 30 31 30 30 36 30 30 31 30 31 30 30 30 30 00>
OPEN-PROTOCOL 7208: LinkLayer _onDataOpSerializer <Buffer 30 30 32 30 30 30 30 31 30 30 36 30 30 31 30 31 30 30 30 30 00>
OPEN-PROTOCOL 7208: LinkLayer _read 16
OPEN-PROTOCOL 7208: LinkLayer _onDataStream <Buffer 30 32 32 31 30 30 30 32 30 30 36 20 30 31 30 31 20 20 20 20 30 31 30 30 30 30 30 32 30 30 30 33 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 ... 172 more bytes>
OPEN-PROTOCOL 7208: OpenProtocolParser _transform <Buffer 30 32 32 31 30 30 30 32 30 30 36 20 30 31 30 31 20 20 20 20 30 31 30 30 30 30 30 32 30 30 30 33 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 ... 172 more bytes>
OPEN-PROTOCOL 7208: LinkLayer _onDataOpParser {
  mid: 2,
  revision: 6,
  noAck: false,
  stationID: 1,
  spindleID: 1,
  sequenceNumber: 0,
  messageParts: 0,
  messageNumber: 0,
  payload: <Buffer 30 31 30 30 30 30 30 32 30 30 30 33 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 30 34 41 43 54 30 35 76 32 2e 30 20 20 ... 151 more bytes>
}
OPEN-PROTOCOL 7208: new MIDParser _transform {
  mid: 2,
  revision: 6,
  noAck: false,
  stationID: 1,
  spindleID: 1,
  sequenceNumber: 0,
  messageParts: 0,
  messageNumber: 0,
  payload: <Buffer 30 31 30 30 30 30 30 32 30 30 30 33 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 30 34 41 43 54 30 35 76 32 2e 30 20 20 ... 151 more bytes>
}
OPEN-PROTOCOL 7208: LinkLayer _onDataMidParser {
  mid: 2,
  revision: 6,
  noAck: false,
  stationID: 1,
  spindleID: 1,
  sequenceNumber: 0,
  messageParts: 0,
  messageNumber: 0,
  payload: {
    cellID: 0,
    channelID: 0,
    controllerName: '',
    supplierCode: 'ACT',
    openProtocolVersion: 'v2.0',
    controllerSoftwareVersion: 'IXB_R_3.6.13.10880_',
    toolSoftwareVersion: '3.6.13',
    rbuType: 'None',
    controllerSerialNumber: 'A3500191',
    systemType: 3,
    systemSubtype: 1,
    sequenceNumberSupport: 0,
    linkingHandlingSupport: 0
  }
}
OPEN-PROTOCOL 7208: SessionControlClient receivedReply {
  mid: 2,
  revision: 6,
  noAck: false,
  stationID: 1,
  spindleID: 1,
  sequenceNumber: 0,
  messageParts: 0,
  messageNumber: 0,
  payload: {
    cellID: 0,
    channelID: 0,
    controllerName: '',
    supplierCode: 'ACT',
    openProtocolVersion: 'v2.0',
    controllerSoftwareVersion: 'IXB_R_3.6.13.10880_',
    toolSoftwareVersion: '3.6.13',
    rbuType: 'None',
    controllerSerialNumber: 'A3500191',
    systemType: 3,
    systemSubtype: 1,
    sequenceNumberSupport: 0,
    linkingHandlingSupport: 0
  }
}
OPEN-PROTOCOL 7208: LinkLayer finishCycle undefined
OPEN-PROTOCOL 7208: LinkLayer deactivateLinkLayer
OPEN-PROTOCOL 7208: SessionControlClient _sendingProcess
Connected!
OPEN-PROTOCOL 7208: SessionControlClient _sendMid 8 {
  midNumber: 900,
  revision: 1,
  dataLength: 35,
  extraData: '00000000000000000000000000000001001'
}
OPEN-PROTOCOL 7208: SessionControlClient new Message
OPEN-PROTOCOL 7208: SessionControlClient _sendingProcess
OPEN-PROTOCOL 7208: SessionControlClient _transmitMid Message {
  _mid: {
    midNumber: 900,
    revision: 1,
    dataLength: 35,
    extraData: '00000000000000000000000000000001001',
    payload: '',
    mid: 8
  },
  _callback: [Function (anonymous)],
  _type: 'manual',
  _group: undefined,
  _baseMid: {
    midNumber: 900,
    revision: 1,
    dataLength: 35,
    extraData: '00000000000000000000000000000001001',
    payload: '',
    mid: 8
  }
}
OPEN-PROTOCOL 7208: SessionControlClient _calcRevision undefined undefined undefined undefined
OPEN-PROTOCOL 7208: LinkLayer _write {
  midNumber: 900,
  revision: 1,
  dataLength: 35,
  extraData: '00000000000000000000000000000001001',
  payload: '',
  mid: 8
}
OPEN-PROTOCOL 7208: MIDSerializer _transform {
  midNumber: 900,
  revision: 1,
  dataLength: 35,
  extraData: '00000000000000000000000000000001001',
  payload: '',
  mid: 8
}
node:buffer:410
    throw new ERR_INVALID_ARG_VALUE.RangeError('size', size);
    ^

RangeError [ERR_INVALID_ARG_VALUE]: The argument 'size' is invalid. Received NaN
    at Function.alloc (node:buffer:419:3)
    at Object.serializer (C:\Users\C41581\node_modules\node-open-protocol\src\mid\0008.js:61:26)
    at MIDSerializer._transform (C:\Users\C41581\node_modules\node-open-protocol\src\MIDSerializer.js:39:29)
    at Transform._write (node:internal/streams/transform:175:8)
    at writeOrBuffer (node:internal/streams/writable:392:12)
    at _write (node:internal/streams/writable:333:10)
    at Writable.write (node:internal/streams/writable:337:10)
    at LinkLayer._write (C:\Users\C41581\node_modules\node-open-protocol\src\linkLayer.js:344:28)
    at writeOrBuffer (node:internal/streams/writable:392:12)
    at _write (node:internal/streams/writable:333:10) {
  code: 'ERR_INVALID_ARG_VALUE'
}

Node.js v18.16.0
alexmc1510 commented 1 year ago

Let me know if you would like to test/debug in real time. I can always share the screen during a meeting. The error of the buffer is the one I detected but I don't know why...

alexmc1510 commented 1 year ago

Hello!!! Super good news!! A manage to make it work in a "manual" mode, ignoring parsing and serializing functions, however, I only receive the first trace and the program stop with an error:

log ``` //@ts-check /* Copyright: (c) 2018-2020, Smart-Tech Controle e Automação GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) */ function parser(msg, opts, cb) { let buffer = msg.payload; msg.payload = buffer.toString("ascii"); cb(null, msg); } function serializer(msg, opts, cb) { let buf = Buffer.from("09000013500000000000000000000000000000001001"); msg.payload = buf; cb(null, msg); } function revision() { return [1]; } module.exports = { parser, serializer, revision }; ``` And the new error related to the socket.... ``` OPEN-PROTOCOL 10352: new SessionControlClient OPEN-PROTOCOL 10352: new LinkLayer { stream: Socket { connecting: true, _hadError: false, _parent: null, _host: null, _closeAfterHandlingError: false, _readableState: ReadableState { objectMode: false, highWaterMark: 16384, buffer: BufferList { head: null, tail: null, length: 0 }, length: 0, pipes: [], flowing: null, ended: false, endEmitted: false, reading: false, constructed: true, sync: true, needReadable: false, emittedReadable: false, readableListening: false, resumeScheduled: false, errorEmitted: false, emitClose: false, autoDestroy: true, destroyed: false, errored: null, closed: false, closeEmitted: false, defaultEncoding: 'utf8', awaitDrainWriters: null, multiAwaitDrain: false, readingMore: false, dataEmitted: false, decoder: null, encoding: null, [Symbol(kPaused)]: null }, _events: [Object: null prototype] { end: [Function: onReadableStreamEnd], connect: [Function], timeout: [Function] }, _eventsCount: 3, _maxListeners: undefined, _writableState: WritableState { objectMode: false, highWaterMark: 16384, finalCalled: false, needDrain: false, ending: false, ended: false, finished: false, destroyed: false, decodeStrings: false, defaultEncoding: 'utf8', length: 0, writing: false, corked: 0, sync: true, bufferProcessing: false, onwrite: [Function: bound onwrite], writecb: null, writelen: 0, afterWriteTickInfo: null, buffered: [], bufferedIndex: 0, allBuffers: true, allNoop: true, pendingcb: 0, constructed: true, prefinished: false, errorEmitted: false, emitClose: false, autoDestroy: true, errored: null, closed: false, closeEmitted: false, [Symbol(kOnFinished)]: [] }, allowHalfOpen: false, _sockname: null, _pendingData: null, _pendingEncoding: '', server: null, _server: null, timeout: 20000, [Symbol(async_id_symbol)]: 2, [Symbol(kHandle)]: TCP { reading: false, onconnection: null, [Symbol(owner_symbol)]: [Circular *1] }, [Symbol(lastWriteQueueSize)]: 0, [Symbol(timeout)]: Timeout { _idleTimeout: 20000, _idlePrev: [TimersList], _idleNext: [TimersList], _idleStart: 121, _onTimeout: [Function: bound ], _timerArgs: undefined, _repeat: null, _destroyed: false, [Symbol(refed)]: false, [Symbol(kHasPrimitive)]: false, [Symbol(asyncId)]: 4, [Symbol(triggerId)]: 1 }, [Symbol(kBuffer)]: null, [Symbol(kBufferCb)]: null, [Symbol(kBufferGen)]: null, [Symbol(kCapture)]: false, [Symbol(kSetNoDelay)]: false, [Symbol(kSetKeepAlive)]: false, [Symbol(kSetKeepAliveInitialDelay)]: 0, [Symbol(kBytesRead)]: 0, [Symbol(kBytesWritten)]: 0 }, timeOut: 5000, retryTimes: 3, rawData: false, disableMidParsing: {} } OPEN-PROTOCOL 10352: new OpenProtocolParser OPEN-PROTOCOL 10352: new openProtocolSerializer OPEN-PROTOCOL 10352: new MIDParser OPEN-PROTOCOL 10352: new MIDSerializer OPEN-PROTOCOL 10352: SessionControlClient connect OPEN-PROTOCOL 10352: SessionControlClient sendMidOne OPEN-PROTOCOL 10352: LinkLayer _write { mid: 1, revision: 6 } OPEN-PROTOCOL 10352: MIDSerializer _transform { mid: 1, revision: 6 } OPEN-PROTOCOL 10352: LinkLayer _onDataMidSerializer { mid: 1, revision: 6, payload: } OPEN-PROTOCOL 10352: openProtocolSerializer _transform { mid: 1, revision: 6, payload: } OPEN-PROTOCOL 10352: openProtocolSerializer _transform publish OPEN-PROTOCOL 10352: LinkLayer _onDataOpSerializer OPEN-PROTOCOL 10352: LinkLayer _read 16 OPEN-PROTOCOL 10352: LinkLayer _onDataStream OPEN-PROTOCOL 10352: OpenProtocolParser _transform OPEN-PROTOCOL 10352: LinkLayer _onDataOpParser { mid: 2, revision: 6, noAck: false, stationID: 1, spindleID: 1, sequenceNumber: 0, messageParts: 0, messageNumber: 0, payload: } OPEN-PROTOCOL 10352: new MIDParser _transform { mid: 2, revision: 6, noAck: false, stationID: 1, spindleID: 1, sequenceNumber: 0, messageParts: 0, messageNumber: 0, payload: } OPEN-PROTOCOL 10352: LinkLayer _onDataMidParser { mid: 2, revision: 6, noAck: false, stationID: 1, spindleID: 1, sequenceNumber: 0, messageParts: 0, messageNumber: 0, payload: { cellID: 0, channelID: 0, controllerName: '', supplierCode: 'ACT', openProtocolVersion: 'v2.0', controllerSoftwareVersion: 'IXB_R_3.6.13.10880_', toolSoftwareVersion: '3.6.13', rbuType: 'None', controllerSerialNumber: 'A3500191', systemType: 3, systemSubtype: 1, sequenceNumberSupport: 0, linkingHandlingSupport: 0 } } OPEN-PROTOCOL 10352: SessionControlClient receivedReply { mid: 2, revision: 6, noAck: false, stationID: 1, spindleID: 1, sequenceNumber: 0, messageParts: 0, messageNumber: 0, payload: { cellID: 0, channelID: 0, controllerName: '', supplierCode: 'ACT', openProtocolVersion: 'v2.0', controllerSoftwareVersion: 'IXB_R_3.6.13.10880_', toolSoftwareVersion: '3.6.13', rbuType: 'None', controllerSerialNumber: 'A3500191', systemType: 3, systemSubtype: 1, sequenceNumberSupport: 0, linkingHandlingSupport: 0 } } OPEN-PROTOCOL 10352: LinkLayer finishCycle undefined OPEN-PROTOCOL 10352: LinkLayer deactivateLinkLayer OPEN-PROTOCOL 10352: SessionControlClient _sendingProcess Connected! OPEN-PROTOCOL 10352: SessionControlClient _sendMid 8 { mid: 8, revision: 1, payload: '09000013500000000000000000000000000000001001' } OPEN-PROTOCOL 10352: SessionControlClient new Message OPEN-PROTOCOL 10352: SessionControlClient _sendingProcess OPEN-PROTOCOL 10352: SessionControlClient _transmitMid Message { _mid: { mid: 8, revision: 1, payload: '09000013500000000000000000000000000000001001' }, _callback: [Function (anonymous)], _type: 'manual', _group: undefined, _baseMid: { mid: 8, revision: 1, payload: '09000013500000000000000000000000000000001001' } } OPEN-PROTOCOL 10352: SessionControlClient _calcRevision undefined undefined undefined undefined OPEN-PROTOCOL 10352: LinkLayer _write { mid: 8, revision: 1, payload: '09000013500000000000000000000000000000001001' } OPEN-PROTOCOL 10352: MIDSerializer _transform { mid: 8, revision: 1, payload: '09000013500000000000000000000000000000001001' } OPEN-PROTOCOL 10352: LinkLayer _onDataMidSerializer { mid: 8, revision: 1, payload: } OPEN-PROTOCOL 10352: openProtocolSerializer _transform { mid: 8, revision: 1, payload: } OPEN-PROTOCOL 10352: openProtocolSerializer _transform publish OPEN-PROTOCOL 10352: LinkLayer _onDataOpSerializer OPEN-PROTOCOL 10352: LinkLayer _read 16 OPEN-PROTOCOL 10352: LinkLayer _onDataStream OPEN-PROTOCOL 10352: OpenProtocolParser _transform OPEN-PROTOCOL 10352: LinkLayer _onDataOpParser { mid: 5, revision: 1, noAck: false, stationID: 1, spindleID: 1, sequenceNumber: 0, messageParts: 0, messageNumber: 0, payload: } OPEN-PROTOCOL 10352: new MIDParser _transform { mid: 5, revision: 1, noAck: false, stationID: 1, spindleID: 1, sequenceNumber: 0, messageParts: 0, messageNumber: 0, payload: } OPEN-PROTOCOL 10352: LinkLayer _onDataMidParser { mid: 5, revision: 1, noAck: false, stationID: 1, spindleID: 1, sequenceNumber: 0, messageParts: 0, messageNumber: 0, payload: { midNumber: 8 } } OPEN-PROTOCOL 10352: SessionControlClient _onDataLinkLayer OPEN-PROTOCOL 10352: LinkLayer finishCycle undefined OPEN-PROTOCOL 10352: SessionControlClient _receiverData { mid: 5, revision: 1, noAck: false, stationID: 1, spindleID: 1, sequenceNumber: 0, messageParts: 0, messageNumber: 0, payload: { midNumber: 8 } } Data received { mid: 5, revision: 1, noAck: false, stationID: 1, spindleID: 1, sequenceNumber: 0, messageParts: 0, messageNumber: 0, payload: { midNumber: 8 } } OPEN-PROTOCOL 10352: SessionControlClient _sendingProcess OPEN-PROTOCOL 10352: LinkLayer _read 16 OPEN-PROTOCOL 10352: SessionControlClient _sendKeepAlive OPEN-PROTOCOL 10352: SessionControlClient _request keepAlive {} OPEN-PROTOCOL 10352: SessionControlClient new Message OPEN-PROTOCOL 10352: SessionControlClient _sendingProcess OPEN-PROTOCOL 10352: SessionControlClient _transmitMid Message { _mid: { payload: '', mid: 9999 }, _callback: [Function (anonymous)], _type: 'request', _group: 'keepAlive', _baseMid: { payload: '', mid: 9999 } } OPEN-PROTOCOL 10352: SessionControlClient _calcRevision undefined undefined undefined undefined OPEN-PROTOCOL 10352: LinkLayer _write { payload: '', mid: 9999, revision: 1 } OPEN-PROTOCOL 10352: MIDSerializer _transform { payload: '', mid: 9999, revision: 1 } OPEN-PROTOCOL 10352: LinkLayer _onDataMidSerializer { payload: , mid: 9999, revision: 1 } OPEN-PROTOCOL 10352: openProtocolSerializer _transform { payload: , mid: 9999, revision: 1 } OPEN-PROTOCOL 10352: openProtocolSerializer _transform publish OPEN-PROTOCOL 10352: LinkLayer _onDataOpSerializer OPEN-PROTOCOL 10352: LinkLayer _onDataStream OPEN-PROTOCOL 10352: OpenProtocolParser _transform OPEN-PROTOCOL 10352: LinkLayer _onDataOpParser { mid: 9999, revision: 1, noAck: false, stationID: 1, spindleID: 1, sequenceNumber: 0, messageParts: 0, messageNumber: 0, payload: } OPEN-PROTOCOL 10352: new MIDParser _transform { mid: 9999, revision: 1, noAck: false, stationID: 1, spindleID: 1, sequenceNumber: 0, messageParts: 0, messageNumber: 0, payload: } OPEN-PROTOCOL 10352: LinkLayer _onDataMidParser { mid: 9999, revision: 1, noAck: false, stationID: 1, spindleID: 1, sequenceNumber: 0, messageParts: 0, messageNumber: 0, payload: '' } OPEN-PROTOCOL 10352: SessionControlClient _onDataLinkLayer OPEN-PROTOCOL 10352: LinkLayer finishCycle undefined OPEN-PROTOCOL 10352: SessionControlClient _receiverData { mid: 9999, revision: 1, noAck: false, stationID: 1, spindleID: 1, sequenceNumber: 0, messageParts: 0, messageNumber: 0, payload: '' } Data received { mid: 9999, revision: 1, noAck: false, stationID: 1, spindleID: 1, sequenceNumber: 0, messageParts: 0, messageNumber: 0, payload: '' } OPEN-PROTOCOL 10352: SessionControlClient _sendingProcess OPEN-PROTOCOL 10352: LinkLayer _read 16 OPEN-PROTOCOL 10352: SessionControlClient _sendKeepAlive OPEN-PROTOCOL 10352: SessionControlClient _request keepAlive {} OPEN-PROTOCOL 10352: SessionControlClient new Message OPEN-PROTOCOL 10352: SessionControlClient _sendingProcess OPEN-PROTOCOL 10352: SessionControlClient _transmitMid Message { _mid: { payload: '', mid: 9999 }, _callback: [Function (anonymous)], _type: 'request', _group: 'keepAlive', _baseMid: { payload: '', mid: 9999 } } OPEN-PROTOCOL 10352: SessionControlClient _calcRevision undefined undefined undefined undefined OPEN-PROTOCOL 10352: LinkLayer _write { payload: '', mid: 9999, revision: 1 } OPEN-PROTOCOL 10352: MIDSerializer _transform { payload: '', mid: 9999, revision: 1 } OPEN-PROTOCOL 10352: LinkLayer _onDataMidSerializer { payload: , mid: 9999, revision: 1 } OPEN-PROTOCOL 10352: openProtocolSerializer _transform { payload: , mid: 9999, revision: 1 } OPEN-PROTOCOL 10352: openProtocolSerializer _transform publish OPEN-PROTOCOL 10352: LinkLayer _onDataOpSerializer OPEN-PROTOCOL 10352: LinkLayer _onDataStream OPEN-PROTOCOL 10352: OpenProtocolParser _transform OPEN-PROTOCOL 10352: LinkLayer _onDataOpParser { mid: 9999, revision: 1, noAck: false, stationID: 1, spindleID: 1, sequenceNumber: 0, messageParts: 0, messageNumber: 0, payload: } OPEN-PROTOCOL 10352: new MIDParser _transform { mid: 9999, revision: 1, noAck: false, stationID: 1, spindleID: 1, sequenceNumber: 0, messageParts: 0, messageNumber: 0, payload: } OPEN-PROTOCOL 10352: LinkLayer _onDataMidParser { mid: 9999, revision: 1, noAck: false, stationID: 1, spindleID: 1, sequenceNumber: 0, messageParts: 0, messageNumber: 0, payload: '' } OPEN-PROTOCOL 10352: SessionControlClient _onDataLinkLayer OPEN-PROTOCOL 10352: LinkLayer finishCycle undefined OPEN-PROTOCOL 10352: SessionControlClient _receiverData { mid: 9999, revision: 1, noAck: false, stationID: 1, spindleID: 1, sequenceNumber: 0, messageParts: 0, messageNumber: 0, payload: '' } Data received { mid: 9999, revision: 1, noAck: false, stationID: 1, spindleID: 1, sequenceNumber: 0, messageParts: 0, messageNumber: 0, payload: '' } OPEN-PROTOCOL 10352: SessionControlClient _sendingProcess OPEN-PROTOCOL 10352: LinkLayer _read 16 OPEN-PROTOCOL 10352: SessionControlClient _sendKeepAlive OPEN-PROTOCOL 10352: SessionControlClient _request keepAlive {} OPEN-PROTOCOL 10352: SessionControlClient new Message OPEN-PROTOCOL 10352: SessionControlClient _sendingProcess OPEN-PROTOCOL 10352: SessionControlClient _transmitMid Message { _mid: { payload: '', mid: 9999 }, _callback: [Function (anonymous)], _type: 'request', _group: 'keepAlive', _baseMid: { payload: '', mid: 9999 } } OPEN-PROTOCOL 10352: SessionControlClient _calcRevision undefined undefined undefined undefined OPEN-PROTOCOL 10352: LinkLayer _write { payload: '', mid: 9999, revision: 1 } OPEN-PROTOCOL 10352: MIDSerializer _transform { payload: '', mid: 9999, revision: 1 } OPEN-PROTOCOL 10352: LinkLayer _onDataMidSerializer { payload: , mid: 9999, revision: 1 } OPEN-PROTOCOL 10352: openProtocolSerializer _transform { payload: , mid: 9999, revision: 1 } OPEN-PROTOCOL 10352: openProtocolSerializer _transform publish OPEN-PROTOCOL 10352: LinkLayer _onDataOpSerializer OPEN-PROTOCOL 10352: LinkLayer _onDataStream OPEN-PROTOCOL 10352: OpenProtocolParser _transform OPEN-PROTOCOL 10352: LinkLayer _onDataOpParser { mid: 9999, revision: 1, noAck: false, stationID: 1, spindleID: 1, sequenceNumber: 0, messageParts: 0, messageNumber: 0, payload: } OPEN-PROTOCOL 10352: new MIDParser _transform { mid: 9999, revision: 1, noAck: false, stationID: 1, spindleID: 1, sequenceNumber: 0, messageParts: 0, messageNumber: 0, payload: } OPEN-PROTOCOL 10352: LinkLayer _onDataMidParser { mid: 9999, revision: 1, noAck: false, stationID: 1, spindleID: 1, sequenceNumber: 0, messageParts: 0, messageNumber: 0, payload: '' } OPEN-PROTOCOL 10352: SessionControlClient _onDataLinkLayer OPEN-PROTOCOL 10352: LinkLayer finishCycle undefined OPEN-PROTOCOL 10352: SessionControlClient _receiverData { mid: 9999, revision: 1, noAck: false, stationID: 1, spindleID: 1, sequenceNumber: 0, messageParts: 0, messageNumber: 0, payload: '' } Data received { mid: 9999, revision: 1, noAck: false, stationID: 1, spindleID: 1, sequenceNumber: 0, messageParts: 0, messageNumber: 0, payload: '' } OPEN-PROTOCOL 10352: SessionControlClient _sendingProcess OPEN-PROTOCOL 10352: LinkLayer _read 16 OPEN-PROTOCOL 10352: SessionControlClient _sendKeepAlive OPEN-PROTOCOL 10352: SessionControlClient _request keepAlive {} OPEN-PROTOCOL 10352: SessionControlClient new Message OPEN-PROTOCOL 10352: SessionControlClient _sendingProcess OPEN-PROTOCOL 10352: SessionControlClient _transmitMid Message { _mid: { payload: '', mid: 9999 }, _callback: [Function (anonymous)], _type: 'request', _group: 'keepAlive', _baseMid: { payload: '', mid: 9999 } } OPEN-PROTOCOL 10352: SessionControlClient _calcRevision undefined undefined undefined undefined OPEN-PROTOCOL 10352: LinkLayer _write { payload: '', mid: 9999, revision: 1 } OPEN-PROTOCOL 10352: MIDSerializer _transform { payload: '', mid: 9999, revision: 1 } OPEN-PROTOCOL 10352: LinkLayer _onDataMidSerializer { payload: , mid: 9999, revision: 1 } OPEN-PROTOCOL 10352: openProtocolSerializer _transform { payload: , mid: 9999, revision: 1 } OPEN-PROTOCOL 10352: openProtocolSerializer _transform publish OPEN-PROTOCOL 10352: LinkLayer _onDataOpSerializer OPEN-PROTOCOL 10352: LinkLayer _onDataStream OPEN-PROTOCOL 10352: OpenProtocolParser _transform OPEN-PROTOCOL 10352: LinkLayer _onDataOpParser { mid: 9999, revision: 1, noAck: false, stationID: 1, spindleID: 1, sequenceNumber: 0, messageParts: 0, messageNumber: 0, payload: } OPEN-PROTOCOL 10352: new MIDParser _transform { mid: 9999, revision: 1, noAck: false, stationID: 1, spindleID: 1, sequenceNumber: 0, messageParts: 0, messageNumber: 0, payload: } OPEN-PROTOCOL 10352: LinkLayer _onDataMidParser { mid: 9999, revision: 1, noAck: false, stationID: 1, spindleID: 1, sequenceNumber: 0, messageParts: 0, messageNumber: 0, payload: '' } OPEN-PROTOCOL 10352: SessionControlClient _onDataLinkLayer OPEN-PROTOCOL 10352: LinkLayer finishCycle undefined OPEN-PROTOCOL 10352: SessionControlClient _receiverData { mid: 9999, revision: 1, noAck: false, stationID: 1, spindleID: 1, sequenceNumber: 0, messageParts: 0, messageNumber: 0, payload: '' } Data received { mid: 9999, revision: 1, noAck: false, stationID: 1, spindleID: 1, sequenceNumber: 0, messageParts: 0, messageNumber: 0, payload: '' } OPEN-PROTOCOL 10352: SessionControlClient _sendingProcess OPEN-PROTOCOL 10352: LinkLayer _read 16 OPEN-PROTOCOL 10352: LinkLayer _onDataStream OPEN-PROTOCOL 10352: OpenProtocolParser _transform OPEN-PROTOCOL 10352: SessionControlClient _sendKeepAlive OPEN-PROTOCOL 10352: SessionControlClient _request keepAlive {} OPEN-PROTOCOL 10352: SessionControlClient new Message OPEN-PROTOCOL 10352: SessionControlClient _sendingProcess OPEN-PROTOCOL 10352: SessionControlClient _transmitMid Message { _mid: { payload: '', mid: 9999 }, _callback: [Function (anonymous)], _type: 'request', _group: 'keepAlive', _baseMid: { payload: '', mid: 9999 } } OPEN-PROTOCOL 10352: SessionControlClient _calcRevision undefined undefined undefined undefined OPEN-PROTOCOL 10352: LinkLayer _write { payload: '', mid: 9999, revision: 1 } OPEN-PROTOCOL 10352: MIDSerializer _transform { payload: '', mid: 9999, revision: 1 } OPEN-PROTOCOL 10352: LinkLayer _onDataMidSerializer { payload: , mid: 9999, revision: 1 } OPEN-PROTOCOL 10352: openProtocolSerializer _transform { payload: , mid: 9999, revision: 1 } OPEN-PROTOCOL 10352: openProtocolSerializer _transform publish OPEN-PROTOCOL 10352: LinkLayer _onDataOpSerializer OPEN-PROTOCOL 10352: LinkLayer _onDataStream OPEN-PROTOCOL 10352: OpenProtocolParser _transform OPEN-PROTOCOL 10352: OpenProtocolParser _transform err-message: 0 OPEN-PROTOCOL 10352: LinkLayer _onDataStream OPEN-PROTOCOL 10352: LinkLayer _onDataStream OPEN-PROTOCOL 10352: LinkLayer _resendMid OPEN-PROTOCOL 10352: openProtocolSerializer _transform { payload: , mid: 9999, revision: 1, stationID: 1, spindleID: 1, sequenceNumber: 0, messageParts: 0, messageNumber: 0 } OPEN-PROTOCOL 10352: openProtocolSerializer _transform publish OPEN-PROTOCOL 10352: LinkLayer _onDataOpSerializer OPEN-PROTOCOL 10352: LinkLayer _onDataStream OPEN-PROTOCOL 10352: LinkLayer _onDataStream OPEN-PROTOCOL 10352: LinkLayer _onDataStream OPEN-PROTOCOL 10352: SessionControlClient stream_close OPEN-PROTOCOL 10352: SessionControlClient close Error: Stream Close at Socket. (C:\Users\C41581\node_modules\node-open-protocol\src\sessionControlClient.js:218:24) at Socket.emit (node:events:513:28) at TCP. (node:net:322:12) OPEN-PROTOCOL 10352: LinkLayer _destroy ```
ferm10n commented 1 year ago

quick tip, you can fold the log messages like this on github comments (or anywhere that supports markdown).

some text

<details>
  <summary>logs</summary>

log content here

</details>

which gives the following:

some text

logs ``` log content here ```

anyway, yeah I feel like some kind of coop debugging session is needed here. What is your timezone? Ideally we could connect on Discord, but I don't feel comfortable putting my info out here publicly. My email should be on my github profile.


I haven't used the sendMid directly before, but I did a bit of poking around in sessionControlClient, and noticed something interesting in the _subscribe call. It looks like it's building a mid 8: https://github.com/st-one-io/node-open-protocol/blob/master/src/sessionControlClient.js#L695-L712

which makes me think your opts should look like this:

//To MIDs not implemented
let opts = {
    payload: {
        midNumber: 900,
        revision: 1,
        dataLength: 35,
        extraData: "00000000000000000000000000000001001"
    }
}
alexmc1510 commented 1 year ago

Hello,

I have tested the code you suggested in the following way. Marking genericMode as true and calling "suscribing" function instead of "sendmid".

With doing that, I manage to send the message as before, nevertheless, I receive the same error after the first trace reception. It seems that I am not answering the machine with the ack after reception that should be the following according Open Protocol Interface Tester: image

Wireshark: image But empty ack: image

And log:

logs ``` node C:\Users\C41581\node_modules\node-open-protocol\test\alex.js OPEN-PROTOCOL 4220: new SessionControlClient OPEN-PROTOCOL 4220: new LinkLayer { stream: Socket { connecting: true, _hadError: false, _parent: null, _host: null, _closeAfterHandlingError: false, _readableState: ReadableState { objectMode: false, highWaterMark: 16384, buffer: BufferList { head: null, tail: null, length: 0 }, length: 0, pipes: [], flowing: null, ended: false, endEmitted: false, reading: false, constructed: true, sync: true, needReadable: false, emittedReadable: false, readableListening: false, resumeScheduled: false, errorEmitted: false, emitClose: false, autoDestroy: true, destroyed: false, errored: null, closed: false, closeEmitted: false, defaultEncoding: 'utf8', awaitDrainWriters: null, multiAwaitDrain: false, readingMore: false, dataEmitted: false, decoder: null, encoding: null, [Symbol(kPaused)]: null }, _events: [Object: null prototype] { end: [Function: onReadableStreamEnd], connect: [Function], timeout: [Function] }, _eventsCount: 3, _maxListeners: undefined, _writableState: WritableState { objectMode: false, highWaterMark: 16384, finalCalled: false, needDrain: false, ending: false, ended: false, finished: false, destroyed: false, decodeStrings: false, defaultEncoding: 'utf8', length: 0, writing: false, corked: 0, sync: true, bufferProcessing: false, onwrite: [Function: bound onwrite], writecb: null, writelen: 0, afterWriteTickInfo: null, buffered: [], bufferedIndex: 0, allBuffers: true, allNoop: true, pendingcb: 0, constructed: true, prefinished: false, errorEmitted: false, emitClose: false, autoDestroy: true, errored: null, closed: false, closeEmitted: false, [Symbol(kOnFinished)]: [] }, allowHalfOpen: false, _sockname: null, _pendingData: null, _pendingEncoding: '', server: null, _server: null, timeout: 20000, [Symbol(async_id_symbol)]: 2, [Symbol(kHandle)]: TCP { reading: false, onconnection: null, [Symbol(owner_symbol)]: [Circular *1] }, [Symbol(lastWriteQueueSize)]: 0, [Symbol(timeout)]: Timeout { _idleTimeout: 20000, _idlePrev: [TimersList], _idleNext: [TimersList], _idleStart: 136, _onTimeout: [Function: bound ], _timerArgs: undefined, _repeat: null, _destroyed: false, [Symbol(refed)]: false, [Symbol(kHasPrimitive)]: false, [Symbol(asyncId)]: 4, [Symbol(triggerId)]: 1 }, [Symbol(kBuffer)]: null, [Symbol(kBufferCb)]: null, [Symbol(kBufferGen)]: null, [Symbol(kCapture)]: false, [Symbol(kSetNoDelay)]: false, [Symbol(kSetKeepAlive)]: false, [Symbol(kSetKeepAliveInitialDelay)]: 0, [Symbol(kBytesRead)]: 0, [Symbol(kBytesWritten)]: 0 }, timeOut: 3000, retryTimes: 3, rawData: false, disableMidParsing: {} } OPEN-PROTOCOL 4220: new OpenProtocolParser OPEN-PROTOCOL 4220: new openProtocolSerializer OPEN-PROTOCOL 4220: new MIDParser OPEN-PROTOCOL 4220: new MIDSerializer node:events:491 ^ Error: Socket Timeout at onTimeout (C:\Users\C41581\node_modules\node-open-protocol\index.js:44:17) at Socket. (C:\Users\C41581\node_modules\node-open-protocol\index.js:41:34) at Object.onceWrapper (node:events:627:28) at Socket.emit (node:events:513:28) at Socket._onTimeout (node:net:570:8) at listOnTimeout (node:internal/timers:569:17) at process.processTimers (node:internal/timers:512:7) Emitted 'error' event on SessionControlClient instance at: at onTimeout (C:\Users\C41581\node_modules\node-open-protocol\index.js:48:16) at Socket. (C:\Users\C41581\node_modules\node-open-protocol\index.js:41:34) [... lines matching original stack trace ...] at process.processTimers (node:internal/timers:512:7) { code: 'SOCKET_TIMEOUT', address: '192.168.0.199', port: 4545 } Node.js v18.16.0 PS C:\Users\C41581\node_modules\node-open-protocol> node C:\Users\C41581\node_modules\node-open-protocol\test\alex.js OPEN-PROTOCOL 18032: new SessionControlClient OPEN-PROTOCOL 18032: new LinkLayer { stream: Socket { connecting: true, _hadError: false, _parent: null, _host: null, _closeAfterHandlingError: false, _readableState: ReadableState { objectMode: false, highWaterMark: 16384, buffer: BufferList { head: null, tail: null, length: 0 }, length: 0, pipes: [], flowing: null, ended: false, endEmitted: false, reading: false, constructed: true, sync: true, needReadable: false, emittedReadable: false, readableListening: false, resumeScheduled: false, errorEmitted: false, emitClose: false, autoDestroy: true, destroyed: false, errored: null, closed: false, closeEmitted: false, defaultEncoding: 'utf8', awaitDrainWriters: null, multiAwaitDrain: false, readingMore: false, dataEmitted: false, decoder: null, encoding: null, [Symbol(kPaused)]: null }, _events: [Object: null prototype] { end: [Function: onReadableStreamEnd], connect: [Function], timeout: [Function] }, _eventsCount: 3, _maxListeners: undefined, _writableState: WritableState { objectMode: false, highWaterMark: 16384, finalCalled: false, needDrain: false, ending: false, ended: false, finished: false, destroyed: false, decodeStrings: false, defaultEncoding: 'utf8', length: 0, writing: false, corked: 0, sync: true, bufferProcessing: false, onwrite: [Function: bound onwrite], writecb: null, writelen: 0, afterWriteTickInfo: null, buffered: [], bufferedIndex: 0, allBuffers: true, allNoop: true, pendingcb: 0, constructed: true, prefinished: false, errorEmitted: false, emitClose: false, autoDestroy: true, errored: null, closed: false, closeEmitted: false, [Symbol(kOnFinished)]: [] }, allowHalfOpen: false, _sockname: null, _pendingData: null, _pendingEncoding: '', server: null, _server: null, timeout: 20000, [Symbol(async_id_symbol)]: 2, [Symbol(kHandle)]: TCP { reading: false, onconnection: null, [Symbol(owner_symbol)]: [Circular *1] }, [Symbol(lastWriteQueueSize)]: 0, [Symbol(timeout)]: Timeout { _idleTimeout: 20000, _idlePrev: [TimersList], _idleNext: [TimersList], _idleStart: 114, _onTimeout: [Function: bound ], _timerArgs: undefined, _repeat: null, _destroyed: false, [Symbol(refed)]: false, [Symbol(kHasPrimitive)]: false, [Symbol(asyncId)]: 4, [Symbol(triggerId)]: 1 }, [Symbol(kBuffer)]: null, [Symbol(kBufferCb)]: null, [Symbol(kBufferGen)]: null, [Symbol(kCapture)]: false, [Symbol(kSetNoDelay)]: false, [Symbol(kSetKeepAlive)]: false, [Symbol(kSetKeepAliveInitialDelay)]: 0, [Symbol(kBytesRead)]: 0, [Symbol(kBytesWritten)]: 0 }, timeOut: 3000, retryTimes: 3, rawData: false, disableMidParsing: {} } OPEN-PROTOCOL 18032: new OpenProtocolParser OPEN-PROTOCOL 18032: new openProtocolSerializer OPEN-PROTOCOL 18032: new MIDParser OPEN-PROTOCOL 18032: new MIDSerializer OPEN-PROTOCOL 18032: SessionControlClient connect OPEN-PROTOCOL 18032: SessionControlClient sendMidOne OPEN-PROTOCOL 18032: LinkLayer _write { mid: 1, revision: 6 } OPEN-PROTOCOL 18032: MIDSerializer _transform { mid: 1, revision: 6 } OPEN-PROTOCOL 18032: LinkLayer _onDataMidSerializer { mid: 1, revision: 6, payload: } OPEN-PROTOCOL 18032: openProtocolSerializer _transform { mid: 1, revision: 6, payload: } OPEN-PROTOCOL 18032: openProtocolSerializer _transform publish OPEN-PROTOCOL 18032: LinkLayer _onDataOpSerializer OPEN-PROTOCOL 18032: LinkLayer _read 16 OPEN-PROTOCOL 18032: LinkLayer _onDataStream OPEN-PROTOCOL 18032: OpenProtocolParser _transform OPEN-PROTOCOL 18032: LinkLayer _onDataOpParser { mid: 2, revision: 6, noAck: false, stationID: 1, spindleID: 1, sequenceNumber: 0, messageParts: 0, messageNumber: 0, payload: } OPEN-PROTOCOL 18032: new MIDParser _transform { mid: 2, revision: 6, noAck: false, stationID: 1, spindleID: 1, sequenceNumber: 0, messageParts: 0, messageNumber: 0, payload: } OPEN-PROTOCOL 18032: LinkLayer _onDataMidParser { mid: 2, revision: 6, noAck: false, stationID: 1, spindleID: 1, sequenceNumber: 0, messageParts: 0, messageNumber: 0, payload: { cellID: 0, channelID: 0, controllerName: '', supplierCode: 'ACT', openProtocolVersion: 'v2.0', controllerSoftwareVersion: 'IXB_R_3.6.13.10880_', toolSoftwareVersion: '3.6.13', rbuType: 'None', controllerSerialNumber: 'A3500191', systemType: 3, systemSubtype: 1, sequenceNumberSupport: 0, linkingHandlingSupport: 0 } } OPEN-PROTOCOL 18032: SessionControlClient receivedReply { mid: 2, revision: 6, noAck: false, stationID: 1, spindleID: 1, sequenceNumber: 0, messageParts: 0, messageNumber: 0, payload: { cellID: 0, channelID: 0, controllerName: '', supplierCode: 'ACT', openProtocolVersion: 'v2.0', controllerSoftwareVersion: 'IXB_R_3.6.13.10880_', toolSoftwareVersion: '3.6.13', rbuType: 'None', controllerSerialNumber: 'A3500191', systemType: 3, systemSubtype: 1, sequenceNumberSupport: 0, linkingHandlingSupport: 0 } } OPEN-PROTOCOL 18032: LinkLayer finishCycle undefined OPEN-PROTOCOL 18032: LinkLayer deactivateLinkLayer OPEN-PROTOCOL 18032: SessionControlClient _sendingProcess Connected! OPEN-PROTOCOL 18032: SessionControlClient _subscribe psetSelected { midNumber: 900, revision: 1, dataLength: 35, extraData: '00000000000000000000000000000001001' } OPEN-PROTOCOL 18032: SessionControlClient new Message OPEN-PROTOCOL 18032: SessionControlClient _sendingProcess OPEN-PROTOCOL 18032: SessionControlClient _transmitMid Message { _mid: { midNumber: 900, revision: 1, dataLength: 35, extraData: '00000000000000000000000000000001001', mid: 8, payload: { midNumber: 900, revision: 1, dataLength: 35, extraData: '00000000000000000000000000000001001' } }, _callback: [Function (anonymous)], _type: 'generic', _group: 'psetSelected', _baseMid: { midNumber: 900, revision: 1, dataLength: 35, extraData: '00000000000000000000000000000001001', mid: 8, payload: { midNumber: 900, revision: 1, dataLength: 35, extraData: '00000000000000000000000000000001001' } } } OPEN-PROTOCOL 18032: SessionControlClient _calcRevision undefined undefined undefined undefined OPEN-PROTOCOL 18032: LinkLayer _write { midNumber: 900, revision: 1, dataLength: 35, extraData: '00000000000000000000000000000001001', mid: 8, payload: { midNumber: 900, revision: 1, dataLength: 35, extraData: '00000000000000000000000000000001001' } } OPEN-PROTOCOL 18032: MIDSerializer _transform { midNumber: 900, revision: 1, dataLength: 35, extraData: '00000000000000000000000000000001001', mid: 8, payload: { midNumber: 900, revision: 1, dataLength: 35, extraData: '00000000000000000000000000000001001' } } OPEN-PROTOCOL 18032: LinkLayer _onDataMidSerializer { midNumber: 900, revision: 1, dataLength: 35, extraData: '00000000000000000000000000000001001', mid: 8, payload: } OPEN-PROTOCOL 18032: openProtocolSerializer _transform { midNumber: 900, revision: 1, dataLength: 35, extraData: '00000000000000000000000000000001001', mid: 8, payload: } OPEN-PROTOCOL 18032: openProtocolSerializer _transform publish OPEN-PROTOCOL 18032: LinkLayer _onDataOpSerializer OPEN-PROTOCOL 18032: LinkLayer _read 16 OPEN-PROTOCOL 18032: LinkLayer _onDataStream OPEN-PROTOCOL 18032: OpenProtocolParser _transform OPEN-PROTOCOL 18032: LinkLayer _onDataOpParser { mid: 5, revision: 1, noAck: false, stationID: 1, spindleID: 1, sequenceNumber: 0, messageParts: 0, messageNumber: 0, payload: } OPEN-PROTOCOL 18032: new MIDParser _transform { mid: 5, revision: 1, noAck: false, stationID: 1, spindleID: 1, sequenceNumber: 0, messageParts: 0, messageNumber: 0, payload: } OPEN-PROTOCOL 18032: LinkLayer _onDataMidParser { mid: 5, revision: 1, noAck: false, stationID: 1, spindleID: 1, sequenceNumber: 0, messageParts: 0, messageNumber: 0, payload: { midNumber: 8 } } OPEN-PROTOCOL 18032: SessionControlClient _onDataLinkLayer OPEN-PROTOCOL 18032: LinkLayer finishCycle undefined OPEN-PROTOCOL 18032: SessionControlClient _receiverData { mid: 5, revision: 1, noAck: false, stationID: 1, spindleID: 1, sequenceNumber: 0, messageParts: 0, messageNumber: 0, payload: { midNumber: 8 } } Data received { mid: 5, revision: 1, noAck: false, stationID: 1, spindleID: 1, sequenceNumber: 0, messageParts: 0, messageNumber: 0, payload: { midNumber: 8 } } OPEN-PROTOCOL 18032: SessionControlClient _sendingProcess OPEN-PROTOCOL 18032: LinkLayer _read 16 OPEN-PROTOCOL 18032: LinkLayer _onDataStream OPEN-PROTOCOL 18032: OpenProtocolParser _transform OPEN-PROTOCOL 18032: LinkLayer _onDataStream OPEN-PROTOCOL 18032: OpenProtocolParser _transform OPEN-PROTOCOL 18032: OpenProtocolParser _transform err-message: 0 OPEN-PROTOCOL 18032: SessionControlClient _sendKeepAlive OPEN-PROTOCOL 18032: SessionControlClient _request keepAlive {} OPEN-PROTOCOL 18032: SessionControlClient new Message OPEN-PROTOCOL 18032: SessionControlClient _sendingProcess OPEN-PROTOCOL 18032: SessionControlClient _transmitMid Message { _mid: { payload: '', mid: 9999 }, _callback: [Function (anonymous)], _type: 'request', _group: 'keepAlive', _baseMid: { payload: '', mid: 9999 } } OPEN-PROTOCOL 18032: SessionControlClient _calcRevision undefined undefined undefined undefined OPEN-PROTOCOL 18032: LinkLayer _write { payload: '', mid: 9999, revision: 1 } OPEN-PROTOCOL 18032: MIDSerializer _transform { payload: '', mid: 9999, revision: 1 } OPEN-PROTOCOL 18032: LinkLayer _onDataMidSerializer { payload: , mid: 9999, revision: 1 } OPEN-PROTOCOL 18032: openProtocolSerializer _transform { payload: , mid: 9999, revision: 1 } OPEN-PROTOCOL 18032: openProtocolSerializer _transform publish OPEN-PROTOCOL 18032: LinkLayer _onDataOpSerializer OPEN-PROTOCOL 18032: LinkLayer _onDataStream OPEN-PROTOCOL 18032: LinkLayer _onDataStream OPEN-PROTOCOL 18032: LinkLayer _resendMid OPEN-PROTOCOL 18032: openProtocolSerializer _transform { payload: , mid: 9999, revision: 1, stationID: 1, spindleID: 1, sequenceNumber: 0, messageParts: 0, messageNumber: 0 } OPEN-PROTOCOL 18032: openProtocolSerializer _transform publish OPEN-PROTOCOL 18032: LinkLayer _onDataOpSerializer OPEN-PROTOCOL 18032: LinkLayer _onDataStream OPEN-PROTOCOL 18032: LinkLayer _onDataStream OPEN-PROTOCOL 18032: LinkLayer _onDataStream OPEN-PROTOCOL 18032: LinkLayer _resendMid OPEN-PROTOCOL 18032: openProtocolSerializer _transform { payload: , mid: 9999, revision: 1, stationID: 1, spindleID: 1, sequenceNumber: 0, messageParts: 0, messageNumber: 0 } OPEN-PROTOCOL 18032: openProtocolSerializer _transform publish OPEN-PROTOCOL 18032: LinkLayer _onDataOpSerializer OPEN-PROTOCOL 18032: LinkLayer _onDataStream OPEN-PROTOCOL 18032: SessionControlClient stream_close OPEN-PROTOCOL 18032: SessionControlClient close Error: Stream Close at Socket. (C:\Users\C41581\node_modules\node-open-protocol\src\sessionControlClient.js:218:24) at Socket.emit (node:events:513:28) at TCP. (node:net:322:12) OPEN-PROTOCOL 18032: LinkLayer _destroy ```