- uint8_t result = dispatch_command(cmd, length);
- interface_send1(result);
+ uint8_t i;
+ if(cmd_read_pos+count>cmd_length)
+ count = cmd_length-cmd_read_pos;
+ for(i=0; i<count; ++i)
+ cmd_buffer[cmd_read_pos++] = serial_read();
+
+ if(cmd_read_pos>=cmd_length)
+ {
+ uint8_t result = dispatch_command(cmd_buffer, cmd_length);
+ interface_send1(result);
+ cmd_length = 0;
+ }