@@ -545,7 +545,7 @@ Cyton.prototype.write = function (dataToWrite) {
545545
546546/**
547547 * @description Should be used to send data to the board
548- * @param data {Buffer} - The data to write out
548+ * @param data {Buffer | Buffer2 } - The data to write out
549549 * @returns {Promise } if signal was able to be sent
550550 * @author AJ Keller (@pushtheworldllc)
551551 */
@@ -1277,7 +1277,12 @@ Cyton.prototype.channelSet = function (channelNumber, powerDown, gain, inputType
12771277 . then ( ( val ) => {
12781278 arrayOfCommands = val . commandArray ;
12791279 this . _rawDataPacketToSample . channelSettings [ channelNumber - 1 ] = val . newChannelSettingsObject ;
1280- return this . write ( arrayOfCommands ) ;
1280+ if ( this . usingAtLeastVersionTwoFirmware ( ) ) {
1281+ const buf = Buffer . from ( arrayOfCommands . join ( '' ) ) ;
1282+ return this . _writeAndDrain ( buf ) ;
1283+ } else {
1284+ return this . write ( arrayOfCommands ) ;
1285+ }
12811286 } ) . then ( resolve , reject ) ;
12821287 } ) ;
12831288} ;
@@ -1684,7 +1689,7 @@ Cyton.prototype.sdStart = function (recordingDuration) {
16841689 if ( ! this . isStreaming ( ) ) {
16851690 this . curParsingMode = k . OBCIParsingEOT ;
16861691 }
1687- this . writeOutDelay = k . OBCIWriteIntervalDelayMSNone ;
1692+ // this.writeOutDelay = k.OBCIWriteIntervalDelayMSNone;
16881693 this . write ( command ) . then ( resolve , reject ) ;
16891694 } )
16901695 . catch ( err => reject ( err ) ) ;
@@ -1704,7 +1709,7 @@ Cyton.prototype.sdStop = function () {
17041709 if ( ! this . isStreaming ( ) ) {
17051710 this . curParsingMode = k . OBCIParsingEOT ;
17061711 }
1707- this . writeOutDelay = k . OBCIWriteIntervalDelayMSNone ;
1712+ // this.writeOutDelay = k.OBCIWriteIntervalDelayMSNone;
17081713 this . write ( k . OBCISDLogStop ) . then ( resolve , reject ) ;
17091714 } ) ;
17101715} ;
@@ -1928,10 +1933,10 @@ Cyton.prototype._processParseBufferForReset = function (dataBuffer) {
19281933 } else {
19291934 this . info . firmware = k . OBCIFirmwareV3 ;
19301935 }
1931- this . writeOutDelay = k . OBCIWriteIntervalDelayMSNone ;
1936+ this . writeOutDelay = k . OBCIWriteIntervalDelayMSShort ;
19321937 } else {
19331938 this . info . firmware = k . OBCIFirmwareV1 ;
1934- this . writeOutDelay = k . OBCIWriteIntervalDelayMSShort ;
1939+ this . writeOutDelay = k . OBCIWriteIntervalDelayMSLong ;
19351940 }
19361941} ;
19371942
@@ -2302,28 +2307,4 @@ Cyton.prototype.debugSession = function () {
23022307 this . printPacketsBad ( ) ;
23032308} ;
23042309
2305- /**
2306- * @description To pretty print the info recieved on a Misc Register Query (printRegisterSettings)
2307- * @param channelSettingsObj
2308- */
2309- /* istanbul ignore next */
2310- Cyton . prototype . debugPrintChannelSettings = function ( channelSettingsObj ) {
2311- console . log ( '-- Channel Settings Object --' ) ;
2312- var powerState = 'OFF' ;
2313- if ( channelSettingsObj . POWER_DOWN . toString ( ) . localeCompare ( '1' ) ) {
2314- powerState = 'ON' ;
2315- }
2316- console . log ( '---- POWER STATE: ' + powerState ) ;
2317- console . log ( '-- END --' ) ;
2318- } ;
2319-
2320- /**
2321- * @description Quickly determine if a channel is on or off from a channelSettingObject. Most likely from a getChannelSettings call.
2322- * @param channelSettingsObject
2323- * @returns {boolean }
2324- */
2325- Cyton . prototype . channelIsOnFromChannelSettingsObject = function ( channelSettingsObject ) {
2326- return channelSettingsObject . POWER_DOWN . toString ( ) . localeCompare ( '1' ) === 1 ;
2327- } ;
2328-
23292310module . exports = Cyton ;
0 commit comments