X-Git-Url: https://sigrok.org/gitweb/?a=blobdiff_plain;f=src%2Fhardware%2Fcenter-3xx%2Fprotocol.c;h=81868b0618aa141f8702bdea993eac3a8fe96110;hb=599f9e1deb6b6a4a75e00e29d86935845164eeed;hp=b4d9ed5ba834162cc063e2bc47a9a3579ef0acce;hpb=869c83751149aa03cda072355c2b670569cdfc0d;p=libsigrok.git
diff --git a/src/hardware/center-3xx/protocol.c b/src/hardware/center-3xx/protocol.c
index b4d9ed5b..81868b06 100644
--- a/src/hardware/center-3xx/protocol.c
+++ b/src/hardware/center-3xx/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
@@ -178,7 +177,7 @@ static gboolean 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, ret = FALSE;
+ int len, offset, ret = FALSE;
devc = sdi->priv;
serial = sdi->conn;
@@ -194,6 +193,7 @@ static gboolean 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) >= center_devs[idx].packet_size) {
if (center_devs[idx].packet_valid(devc->buf + offset)) {
handle_packet(devc->buf + offset, sdi, idx);
@@ -205,8 +205,8 @@ static gboolean 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;
return ret;
@@ -244,7 +244,7 @@ static int receive_data(int fd, int revents, int idx, void *cb_data)
}
if (sr_sw_limits_check(&devc->sw_limits))
- sdi->driver->dev_acquisition_stop(sdi);
+ sr_dev_acquisition_stop(sdi);
return TRUE;
}