Post 1 made on Friday July 19, 2019 at 19:46 |
Fiasco Senior Member |
Joined: Posts: | July 2009 1,282 |
|
|
An insanely cruel barely documented protocol. I've got the string calculator and know how to bring up the sniffer from the GUI programming software. I want basic functions. Volume control, mute and feedback from those for my CF controller. I've been working on a JS driver and have mute and ramped volume control function. The string calculator only calculates the most basic functions and trying to decipher which codes being sent back and forth are relevant is making my eyes bleed. Does anyone, per chance, know how to register for mute feedback for example? If I had one working command to register for and request/trigger feedback on one specific function (mute for example) I would be off to the races. var ZonePro = function() { var self = { system: "", model: "", join: -1, feedback : "", debug: 1, zone1 : ["01","05","00","10"], zone2 : ["01","05","01","11"], zone3 : ["01","05","02","12"], zone4 : ["01","05","03","13"], }; self.setup = function(system, feedback) { self.log("Creating " + system + " " + feedback ); self.system = system; self.feedback = feedback; }; self.initialize = function() { self.log("init"); CF.watch(CF.FeedbackMatchedEvent, self.system, self.feedback, self.ProcessFeedback); self.sendHeartbeat(); }; /////////////////////////////// // VOLUME FUNCTIONS // /////////////////////////////// self.setVolume = function(zone, volume) { switch (zone) { case 1: self.setZoneVolume(self.zone1, volume); break; case 2: self.setZoneVolume(self.zone2, volume); break; case 3: self.setZoneVolume(self.zone3, volume); self.setZoneVolume(self.zone4, volume); break; } }; self.setZoneVolume = function(zone, volume) { var commandarray = ["F0","64","00","01","00","00","00","1C","00","33"]; var fillarray = ["00","30"]; var endarray = ["01","00","00","00","00","01","00","01","03","00"]; commandarray = commandarray.concat(zone, fillarray, zone, endarray); commandarray.push((parseInt(volume) * 2 + 181).toString(16)); commandarray.push(self.checksum(commandarray)); self.log(commandarray); self.sendCommand(self.hexify(commandarray)); }; /////////////////////////////// // MUTE FUNCTIONS // /////////////////////////////// self.muteOn = function() { self.log("Mute"); self.muteZoneOn(1, "01"); self.muteZoneOn(2, "01"); self.muteZoneOn(3, "01"); self.muteZoneOn(4, "01"); }; self.muteOff = function() { self.log("UnMute"); self.muteZoneOn(1, "00"); self.muteZoneOn(2, "00"); self.muteZoneOn(3, "00"); self.muteZoneOn(4, "00"); }; self.muteZoneOn = function(zone, mute) { var commandarray = ["F0","64","00","01","00","00","00","1B","00","33"]; var fillarray = ["00","30"]; var endarray = ["01","00","00","00","00","01","00","02","01"]; var target = ""; switch (zone) { case 1: target = self.zone1; break; case 2: target = self.zone2; break; case 3: target = self.zone3; break; case 4: target = self.zone4; break; } commandarray = commandarray.concat(target, fillarray, target, endarray); commandarray.push(mute); commandarray.push(self.checksum(commandarray)); self.sendCommand(self.hexify(commandarray)); }; /////////////////////////////// // FEEDBACK // /////////////////////////////// self.ProcessFeedback = function(feedbackname, feedbackstring) { self.log("fb " + feedbackname + " " + feedbackstring); // hahahah yea right return; }; /////////////////////////////// // INTERNAL HELPER FUNCTIONS // /////////////////////////////// self.sendHeartbeat = function() { // Heartbeat F0 8C self.log("heartbeat"); self.sendCommand("\xF0\x8C"); }; self.hexify = function( array ) { var string = ""; for ( var i = 0; i < array.length; i++) { string = string + String.fromCharCode(parseInt(array[i],16)); } return string; }; self.checksum = function(dbx) { var ccit = ["5E","BC","E2","61","3F","DD","83","C2","9C","7E","20","A3","FD","1F","41","9D" ,"C3","21","7F","FC","A2","40","1E","5F","01","E3","BD","3E","60","82","DC","23", "7D","9F","C1","42","1C","FE","A0","E1","BF","5D","03","80","DE","3C","62","BE", "E0","02","5C","DF","81","63","3D","7C","22","C0","9E","1D","43","A1","FF","46"," 18","FA","A4","27","79","9B","C5","84","DA","38","66","E5","BB","59","07","DB"," 85","67","39","BA","E4","06","58","19","47","A5","FB","78","26","C4","9A","65"," 3B","D9","87","04","5A","B8","E6","A7","F9","1B","45","C6","98","7A","24","F8"," A6","44","1A","99","C7","25","7B","3A","64","86","D8","5B","05","E7","B9","8C"," D2","30","6E","ED","B3","51","0F","4E","10","F2","AC","2F","71","93","CD","11"," 4F","AD","F3","70","2E","CC","92","D3","8D","6F","31","B2","EC","0E","50","AF"," F1","13","4D","CE","90","72","2C","6D","33","D1","8F","0C","52","B0","EE","32"," 6C","8E","D0","53","0D","EF","B1","F0","AE","4C","12","91","CF","2D","73","CA"," 94","76","28","AB","F5","17","49","08","56","B4","EA","69","37","D5","8B","57"," 09","EB","B5","36","68","8A","D4","95","CB","29","77","F4","AA","48","16","E9"," B7","55","0B","88","D6","34","6A","2B","75","97","C9","4A","14","F6","A8","74"," 2A","C8","96","15","4B","A9","F7","B6","E8","0A","54","D7","89","6B","35"]; var bcc = "FF"; for (var i = 1; i < dbx.length; i++ ) { var dbx1 = parseInt(dbx[i],16); var bcc1 = parseInt(bcc,16); var bcc = ccit[(bcc1^dbx1)-1]; } return bcc; }; self.sendCommand = function (command) { CF.send("Moxa_ZonePro", command + "\n"); }; // Only allow logging calls when CF is in debug mode - better performance in release mode this way self.log = function(msg) { if (CF.debug && self.debug) { CF.log("ZonePro: " + msg); } }; return self; }; CF.modules.push({ name: "DBX ZonePro", object: ZonePro, version: 1.0 });
Last edited by Fiasco on July 19, 2019 21:52.
|
|
Pump House on Facebook: [Link: facebook.com] |
|