@@ -8,7 +8,7 @@ using namespace std;
88
99void sioVoice::sio_sam_parameters ()
1010{
11- string s = string ((char *)sioBuffer);
11+ string s = string ((char *)lineBuffer); // change to lineBuffer
1212 vector<string> tokens = util_tokenize (s, ' ' );
1313
1414 for (vector<string>::iterator it = tokens.begin (); it != tokens.end (); ++it)
@@ -56,17 +56,10 @@ void sioVoice::sio_sam()
5656{
5757 int n = 0 ;
5858 char *a[16 ];
59- int i = 0 ;
59+ // int i = 0;
6060
61- memset (samBuffer,0 ,sizeof (samBuffer));
62- memset (a,0 ,sizeof (a));
63-
64- while (sioBuffer[i] != EOL && i < 39 )
65- {
66- i++;
67- }
68-
69- sioBuffer[i] = ' \0 ' ;
61+ memset (samBuffer, 0 , sizeof (samBuffer));
62+ memset (a, 0 , sizeof (a));
7063
7164 // Construct parameter buffer.
7265 a[n++] = (char *)(" sam" );
@@ -126,7 +119,27 @@ void sioVoice::sio_write()
126119
127120 if (ck == sio_checksum (sioBuffer, n))
128121 {
129- sio_sam ();
122+ // append sioBuffer onto lineBuffer until EOL is reached
123+ // move this logic to append \0 into sio_write
124+ uint8_t i = 0 ;
125+ while (i < 40 )
126+ {
127+ if (sioBuffer[i] != EOL && buffer_idx < 121 )
128+ {
129+ lineBuffer[buffer_idx] = sioBuffer[i];
130+ buffer_idx++;
131+ }
132+ else
133+ {
134+ lineBuffer[buffer_idx] = ' \0 ' ;
135+ buffer_idx = 0 ;
136+ sio_sam ();
137+ // clear lineBuffer
138+ memset (lineBuffer, 0 , sizeof (lineBuffer));
139+ break ;
140+ }
141+ i++;
142+ }
130143 sio_complete ();
131144 }
132145 else
@@ -143,7 +156,7 @@ void sioVoice::sio_status()
143156
144157 status[0 ] = 0 ;
145158 status[1 ] = lastAux1;
146- status[2 ] = 5 ;
159+ status[2 ] = 15 ; // set timeout > 10 seconds (SAM audio buffer)
147160 status[3 ] = 0 ;
148161
149162 sio_to_computer (status, sizeof (status), false );
0 commit comments