@@ -354,7 +354,7 @@ function Device(atemIpAddress){
354354 // If it's the first time this packet is sent
355355 if ( pendingPackets . indexOf ( this ) == - 1 && ! this . serializedCache ) {
356356 this . header . uid = uid ;
357-
357+
358358 if ( this . isSync ( ) || this . isConnect ( ) ) {
359359 this . header . ls = ls ;
360360 }
@@ -441,7 +441,7 @@ function Device(atemIpAddress){
441441 this . header . ls = msg . readUInt16BE ( 10 ) ;
442442
443443 if ( ( this . header . flags & flags . unknown ) == flags . unknown ) console . log ( 'Unknown Packet flag!' ) ;
444-
444+
445445 if ( state === ConnectionState . attempting ) {
446446 if ( this . isSync ( ) ) {
447447 atem . state = ConnectionState . establishing ;
@@ -475,7 +475,7 @@ function Device(atemIpAddress){
475475 * @event Device#rawCommand
476476 * @type {Command }
477477 */
478-
478+
479479 // todo: check foreign sequence number, to prevent the event emitter
480480 // from emitting the same message twice.
481481 atem . emit ( 'rawCommand' , cmd ) ;
@@ -550,8 +550,8 @@ function Device(atemIpAddress){
550550 return count
551551 }
552552
553-
554-
553+
554+
555555
556556 this . sendCommand = function ( cmd ) {
557557 commandQueue = commandQueue . concat ( cmd ) ;
@@ -657,39 +657,38 @@ function Device(atemIpAddress){
657657 const cmd = new Command ( 'CPvI' , data ) ;
658658 atem . sendCommand ( cmd ) ;
659659 } ;
660-
660+
661661 /**
662662 * Change the auxiliary output
663- * @param {SourceID } aux
664- * @param {SourceID } source
663+ * @param {SourceID } aux
664+ * @param {SourceID } source
665665 */
666666 this . setAux = function ( aux , source ) {
667- var data = new Buffer ( 8 ) ;
667+ var data = new Buffer ( 4 ) ;
668668 data [ 0 ] = 1 ;
669669 data [ 1 ] = aux - 8001 ;
670670 data . writeUInt16BE ( source , 2 ) ;
671- data . writeUInt32BE ( 0 , 4 ) ;
672671
673672 const cmd = new Command ( 'CAuS' , data ) ;
674673 atem . sendCommand ( cmd ) ;
675674 }
676-
677-
678-
675+
676+
677+
679678
680679 this . on ( 'connected' , function ( ) {
681680 sync ( ) ;
682681 } ) ;
683-
682+
684683 this . on ( 'messageTimeout' , function ( ) {
685-
684+
686685 } ) ;
687-
686+
688687 this . on ( 'connectionLost' , function ( ) {
689688 console . log ( 'Connection Lost' ) ;
690689 atem . disconnect ( atem . connect ) ;
691690 } ) ;
692-
691+
693692 this . on ( 'InPr' , function ( d ) {
694693 const sourceID = d . readUInt16BE ( 0 ) ;
695694
@@ -807,10 +806,10 @@ function Device(atemIpAddress){
807806 */
808807 this . connect = function ( ) {
809808
810- if ( atem . state === ConnectionState . closed ) {
809+ if ( atem . state === ConnectionState . closed ) {
811810 uid = Math . round ( Math . random ( ) * 0x7FF ) ;
812811 ls = 0 ;
813-
812+
814813 if ( atem . ip ) {
815814 atem . state = ConnectionState . attempting ;
816815
@@ -823,15 +822,15 @@ function Device(atemIpAddress){
823822 const err = new Error ( 'IP not set' ) ;
824823 atem . emit ( 'error' , err ) ;
825824 }
826-
825+
827826 } else {
828827 atem . disconnect ( atem . connect ) ;
829828 }
830829 }
831830
832831 this . disconnect = function ( callback ) {
833832 console . log ( 'Disconnecting' ) ;
834-
833+
835834 clearInterval ( syncInterval ) ;
836835 clearTimeout ( communicationTimeout ) ;
837836 pendingPackets . forEach ( function ( packet ) {
@@ -840,7 +839,7 @@ function Device(atemIpAddress){
840839 atem . state = ConnectionState . closed ;
841840
842841 if ( socket ) socket . close ( ) ;
843-
842+
844843 if ( callback ) callback ( ) ;
845844 }
846845
0 commit comments