mirror of
https://git.planet-casio.com/Lephenixnoir/fxsdk.git
synced 2024-12-28 04:23:37 +01:00
gdb: interpret client disconnect as W00 (normal exit)
This commit is contained in:
parent
5acef051f1
commit
8b09299c3a
1 changed files with 18 additions and 0 deletions
|
@ -191,6 +191,7 @@ int main(int argc, char **argv)
|
||||||
libusb_context *context = NULL;
|
libusb_context *context = NULL;
|
||||||
struct fxlink_device *fdev = NULL;
|
struct fxlink_device *fdev = NULL;
|
||||||
struct fxlink_pollfds fxlink_polled_fds = { 0 };
|
struct fxlink_pollfds fxlink_polled_fds = { 0 };
|
||||||
|
struct fxlink_device_list device_list = { 0 };
|
||||||
char socket_path[256] = { 0 };
|
char socket_path[256] = { 0 };
|
||||||
pid_t gdb_pid = -1;
|
pid_t gdb_pid = -1;
|
||||||
int ret = 1;
|
int ret = 1;
|
||||||
|
@ -238,6 +239,9 @@ int main(int argc, char **argv)
|
||||||
};
|
};
|
||||||
fxlink_pollfds_track(&fxlink_polled_fds, context);
|
fxlink_pollfds_track(&fxlink_polled_fds, context);
|
||||||
|
|
||||||
|
/* Track devices to find out when our device is removed */
|
||||||
|
fxlink_device_list_track(&device_list, context);
|
||||||
|
|
||||||
while(!interrupted_flag && !gdb_terminated_flag) {
|
while(!interrupted_flag && !gdb_terminated_flag) {
|
||||||
int err = fxlink_multipoll(-1,
|
int err = fxlink_multipoll(-1,
|
||||||
fxlink_polled_fds.fds, fxlink_polled_fds.count,
|
fxlink_polled_fds.fds, fxlink_polled_fds.count,
|
||||||
|
@ -251,6 +255,18 @@ int main(int argc, char **argv)
|
||||||
struct timeval zero = {0};
|
struct timeval zero = {0};
|
||||||
libusb_handle_events_timeout(context, &zero);
|
libusb_handle_events_timeout(context, &zero);
|
||||||
|
|
||||||
|
/* Check if our device is still in the list */
|
||||||
|
fxlink_device_list_refresh(&device_list);
|
||||||
|
bool still_there = false;
|
||||||
|
for(int i = 0; i < device_list.count; i++)
|
||||||
|
still_there = still_there || device_list.devices[i].dp == fdev->dp;
|
||||||
|
if(!still_there) {
|
||||||
|
hlog("gdb");
|
||||||
|
log_("device disconnected\n");
|
||||||
|
send(client_socket, "$W00#b7", 7, 0);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
struct fxlink_message *msg;
|
struct fxlink_message *msg;
|
||||||
while((msg = fxlink_device_finish_bulk_IN(fdev)) != NULL) {
|
while((msg = fxlink_device_finish_bulk_IN(fdev)) != NULL) {
|
||||||
if(!fxlink_message_is_apptype(msg, "gdb", "remote")) {
|
if(!fxlink_message_is_apptype(msg, "gdb", "remote")) {
|
||||||
|
@ -304,6 +320,8 @@ end:
|
||||||
waitpid(gdb_pid, NULL, 0);
|
waitpid(gdb_pid, NULL, 0);
|
||||||
if(socket_path[0])
|
if(socket_path[0])
|
||||||
unlink(socket_path);
|
unlink(socket_path);
|
||||||
|
if(device_list.ctx)
|
||||||
|
fxlink_device_list_stop(&device_list);
|
||||||
if(fxlink_polled_fds.ctx)
|
if(fxlink_polled_fds.ctx)
|
||||||
fxlink_pollfds_stop(&fxlink_polled_fds);
|
fxlink_pollfds_stop(&fxlink_polled_fds);
|
||||||
if(fdev) {
|
if(fdev) {
|
||||||
|
|
Loading…
Reference in a new issue