Skip to content

Commit

Permalink
3.0.4 - Better handling of unexpected messages
Browse files Browse the repository at this point in the history
  • Loading branch information
MeestorX committed Mar 8, 2023
1 parent 5848b66 commit 8ef105b
Show file tree
Hide file tree
Showing 7 changed files with 33 additions and 22 deletions.
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -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**

Expand All @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion companion/HELP.md
Original file line number Diff line number Diff line change
@@ -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.

Expand Down
2 changes: 1 addition & 1 deletion companion/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
39 changes: 23 additions & 16 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Control module for Yamaha Pro Audio digital mixers
// Andrew Broughton <[email protected]>
// 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')

Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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() {
Expand Down Expand Up @@ -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})
Expand Down Expand Up @@ -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)

Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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"
}
2 changes: 1 addition & 1 deletion upgrade.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
// Do the upgrades of actions, release actions and feedback
// Do the upgrades of actions, release actions and feedback
*/

module.exports = [
Expand Down
1 change: 1 addition & 0 deletions variables.js
Original file line number Diff line number Diff line change
Expand Up @@ -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}` : '')
Expand Down

0 comments on commit 8ef105b

Please sign in to comment.