diff --git a/README.md b/README.md index ebd94a04..d7321cc2 100755 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -## Yamaha Remote Control Protocol v3.0.3 - for Companion v3 +## Yamaha Remote Control Protocol v3.0.4 - for Companion v3 **Available for the following Yamaha Pro Audio Devices** @@ -21,6 +21,9 @@ _Andrew Broughton_ **REVISION HISTORY** +3.0.4 +- Better handling of unexpected messages being returned from console + 3.0.2 - Removed RecallInc/Dec for Rivage (not supported) - Removed Cued Channel Variables for TF (not supported) diff --git a/companion/HELP.md b/companion/HELP.md index c0699894..f1a0bf7f 100644 --- a/companion/HELP.md +++ b/companion/HELP.md @@ -1,4 +1,4 @@ -## Yamaha Remote Control Protocol - v3.0.3 +## Yamaha Remote Control Protocol - v3.0.4 Please visit https://discourse.checkcheckonetwo.com for help, discussions, suggestions, etc. diff --git a/companion/manifest.json b/companion/manifest.json index 6016709f..4297d7a0 100644 --- a/companion/manifest.json +++ b/companion/manifest.json @@ -3,7 +3,7 @@ "name": "yamaha-rcp", "shortname": "yamaha-rcp", "description": "yamaha-rcp", - "version": "3.0.3" , + "version": "0.0.0", "license": "MIT", "repository": "git+https://github.com/bitfocus/companion-module-yamaha-rcp.git", "bugs": "https://discourse.checkcheckonetwo.com", diff --git a/index.js b/index.js index de54be0d..42905418 100755 --- a/index.js +++ b/index.js @@ -1,6 +1,6 @@ // Control module for Yamaha Pro Audio digital mixers // Andrew Broughton -// Feb 10, 2023 Version 3.0.3 (v3) +// Mar 7, 2023 Version 3.0.4 (v3) const { InstanceBase, Regex, runEntrypoint, combineRgb, TCPHelper } = require('@companion-module/base') @@ -133,24 +133,13 @@ class instance extends InstanceBase { } this.log('debug', `Received: '${line}'`) receivedCmds = paramFuncs.parseData(this, line, RCP_VALS) // Break out the parameters + if (receivedCmds.length == 0) this.processReqStack() for (let i = 0; i < receivedCmds.length; i++) { let curCmd = JSON.parse(JSON.stringify(receivedCmds[i])) // deep clone let cmdToFind = curCmd.Address - let reqIdx = this.reqStack.findIndex((c) => - (c.Address == curCmd.Address && c.X == (curCmd.X || 0) && c.Y == (curCmd.Y || 0)) - ) - if (reqIdx > -1) { - this.reqStack.splice(reqIdx, 1) // Remove it! - } else { - this.reqStack.shift() // Just in case it's an invalid command stuck in there - } - if (this.reqStack.length > 0) { // More to send? - let cmdToSend = this.reqStack[0] // Oldest - let req = `get ${cmdToSend.Address} ${cmdToSend.X} ${cmdToSend.Y}` - this.sendCmd(req) - } + this.processReqStack(curCmd) foundCmd = this.rcpCommands.find((cmd) => cmd.Address == cmdToFind) // Find which command if (foundCmd != undefined) { @@ -186,6 +175,24 @@ class instance extends InstanceBase { } } + processReqStack(cmd = {Address: '', X: 0, Y: 0}) { + if (this.reqStack == undefined || this.reqStack.length == 0) return + + let reqIdx = this.reqStack.findIndex((c) => + (c.Address == cmd.Address && c.X == (cmd.X || 0) && c.Y == (cmd.Y || 0)) + ) + if (reqIdx > -1) { + this.reqStack.splice(reqIdx, 1) // Got value from matching request so remove it! + } else { + this.reqStack.shift() // Just in case it's an invalid command stuck in there + } + + if (this.reqStack.length > 0) { // More to send? + let cmdToSend = this.reqStack[0] // Oldest + let req = `get ${cmdToSend.Address} ${cmdToSend.X} ${cmdToSend.Y}` + this.sendCmd(req) + } + } // Create the Actions & Feedbacks updateActions() { @@ -340,7 +347,7 @@ class instance extends InstanceBase { return data } - if (cmd.Address.startsWith('MIXER:Lib')) return + if (cmd.Address.startsWith('MIXER:Lib')) return data if (this.reqStack.length == 0) { this.reqStack.push({Address: cmd.Address, X: cmd.options.X, Y: cmd.options.Y}) @@ -406,7 +413,7 @@ class instance extends InstanceBase { let parsedOptions = {} parsedOptions.X = cmdToParse.options.X == undefined ? 0 : parseInt(await context.parseVariablesInString(cmdToParse.options.X)) - 1 parsedOptions.Y = cmdToParse.options.Y == undefined ? 0 : parseInt(await context.parseVariablesInString(cmdToParse.options.Y)) - 1 - parsedOptions.Val = await context.parseVariablesInString(cmdToParse.options.Val) + parsedOptions.Val = await context.parseVariablesInString(cmdToParse.options.Val || '') parsedOptions.X = Math.max(parsedOptions.X, 0) parsedOptions.Y = Math.max(parsedOptions.Y, 0) diff --git a/package.json b/package.json index b948208c..6acbcb5f 100755 --- a/package.json +++ b/package.json @@ -3,7 +3,7 @@ "legacy": [ "yamaha-scp" ], - "version": "3.0.3", + "version": "3.0.4", "main": "index.js", "scripts": { "test": "echo \"Error: no test specified\" && exit 1", @@ -20,7 +20,7 @@ "@companion-module/tools": "^1.0.0" }, "dependencies": { - "@companion-module/base": "~1.2.1" + "@companion-module/base": "~1.3.0" }, "prettier": "@companion-module/tools/.prettierrc.json" } diff --git a/upgrade.js b/upgrade.js index 8ecdca2f..d5fee2e3 100755 --- a/upgrade.js +++ b/upgrade.js @@ -1,5 +1,5 @@ /* -// Do the upgrades of actions, release actions and feedback +// Do the upgrades of actions, release actions and feedback */ module.exports = [ diff --git a/variables.js b/variables.js index b2f5510a..a85d0cfc 100644 --- a/variables.js +++ b/variables.js @@ -119,6 +119,7 @@ module.exports = { }, fbCreatesVar: (instance, cmd, options, data) => { + let cmdName = cmd.rcpCmd.Address.slice(cmd.rcpCmd.Address.indexOf('/') + 1).replace(/\//g, '_') let varName = `V_${cmdName}` varName = varName + (cmd.options.X ? `_${cmd.options.X}` : '')