File tree Expand file tree Collapse file tree 3 files changed +13
-20
lines changed Expand file tree Collapse file tree 3 files changed +13
-20
lines changed Original file line number Diff line number Diff line change @@ -30,21 +30,8 @@ class SerialTransport: public ITransport {
3030 }
3131
3232 size_t read (uint8_t * buffer, size_t size) override {
33-
34- size_t r_size = 0 ;
35-
36- while (_stream->available ()){
37- if (r_size == size){
38- return r_size;
39- }
40- buffer[r_size] = _stream->read ();
41- r_size++;
42- // TODO the following delay is essential for GIGA to work. Is it worth making giga-specific?
43- delay (1 );
44- }
45-
46- return r_size;
47-
33+ _stream->setTimeout (0 );
34+ return _stream->readBytes (buffer, size);
4835 }
4936
5037 size_t read_byte (uint8_t & r) override {
Original file line number Diff line number Diff line change @@ -32,8 +32,9 @@ class RPCClient {
3232 RpcError error;
3333 // blocking call
3434 while (!decoder.get_response (msg_id, result, error)){
35- decoder.process ();
36- delay (1 );
35+ if (!decoder.process ()) {
36+ delay (1 );
37+ }
3738 }
3839
3940 lastError.code = error.code ;
Original file line number Diff line number Diff line change @@ -168,8 +168,12 @@ class RpcDecoder {
168168
169169 }
170170
171- void process (){
172- if (advance ()) parse_packet ();
171+ bool process (){
172+ if (advance ()) {
173+ parse_packet ();
174+ return true ;
175+ }
176+ return false ;
173177 }
174178
175179 // Fill the raw buffer to its capacity
@@ -188,8 +192,9 @@ class RpcDecoder {
188192 delay (1 );
189193 }
190194 }
195+ return true ;
191196 }
192- return true ;
197+ return false ;
193198 }
194199
195200 void parse_packet (){
You can’t perform that action at this time.
0 commit comments