Fix usbdbg exec script

This commit is contained in:
iabdalkader 2014-02-10 03:11:53 +02:00
parent 025f54949f
commit 567feccc66

View File

@ -4,7 +4,8 @@
#include "usbdbg.h"
#define USB_TX_BUF_SIZE (64)
static int frame_tx_bytes;
static int xfer_bytes;
static int xfer_length;
static enum usbdbg_cmd cmd;
extern struct sensor_dev sensor;
@ -15,10 +16,10 @@ void usb_fb_data_in(void *buffer, int *length)
switch (cmd) {
case USBDBG_DUMP_FB: /* dump framebuffer */
if (frame_tx_bytes < (fb->width*fb->height*fb->bpp)) {
memcpy(buffer, fb->pixels+frame_tx_bytes, *length);
if (xfer_bytes < (fb->width*fb->height*fb->bpp)) {
memcpy(buffer, fb->pixels+xfer_bytes, *length);
*length = USB_TX_BUF_SIZE;
frame_tx_bytes += USB_TX_BUF_SIZE;
xfer_bytes += USB_TX_BUF_SIZE;
} else {
*length = 0;
}
@ -34,6 +35,11 @@ void usb_fb_data_out(void *buffer, int length)
switch (cmd) {
case USBDBG_EXEC_SCRIPT: /* execute script */
vstr_add_strn(libmp_get_line(), buffer, length);
xfer_bytes += length;
if (xfer_bytes == xfer_length) {
/* interrupt do_repl */
libmp_line_feed();
}
break;
default: /* error */
@ -47,10 +53,13 @@ void usb_fb_control(uint8_t request, int length)
switch (cmd) {
case USBDBG_DUMP_FB: /* dump framebuffer */
/* reset bytes counter */
frame_tx_bytes = 0;
xfer_bytes = 0;
break;
case USBDBG_EXEC_SCRIPT: /* execute script */
/* reset bytes counter */
xfer_bytes = 0;
xfer_length =length;
break;
default: /* error */