1
0
mirror of git://projects.qi-hardware.com/iris.git synced 2025-04-21 12:27:27 +03:00

bug hunting

This commit is contained in:
Bas Wijnen
2009-12-26 14:17:06 +01:00
parent ad2f531ab0
commit d97f1a4ff2
23 changed files with 334 additions and 83 deletions

View File

@@ -27,4 +27,7 @@ PYPP = /usr/bin/pypp
%.cc: %.ccp
$(PYPP) --name $< < $< > $@
run:
$(top_buiddir)/usb-server
BUILT_SOURCES = usb-server.cc

View File

@@ -54,15 +54,34 @@ struct data:
VR_FLUSH_CACHES = 3
VR_PROGRAM_START1 = 4
VR_PROGRAM_START2 = 5
POLL = 10
void request (requests num, unsigned data = 0)
void send_file (unsigned address, unsigned size, char const *data)
void reboot ():
// This always fails, because the device doesn't answer. However, that means there's nothing wrong, so don't complain.
usb_control_msg (handle, USB_ENDPOINT_IN | USB_TYPE_VENDOR | USB_RECIP_DEVICE, VR_GET_CPU_INFO, 0, 0, NULL, 8, timeout)
char buffer[8]
if usb_control_msg (handle, USB_ENDPOINT_IN | USB_TYPE_VENDOR | USB_RECIP_DEVICE, VR_GET_CPU_INFO, 0, 0, buffer, 8, timeout) < 0:
std::cerr << "unable to send reboot message to device: " << usb_strerror () << std::endl
usb_release_interface (handle, 0)
usb_close (handle)
handle = NULL
void get_device (unsigned vendor, unsigned product, unsigned tries)
void poll ()
void data::poll ():
while true:
char buffer[2]
int s = usb_control_msg (handle, USB_ENDPOINT_IN | USB_TYPE_VENDOR | USB_RECIP_DEVICE, POLL, 0, 0, buffer, 8, timeout)
if s < 1 || s > 2 || buffer[0] != '#':
std::cerr << "unable to send poll message to device: " << usb_strerror () << std::endl
usb_release_interface (handle, 0)
usb_close (handle)
handle = NULL
return
if s != 1:
std::cout << buffer[1] << std::flush
else:
break
(shevek::absolute_time () + shevek::relative_time (1, 0)).schedule (sigc::mem_fun (*this, &data::poll))
struct client : public shevek::server <client, data *>::connection:
static Glib::RefPtr <client> create ():
@@ -75,6 +94,9 @@ struct client : public shevek::server <client, data *>::connection:
unsigned entry
if l ("reboot %x%", entry):
get_server ()->data ()->boot (entry)
else if l ("shutdown%"):
std::cerr << "shutting down\n"
shevek::end_loop ()
else:
out->write ("invalid command\n")
if !keep:
@@ -112,10 +134,11 @@ void data::get_device (unsigned vendor, unsigned product, unsigned tries):
continue
handle = usb_open (dev)
if usb_claim_interface (handle, 0) < 0:
std::cerr << "unable to claim interface\n"
std::cerr << "unable to claim interface: " << usb_strerror () << "\n"
usb_close (handle)
handle = NULL
continue
(shevek::absolute_time () + shevek::relative_time (1, 0)).schedule (sigc::mem_fun (*this, &data::poll))
return
if i + 1 < tries:
//std::cerr << "failed to find device, still trying...\n"