This was partly fixed by fixing a nasty bug in which ensure_size was changing the buffer pointer in a way that wasn't getting noticed by the receive message functions. Downloads of file lists still don't work, because for some reason USB can't read the whole response from the camera. Still not sure whether this is a USB bug or my bug. Still investigating.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
This was partly fixed by fixing a nasty bug in which ensure_size was changing the buffer pointer in a way that wasn't getting noticed by the receive message functions. Downloads of file lists still don't work, because for some reason USB can't read the whole response from the camera. Still not sure whether this is a USB bug or my bug. Still investigating.