Android 4.0.3. USB Host - communication with a cam

2019-04-06 01:21发布

I am making an app that is supposed to be a remote control for a camera. In order to do this, I need it to interpret the signals I am sending via USB as if I was physically pushing the buttons. So far, no success.

I've noticed that when I plug in the cable, camera automatically switches to "file transfer mode" and acts as a mass storage device. To my knowledge cameras cannot film or make photos when connected to the camera so I'm guessing the problem is that I have to make the camera not switch to that mode - any idea how can I do this.

I've checked if maybe there are different interfaces that the device has but it can only act as a mass storage device. I am trying to send a signal via bulkTransfer.

I know that sending commands such as record etc. is possible when connected to a computer, e.g. using a C program under linux - it only needs a simple write() command with first choosing the right descriptor e.g. fd=open ( ” / dev / ttyUSB0 ” , O_RDWR).

Does anyone know how can I get similar functionality with Android?

1条回答
对你真心纯属浪费
2楼-- · 2019-04-06 01:30

It feels stupid to answer my own question, but I did find a way to solve my problem. When it comes to the mass storage functionality - it was actually an option to choose in the setup menu of the camera I am working with (I don't know how it is with other cameras). When this got solved, I still had a problem with the bulkTransfer() - I knew I had to send 2-character signal via bulkTransfer(), but when I sent it the camera did not respond. As it turned out, I had to send it in separate transfer each. So it was in fact two one-character bulk transfers. I don't know why it made a difference, but it did and now I am able to control all the menu of my camera via USB.

查看更多
登录 后发表回答