Skip to content

Commit

Permalink
Make compatible with Atem Control version 6.7
Browse files Browse the repository at this point in the history
Problem: Aux switching was not working anymore
Solution: Remove 4 empty bytes at the end of the CAuS message
  • Loading branch information
Dev1an committed Apr 3, 2016
1 parent 937aeae commit 7dd91e2
Showing 1 changed file with 21 additions and 22 deletions.
43 changes: 21 additions & 22 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -354,7 +354,7 @@ function Device(atemIpAddress){
// If it's the first time this packet is sent
if (pendingPackets.indexOf(this) == -1 && !this.serializedCache) {
this.header.uid = uid;

if ( this.isSync() || this.isConnect() ) {
this.header.ls = ls;
}
Expand Down Expand Up @@ -441,7 +441,7 @@ function Device(atemIpAddress){
this.header.ls = msg.readUInt16BE(10);

if ((this.header.flags & flags.unknown) == flags.unknown) console.log('Unknown Packet flag!');

if (state === ConnectionState.attempting) {
if (this.isSync()){
atem.state = ConnectionState.establishing;
Expand Down Expand Up @@ -475,7 +475,7 @@ function Device(atemIpAddress){
* @event Device#rawCommand
* @type {Command}
*/

// todo: check foreign sequence number, to prevent the event emitter
// from emitting the same message twice.
atem.emit('rawCommand', cmd);
Expand Down Expand Up @@ -550,8 +550,8 @@ function Device(atemIpAddress){
return count
}




this.sendCommand = function(cmd) {
commandQueue = commandQueue.concat(cmd);
Expand Down Expand Up @@ -657,39 +657,38 @@ function Device(atemIpAddress){
const cmd = new Command('CPvI', data);
atem.sendCommand(cmd);
};

/**
* Change the auxiliary output
* @param {SourceID} aux
* @param {SourceID} source
* @param {SourceID} aux
* @param {SourceID} source
*/
this.setAux = function(aux, source){
var data = new Buffer(8);
var data = new Buffer(4);
data[0] = 1;
data[1] = aux - 8001;
data.writeUInt16BE(source, 2);
data.writeUInt32BE(0, 4);

const cmd = new Command('CAuS', data);
atem.sendCommand(cmd);
}




this.on('connected', function() {
sync();
});

this.on('messageTimeout', function() {

});

this.on('connectionLost', function() {
console.log('Connection Lost');
atem.disconnect(atem.connect);
});

this.on('InPr', function(d) {
const sourceID = d.readUInt16BE(0);

Expand Down Expand Up @@ -807,10 +806,10 @@ function Device(atemIpAddress){
*/
this.connect = function() {

if (atem.state === ConnectionState.closed) {
if (atem.state === ConnectionState.closed) {
uid = Math.round(Math.random() * 0x7FF);
ls = 0;

if (atem.ip) {
atem.state = ConnectionState.attempting;

Expand All @@ -823,15 +822,15 @@ function Device(atemIpAddress){
const err = new Error('IP not set');
atem.emit('error', err);
}

} else {
atem.disconnect(atem.connect);
}
}

this.disconnect = function(callback) {
console.log('Disconnecting');

clearInterval(syncInterval);
clearTimeout(communicationTimeout);
pendingPackets.forEach(function(packet) {
Expand All @@ -840,7 +839,7 @@ function Device(atemIpAddress){
atem.state = ConnectionState.closed;

if (socket) socket.close();

if (callback) callback();
}

Expand Down

0 comments on commit 7dd91e2

Please sign in to comment.