@@ -1674,10 +1674,11 @@ describe('openBCIUtilities', function () {
1674
1674
lowerSampleObject . channelData = [ 1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 ] ;
1675
1675
lowerSampleObject . auxData = [ 0 , 1 , 2 ] ;
1676
1676
lowerSampleObject . timestamp = 4 ;
1677
- lowerSampleObject . accelData = [ 0.5 , - 0.5 , 1 ] ;
1677
+ lowerSampleObject . accelData = [ 0 , 0 , 0 ] ;
1678
1678
// Make the upper sample (channels 9-16)
1679
1679
upperSampleObject = openBCIUtilities . newSample ( 2 ) ;
1680
1680
upperSampleObject . channelData = [ 9 , 10 , 11 , 12 , 13 , 14 , 15 , 16 ] ;
1681
+ lowerSampleObject . accelData = [ 0 , 1 , 2 ] ;
1681
1682
upperSampleObject . auxData = [ 3 , 4 , 5 ] ;
1682
1683
upperSampleObject . timestamp = 8 ;
1683
1684
@@ -1686,11 +1687,12 @@ describe('openBCIUtilities', function () {
1686
1687
lowerSampleObjectNoScale = openBCIUtilities . newSample ( 1 ) ;
1687
1688
lowerSampleObjectNoScale . channelDataCounts = [ 1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 ] ;
1688
1689
lowerSampleObjectNoScale . auxData = [ 0 , 1 , 2 ] ;
1690
+ lowerSampleObjectNoScale . accelDataCounts = [ 0 , 0 , 0 ] ;
1689
1691
lowerSampleObjectNoScale . timestamp = 4 ;
1690
- lowerSampleObjectNoScale . accelData = [ 0.5 , - 0.5 , 1 ] ;
1691
1692
// Make the upper sample (channels 9-16)
1692
1693
upperSampleObjectNoScale = openBCIUtilities . newSample ( 2 ) ;
1693
1694
upperSampleObjectNoScale . channelDataCounts = [ 9 , 10 , 11 , 12 , 13 , 14 , 15 , 16 ] ;
1695
+ lowerSampleObjectNoScale . accelDataCounts = [ 0 , 1 , 2 ] ;
1694
1696
upperSampleObjectNoScale . auxData = [ 3 , 4 , 5 ] ;
1695
1697
upperSampleObjectNoScale . timestamp = 8 ;
1696
1698
@@ -1741,6 +1743,28 @@ describe('openBCIUtilities', function () {
1741
1743
} ) ;
1742
1744
it ( 'should store an accelerometer value if present' , function ( ) {
1743
1745
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 ] ) ;
1744
1768
} ) ;
1745
1769
} ) ;
1746
1770
describe ( '#isEven' , function ( ) {
@@ -2708,6 +2732,30 @@ describe('#extractRawDataPackets', function () {
2708
2732
expect ( bufferEqual ( expectedRawDataPackets [ i ] , output . rawDataPackets [ i ] ) ) . to . be . true ( `Expected 0x${ expectedRawDataPackets [ i ] . toString ( 'HEX' ) } to equal 0x${ output . rawDataPackets [ i ] . toString ( 'HEX' ) } ` ) ;
2709
2733
}
2710
2734
} ) ;
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
+ } ) ;
2711
2759
2712
2760
it ( 'should be able to get multiple packets and keep extra data on the end' , ( ) => {
2713
2761
let expectedString = 'AJ' ;
0 commit comments