diff --git a/bad.c b/bad.c index b38635d..c1631de 100644 --- a/bad.c +++ b/bad.c @@ -195,6 +195,9 @@ static int handle_stdin(int fd, void *buf) case MSG_VBUS_OFF: device_vbus(selected_device, false); break; + case MSG_SEND_BREAK: + device_send_break(selected_device); + break; default: fprintf(stderr, "unk %d len %d\n", msg->type, msg->len); exit(1); diff --git a/cdb_assist.c b/cdb_assist.c index 9d86bdd..34ae1ec 100644 --- a/cdb_assist.c +++ b/cdb_assist.c @@ -542,8 +542,10 @@ int cdb_target_write(struct device *dev, const void *buf, size_t len) return write(cdb->target_tty, buf, len); } -void cdb_target_break(struct cdb_assist *cdb) +void cdb_send_break(struct device *dev) { + struct cdb_assist *cdb = dev->cdb; + tcsendbreak(cdb->target_tty, 0); } diff --git a/cdb_assist.h b/cdb_assist.h index ec94029..9269c27 100644 --- a/cdb_assist.h +++ b/cdb_assist.h @@ -15,7 +15,7 @@ int cdb_assist_power_off(struct device *dev); void cdb_assist_vbus(struct device *dev, bool on); void cdb_gpio(struct cdb_assist *cdb, int gpio, bool on); int cdb_target_write(struct device *dev, const void *buf, size_t len); -void cdb_target_break(struct cdb_assist *cdb); +void cdb_send_break(struct device *dev); unsigned int cdb_vref(struct cdb_assist *cdb); void cdb_assist_print_status(struct device *dev); void cdb_set_voltage(struct cdb_assist *cdb, unsigned mV); diff --git a/cdba.c b/cdba.c index 9c7cf73..9ed15c5 100644 --- a/cdba.c +++ b/cdba.c @@ -193,11 +193,11 @@ static int tty_callback(int *ssh_fds) write(ssh_fds[0], &hdr, sizeof(hdr)); write(ssh_fds[0], "\001", 1); break; -#if 0 - case 'b': - device_break(device); + case 'B': + hdr.type = MSG_SEND_BREAK; + hdr.len = 0; + write(ssh_fds[0], &hdr, sizeof(hdr)); break; -#endif } special = false; diff --git a/cdba.h b/cdba.h index adbb44c..24582f6 100644 --- a/cdba.h +++ b/cdba.h @@ -27,6 +27,7 @@ enum { MSG_VBUS_ON, MSG_VBUS_OFF, MSG_FASTBOOT_REBOOT, + MSG_SEND_BREAK, }; #endif diff --git a/device.c b/device.c index a51bebb..3ea90a6 100644 --- a/device.c +++ b/device.c @@ -173,3 +173,9 @@ void device_fastboot_key(struct device *device, bool on) if (device->fastboot_key) device->fastboot_key(device, on); } + +void device_send_break(struct device *device) +{ + if (device->send_break) + device->send_break(device); +} diff --git a/device.h b/device.h index 915ed9d..bbb9f02 100644 --- a/device.h +++ b/device.h @@ -28,6 +28,7 @@ struct device { void (*vbus)(struct device *dev, bool on); int (*write)(struct device *dev, const void *buf, size_t len); void (*fastboot_key)(struct device *dev, bool on); + void (*send_break)(struct device *dev); bool set_active; void *cdb; @@ -50,5 +51,6 @@ void device_boot(struct device *device, const void *data, size_t len); void device_fastboot_boot(struct device *device); void device_fastboot_flash_reboot(struct device *device); void device_fastboot_key(struct device *device, bool on); +void device_send_break(struct device *device); #endif diff --git a/device_parser.c b/device_parser.c index 5fd6555..14d7b95 100644 --- a/device_parser.c +++ b/device_parser.c @@ -103,6 +103,7 @@ static void parse_board(struct device_parser *dp) dev->vbus = cdb_assist_vbus; dev->write = cdb_target_write; dev->fastboot_key = cdb_fastboot_key; + dev->send_break = cdb_send_break; } else if (!strcmp(key, "conmux")) { dev->cdb_serial = strdup(value);