@@ -37,6 +37,43 @@ describe('openBCIUtilities', function () {
3737 accelArray = [ 0 , 0 , 0 ] ;
3838 } ) ;
3939 afterEach ( ( ) => bluebirdChecks . noPendingPromises ( ) ) ;
40+ describe ( '#processMultiBytePacketStop' , function ( ) {
41+ it ( 'should output the message' , function ( ) {
42+ const rawBuf = Buffer . from ( [ 0xCF , 0x65 , 0x64 , 0x0A ] ) ;
43+
44+ const expectedOutput = 'ed\n' ;
45+
46+ const actualOutput = openBCIUtilities . processMultiBytePacketStop ( {
47+ multiPacketBuffer : null ,
48+ rawDataPacket : rawBuf
49+ } ) ;
50+ expect ( actualOutput . message ) . to . equal ( expectedOutput ) ;
51+ } ) ;
52+ } ) ;
53+ describe ( '#processMultiBytePacket' , function ( ) {
54+ it ( 'should be convert raw data packtet to string' , function ( ) {
55+ const rawBufMulti = Buffer . from ( [ 0xCE , 0x61 , 0x63 , 0x63 , 0x65 , 0x6C , 0x65 , 0x72 , 0x6F , 0x6D , 0x65 , 0x74 , 0x65 , 0x72 , 0x20 , 0x65 , 0x6E , 0x61 , 0x62 , 0x6C ] ) ;
56+
57+ const expectedRawBufMulti = Buffer . from ( [ 0x61 , 0x63 , 0x63 , 0x65 , 0x6C , 0x65 , 0x72 , 0x6F , 0x6D , 0x65 , 0x74 , 0x65 , 0x72 , 0x20 , 0x65 , 0x6E , 0x61 , 0x62 , 0x6C ] ) ;
58+
59+ const o = { } ;
60+ o . rawDataPacket = rawBufMulti ;
61+ openBCIUtilities . processMultiBytePacket ( o ) ;
62+ expect ( o . multiPacketBuffer . toString ( ) ) . to . equal ( expectedRawBufMulti . toString ( ) ) ;
63+ } ) ;
64+ it ( 'should be able to concat multi byte messages' , function ( ) {
65+ const rawBufMulti = Buffer . from ( [ 0xCE , 0x61 , 0x63 , 0x63 , 0x65 , 0x6C , 0x65 , 0x72 , 0x6F , 0x6D , 0x65 , 0x74 , 0x65 , 0x72 , 0x20 , 0x65 , 0x6E , 0x61 , 0x62 , 0x6C ] ) ;
66+ const o = {
67+ multiPacketBuffer : rawBufMulti . slice ( 1 ) . toString ( )
68+ } ;
69+ const rawBufStop = Buffer . from ( [ 0xCF , 0x65 , 0x64 , 0x0A ] ) ;
70+ const expectedRawBufMulti = Buffer . from ( [ 0x61 , 0x63 , 0x63 , 0x65 , 0x6C , 0x65 , 0x72 , 0x6F , 0x6D , 0x65 , 0x74 , 0x65 , 0x72 , 0x20 , 0x65 , 0x6E , 0x61 , 0x62 , 0x6C , 0x65 , 0x64 , 0x0A ] ) ;
71+
72+ o . rawDataPacket = rawBufStop ;
73+ openBCIUtilities . processMultiBytePacket ( o ) ;
74+ expect ( o . multiPacketBuffer . toString ( ) ) . to . equal ( expectedRawBufMulti . toString ( ) ) ;
75+ } ) ;
76+ } ) ;
4077 describe ( '#convertGanglionArrayToBuffer' , function ( ) {
4178 it ( 'should fill the packet with values from data' , function ( ) {
4279 const numChannels = k . numberOfChannelsForBoardType ( k . OBCIBoardGanglion ) ;
0 commit comments