X-Git-Url: http://sigrok.org/gitweb/?a=blobdiff_plain;f=src%2Fhardware%2Fmic-985xx%2Fprotocol.c;h=2218f32b2908d3f3538db02489fa5429a2da83b1;hb=9417f26fd47556c4b4f6ecaa08a2860672664eb9;hp=8ae324334e474b15b098b85670c023319457823a;hpb=b66a0b5bddedfe6399256799bdc783f62dcc7a95;p=libsigrok.git
diff --git a/src/hardware/mic-985xx/protocol.c b/src/hardware/mic-985xx/protocol.c
index 8ae32433..2218f32b 100644
--- a/src/hardware/mic-985xx/protocol.c
+++ b/src/hardware/mic-985xx/protocol.c
@@ -14,8 +14,7 @@
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ * along with this program; if not, see .
*/
#include
@@ -151,7 +150,7 @@ static void handle_new_data(struct sr_dev_inst *sdi, int idx)
{
struct dev_context *devc;
struct sr_serial_dev_inst *serial;
- int len, i, offset = 0;
+ int len, offset;
devc = sdi->priv;
serial = sdi->conn;
@@ -167,6 +166,7 @@ static void handle_new_data(struct sr_dev_inst *sdi, int idx)
devc->buflen += len;
/* Now look for packets in that data. */
+ offset = 0;
while ((devc->buflen - offset) >= mic_devs[idx].packet_size) {
if (mic_devs[idx].packet_valid(devc->buf + offset)) {
handle_packet(devc->buf + offset, sdi, idx);
@@ -177,8 +177,8 @@ static void handle_new_data(struct sr_dev_inst *sdi, int idx)
}
/* If we have any data left, move it to the beginning of our buffer. */
- for (i = 0; i < devc->buflen - offset; i++)
- devc->buf[i] = devc->buf[offset + i];
+ if (offset < devc->buflen)
+ memmove(devc->buf, devc->buf + offset, devc->buflen - offset);
devc->buflen -= offset;
}
@@ -211,7 +211,7 @@ static int receive_data(int fd, int revents, int idx, void *cb_data)
}
if (sr_sw_limits_check(&devc->limits))
- sdi->driver->dev_acquisition_stop(sdi);
+ sr_dev_acquisition_stop(sdi);
return TRUE;
}