@@ -1674,10 +1674,11 @@ describe('openBCIUtilities', function () {
16741674 lowerSampleObject . channelData = [ 1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 ] ;
16751675 lowerSampleObject . auxData = [ 0 , 1 , 2 ] ;
16761676 lowerSampleObject . timestamp = 4 ;
1677- lowerSampleObject . accelData = [ 0.5 , - 0.5 , 1 ] ;
1677+ lowerSampleObject . accelData = [ 0 , 0 , 0 ] ;
16781678 // Make the upper sample (channels 9-16)
16791679 upperSampleObject = openBCIUtilities . newSample ( 2 ) ;
16801680 upperSampleObject . channelData = [ 9 , 10 , 11 , 12 , 13 , 14 , 15 , 16 ] ;
1681+ lowerSampleObject . accelData = [ 0 , 1 , 2 ] ;
16811682 upperSampleObject . auxData = [ 3 , 4 , 5 ] ;
16821683 upperSampleObject . timestamp = 8 ;
16831684
@@ -1686,11 +1687,12 @@ describe('openBCIUtilities', function () {
16861687 lowerSampleObjectNoScale = openBCIUtilities . newSample ( 1 ) ;
16871688 lowerSampleObjectNoScale . channelDataCounts = [ 1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 ] ;
16881689 lowerSampleObjectNoScale . auxData = [ 0 , 1 , 2 ] ;
1690+ lowerSampleObjectNoScale . accelDataCounts = [ 0 , 0 , 0 ] ;
16891691 lowerSampleObjectNoScale . timestamp = 4 ;
1690- lowerSampleObjectNoScale . accelData = [ 0.5 , - 0.5 , 1 ] ;
16911692 // Make the upper sample (channels 9-16)
16921693 upperSampleObjectNoScale = openBCIUtilities . newSample ( 2 ) ;
16931694 upperSampleObjectNoScale . channelDataCounts = [ 9 , 10 , 11 , 12 , 13 , 14 , 15 , 16 ] ;
1695+ lowerSampleObjectNoScale . accelDataCounts = [ 0 , 1 , 2 ] ;
16941696 upperSampleObjectNoScale . auxData = [ 3 , 4 , 5 ] ;
16951697 upperSampleObjectNoScale . timestamp = 8 ;
16961698
@@ -1741,6 +1743,28 @@ describe('openBCIUtilities', function () {
17411743 } ) ;
17421744 it ( 'should store an accelerometer value if present' , function ( ) {
17431745 expect ( daisySampleObject ) . to . have . property ( 'accelData' ) ;
1746+ expect ( daisySampleObject . accelData ) . to . deep . equal ( [ 0 , 1 , 2 ] ) ;
1747+ expect ( daisySampleObjectNoScale ) . to . have . property ( 'accelDataCounts' ) ;
1748+ expect ( daisySampleObjectNoScale . accelDataCounts ) . to . deep . equal ( [ 0 , 1 , 2 ] ) ;
1749+ } ) ;
1750+ it ( 'should work for all accel cases to extract the non-zero values' , function ( ) {
1751+ let lowerSample = openBCIUtilities . newSample ( 1 ) ;
1752+ lowerSample . accelData = [ 0 , 1 , 2 ] ;
1753+ let upperSample = openBCIUtilities . newSample ( 2 ) ;
1754+ upperSample . accelData = [ 0 , 0 , 0 ] ;
1755+
1756+ let lowerSampleNoScale = openBCIUtilities . newSampleNoScale ( 1 ) ;
1757+ lowerSampleNoScale . accelDataCounts = [ 0 , 1 , 2 ] ;
1758+ let upperSampleNoScale = openBCIUtilities . newSampleNoScale ( 2 ) ;
1759+ upperSampleNoScale . accelDataCounts = [ 0 , 0 , 0 ] ;
1760+
1761+ // Call the function under test
1762+ let daisySample = openBCIUtilities . makeDaisySampleObjectWifi ( lowerSample , upperSample ) ;
1763+ let daisySampleNoScale = openBCIUtilities . makeDaisySampleObjectWifi ( lowerSampleNoScale , upperSampleNoScale ) ;
1764+ expect ( daisySample ) . to . have . property ( 'accelData' ) ;
1765+ expect ( daisySample . accelData ) . to . deep . equal ( [ 0 , 1 , 2 ] ) ;
1766+ expect ( daisySampleNoScale ) . to . have . property ( 'accelDataCounts' ) ;
1767+ expect ( daisySampleNoScale . accelDataCounts ) . to . deep . equal ( [ 0 , 1 , 2 ] ) ;
17441768 } ) ;
17451769 } ) ;
17461770 describe ( '#isEven' , function ( ) {
@@ -2708,6 +2732,30 @@ describe('#extractRawDataPackets', function () {
27082732 expect ( bufferEqual ( expectedRawDataPackets [ i ] , output . rawDataPackets [ i ] ) ) . to . be . true ( `Expected 0x${ expectedRawDataPackets [ i ] . toString ( 'HEX' ) } to equal 0x${ output . rawDataPackets [ i ] . toString ( 'HEX' ) } ` ) ;
27092733 }
27102734 } ) ;
2735+ it ( 'should be able to extract multiple packets from a single buffer when daisy' , ( ) => {
2736+ // We are going to extract multiple buffers
2737+ let expectedNumberOfBuffers = 4 ;
2738+ // declare the big buffer
2739+ let buffer = new Buffer ( k . OBCIPacketSize * expectedNumberOfBuffers ) ;
2740+ // Fill that new big buffer with buffers
2741+ const expectedRawDataPackets = [
2742+ openBCIUtilities . samplePacketReal ( 0 ) ,
2743+ openBCIUtilities . samplePacketReal ( 0 ) ,
2744+ openBCIUtilities . samplePacketReal ( 1 ) ,
2745+ openBCIUtilities . samplePacketReal ( 1 )
2746+ ] ;
2747+ expectedRawDataPackets [ 0 ] . copy ( buffer , 0 ) ;
2748+ expectedRawDataPackets [ 1 ] . copy ( buffer , k . OBCIPacketSize ) ;
2749+ expectedRawDataPackets [ 2 ] . copy ( buffer , k . OBCIPacketSize * 2 ) ;
2750+ expectedRawDataPackets [ 2 ] . copy ( buffer , k . OBCIPacketSize * 3 ) ;
2751+ // Call the function under test
2752+ const output = openBCIUtilities . extractRawDataPackets ( buffer ) ;
2753+ // The buffer should not have anything in it any more
2754+ expect ( output . buffer ) . to . be . null ( ) ;
2755+ for ( let i = 0 ; i < expectedNumberOfBuffers ; i ++ ) {
2756+ expect ( bufferEqual ( expectedRawDataPackets [ i ] , output . rawDataPackets [ i ] ) ) . to . be . true ( `Expected 0x${ expectedRawDataPackets [ i ] . toString ( 'HEX' ) } to equal 0x${ output . rawDataPackets [ i ] . toString ( 'HEX' ) } ` ) ;
2757+ }
2758+ } ) ;
27112759
27122760 it ( 'should be able to get multiple packets and keep extra data on the end' , ( ) => {
27132761 let expectedString = 'AJ' ;
0 commit comments