I’m starting new series of articles describing exciting field of digital camera control. In modern cameras, USB port can be used not only for transferring images to a PC, but also for sending control commands to the camera. It is often possible to send commands which “press” the shutter button, modify shutter and aperture values, some cameras are even capable of doing focus control. At the same time, new shooting techniques, such as HDR and stacked focus, require that a photographer makes several shots, slightly modifying one or several shooting parameters from shot to shot. Even age-old time lapse technique could use some automation. Since camera manufacturers are, as always slow to implement there cool features, Arduino comes to the rescue.

I am announcing new code developed for Arduino USB Host shield which implements digital camera control functions via PTP. Alex Glushchenko, a developer from my native Russia, recently joined camera control project and code shown here and in the future articles is mainly his. He did most of reverse engineering and code development and my contributions to this project were mainly code testing, camera borrowing, and blogging. Code is hosted on github separately from USB Host library. Be warned – this source is preliminary and will be changed many times before it becomes stable! It is also expected to grow quite a bit – different cameras use different commands and developing universal code supporting all manufacturers (or even every camera from one manufacturer) is not possible due to the modest resources of Arduino platform. Therefore, several libraries have been developed, each covering specific set of cameras. The cameras supporting functions of a certain library are listed in library’s header file. The list of cameras is currently quite small but I’m hoping to get more cameras supported in the future.

Digital camera as USB peripheral is much more complex and less standard than a keyboard. The complexity starts at the very first level – device configuration. Very often , several different configurations are supported on a device and the default configuration is not the one we need. Therefore, the first step would naturally be learning how to recognize configuration which supports camera control commands.

There are 3 specifications describing USB digital camera works. Still Image Device specifies USB requests, descriptors and endpoints. The protocol structure is described in Media Transfer Protocol (MTP), which is better known by its previous name, “Picture Transfer Protocol” (PTP). The most interesting document, which actually lists commands supported by camera class, is known as “PIMA 15740-2000”. It is available for a fee from I3A, however, second-hand pdf copy can be obtained for free after some googling. Camera manufacturers implement their own functions, expanding PIMA definitions. In addition to that, some older cameras use their proprietary protocols instead of PTP; support for such cameras will be added eventually.

USB specification defines a class called “Still Image Capture Device”. According to it, such device has ’06’ in “Class” field of interface descriptor of the configuration. Therefore, one way to find necessary configuration is to look at configuration descriptor contents. Let’s take a look at the device descriptor (in case you are curious, it’s an iPhone). When we look at the last line, the number of configurations is 4. Older cameras may have 2 configurations and the first one is often a disk drive – this arrangement was made in pre-PTP times so you could offload pictures to a PC even if you didn’t have a driver for the camera installed. Modern cameras rely on PTP to transfer files to PC and often come with just one configuration – so far, all cameras used so to check the PTP code for the shield were of this variety.

A sketch which prints device descriptor was posted several articles back, make yourself a copy of it if you haven’t already. A sketch printing configuration descriptor was also posted not long ago; however, it was written to output only first configuration of the device – don’t use it. Instead, download this multiple configuration capable sketch from examples section of USB_Host_Shield repo. The following table shows all four configurations of the iPhone:

The key here is Class field in interface descriptor – we know that still image capture device is identified by class 6. As we can see, configurations 0, 2 and 3 have potential. However, after much testing I found that none of these configurations support camera control commands. Here is another example of “Class 6 device” configuration, taken from Canon XSi camera – :

Number 6 in interface Class field doesn’t guarantee functionality but at least this configuration can then be activated and checked with PTP queries. It’s worth mentioning that in some cameras different configurations can be activated via camera menu and very often configuration which has “PTP” in it’s name is not the one we need. For example, Canon 5D has “PC Connection” configuration containing FF in interface class field and “PTP/Print” one with class 06. Even though both configurations talk PTP, PC Connection configuration is the one that supports remote control. This strangeness can be explained by the fact that Canon had proprietary camera control long before PTP and their first PTP implementation was written in order to be able to interact with third-party picture printers.

Let’s talk briefly about PTP protocol. A unit of information exchange in PTP protocol is called a transaction. Camera commands, requests and responses travel inside transactions. In turn, transactions are exchanged within sessions – to send something to the camera, a session would have to be opened first (one exception being “Get Device Info” request, more about it later). Many times several responses are given to a single request, the first one meaning camera understood the request, the second one generated when requested command has been executed, and then another one reflecting camera changes resulted in command execution, like image file apperared after a picture has been taken. Some types of responses have specific meaning and are called events. In order to make a shot, program needs to open a session to the camera, set PC connection mode, send shutter release command, wait for “Shutter released” event, then wait until a new file appears on the memory card (another event) and only after that consider the job done and close the session. Data flow of other commands is similar; to change aperture we need to send aperture value and wait for “aperture changed” event. Skipping commands or requests for new events in the sequence usually causes camera to hang – it would execute a command or two and then become unresponsive and would have to be power cycled. Hanging of the camera is harmless and shall be anticipated during development.

Another piece of PTP device is properties. In digital camera, most properties contain shooting parameters. Typical example of a property is shutter speed value – this property can be changed. Another property is battery level. We won’t be able to change it directly but can request it’s value. There are also properties which both change by itself and can be changed externally; one good example is camera’s real-time clock.

Lastly, there are objects contained in storages. For cameras, this is mainly files on memory card and their significance in Arduino-based applications is minor.

It’s now time to start controlling our cameras. The very first piece of software is a sketch that queries PTP device and prints out it’s capabilities. It uses GetDeviceInfo command (or operation) to output device capabilities. GetDeviceInfo is the only PTP operation which can be sent to the device without opening a session first. You will need al 3 files from this directory as well as files from ptp directory copied into %arduino%/hardware/libraries/ptp directory. This sketch is not camera-specific – it shall work with any class 6 device (as well as some proprietary ones, see note about Canon 5D above). Regretfully, this sketch won’t fit into 16K Arduinos – parser strings eat too much memory and more strings will be added in the future when more vendor-specific commands become known.

The output starts with hex dump of the response and device operations start at line 31. The first operation, 1001 or GetDeviceInfo, it the very operation that was used to retrieve this information. The “OpenSession” and “Close Session”, as you may have guessed, are used to open and close a session with the device, the rest are used for file manipulation – not very useful. Let’s now take a look at GetDeviceInfo of a real camera, in this case, Canon 400D:

This output lists many vendor-specific functions, some of which are used for camera control. Even though standard PTP contains many camera control commands, vendors tend to write their own, sometimes duplicating even non-camera control functions. The functions which name starts with “EOS” are Canon-specific.”Vendor defined” functions are also Canon-specific functions whose purpose is yet unknown.

GetDeviceInfo is a powerful tool to compare functionality of different cameras from the same vendor. Functions with the same number often perform identical actions. For example, the following output taken from Canon xSi camera shows the same EOS_Capture command as in 400D (910f, line 64 in 400D output, line 75 in xSi output). Indeed, shutter release code for 400D works identically on xSi.

Modern Canon EOS cameras have function set similar to the one above. However, if we look into older cameras, they give very different output. Below is GetDeviceInfo output from my old trusty Canon 5D. As you can see, it has no resemblance to xSi or 400D. In fact, it looks like Canon Powershot A640 output, which is posted just below this one.

When analyzing output posted above, we can see that this camera actually supports standard PTP “Initiate Capture” command (100E, line 87) as well as “Capture Complete” event (400D, line 118).

Here is a bonus for those who managed to get to this point – a sketch that performs shutter release on Canon EOS camera. It had been tested on 400D and xSi and will most likely work on cameras with the same 910f EOS_Capture command listed in GetDeviceInfo output. The sketch is available in the PTP examples on github, and copied below for your viewing pleasure:[EDIT] This code doesn’t work with current PTP/EOS library. The correct code is here

As you can see, the sketch is quite short for the amount of work it is doing and simple to understand thanks to Alex’s library structure design. Main functionality is presented on lines 41-51 – Open Session, Capture, Close Session. Delay is inserted to give camera time to save captured image; in real life applications it’s necessary to poll camera for “Object Created” event instead.

Due to the amount of material, writing about camera control can be challenging. Many things are much easier to the writer to present rather than explain; presentation style is also easier for the reader to digest. I’m currently working on simple camera controller design consisting of USB Host Shield, LCD display, rotary encoder plus a button or two and will be using it to present ways to use the library in various automatic shooting applications. I’m hoping to finish it in the next week or two, weather permitting, and publish the next program. Stay tuned!

Hello all, I’m using an UNO and a sparkfun shield. I am returning this “Start
Error: OSCOKIRQ failed to assert” in the serial monitor. I know this error is associated with the use of the VIN pin instead of the 5V. I tried connecting the UNO to a 9 volt and I am still returning this error. Could someone post the proper pin set up for this unit. I can see in the forum that some people have incurred this problem and solved it.
A side note, I already switched the 7 and 8 pin in the code. Thank you for any help in advance.

Had the same problem with the brand new usb2.0 hostboard on my Mega. As I was using the standard config and the board was brand new I knew had to be something simple. After some troubleshooting with a multimeter I found I hadn’t soldered the 3.3V pin well enough and it didn’t get to the board. Fixed it, problem solved, works like a train now 🙂

Awesome work, both the hw and the usb/ptp libraries! Got my usb2.0 board a week ago and started tinkering trying to control my D500 camera for a start. Controlling aperture, mode, shutter etc all fine 🙂 but struggling with bulb mode, like some others above. Eos.StartBulb() works fine, camera starts taking image in bulb mode. But Eos.StopBulb is just ignored, nothing happens. After this the camera usb interface just hangs, getting errors on getevent etc. Any ideas? How to troubleshoot this?

Following on from prev post – I also got the MoveFocus to work on my D500, as others mentioned I have to turn on Liveview manually. Works with focus switch in Manual or Auto which is good as I normally need Manual. At the smallest step 0x0001 (decreasing focus distance) or 0x8001 (increasing focus distance) on my EFS17-55mm lens it takes about 95 steps from 0.35m to 3m that’s just perfect. I am making timelapses, and this is going to be awesome. Totally awesome. Thanks to Oleg/Alex for the hard work behind the scenes. Now I just need to get Bulb to work and read out the exposure value in some way. This is going to be more difficult.

Bulb functionality may or may not be available via PTP on EOS cameras such as EOS400D for example. You should check this by running EOSEventLab.pde sketch first and checking shutter speed values. Bulb is 0x0C. All device properties such as shutter speed and aperture are available from EOS cameras as events. When the camera is initialized and events are enabled the first event you receive is a huge bunch of current device property values and their acceptable values or value ranges (you should see EOSCamController sketch for more details). Then you have to monitor device property value changes polling events from the camera. That’s how it works in EOSCamController sketch.

I can set bulb via Eos.SetProperty(EOS_DPC_Shutterspeed,0x0c) allright (in manual mode, lcd display changes to “BULB”) and Eos.StartBulb() starts bulb mode capture, but then I can’t stop it with Eos.StopBulb(). I have not been successfull with EOSEventlab, it hangs the camera after the first big packet (USB Fatal Error). Generally I don’t have any/much success with Eos.Eventcheck. This blog/documentation suggest lots events should be generated after image capture but none in my case (but an image IS taken). I guess it’s just a learning curve 🙂

Unfortunately, I don’t have the same camera at hands to find out what is wrong. There might be either a bug in the code or your camera behaves differently then other Canon models I tried the code on. If you could install Snoopy Pro sniffer and make a dump of USB session during bulb capture with Canon or some other software, properly working with your camera, and send it to me, I would probably find what the problem is and fix the code.

Ok, I made a lot of progress with my D500 – this is all pretty awesome. I added an EOS.EventCheck(NULL) in the startup initialisation (e.g., eventmonitor example) that skipped the first big packet. But it still bombed on changing the mode dial… Later I changed to your eventparser function, which seems more robust, it never bombs. Cool because this gives me access to the settings (I am not great with C++ so would not be able to write this myself). Then in order to get bulb and half-push-release-button to work I had to resort to SnoopyPro usb sniffer to figure what packets the EOS Utility programme sends to the camera for these functions. Since I am a newbie to USB it tok me some time to figure it all out. It’s the out.down packets that need to be studied. From there it was easy, now it works like a train (tested). The code that works for a D500 is below, it’s generates an exact copy of what EOS utility sends to the camera. In canoneos.cpp:

You will also need to add uint16_t HalfPush() to the CanonEOS class in canoneos.h HalfPush generates an event with the desired aperture (in T mode) or shutterspeed (in A mode). The delay will make the values appear on the LCD of the camera, if you leave it out you get the same response but won’t see the values on the camera’s LCD.

I hope this is useful to someone. This all very great stuff. Now I will move to getting my Canon G6 to work as well 🙂

When you change mode dial you’ll get the same large packet again since all property values change (like in Av you don’t have property value for shutter speed). Good find about Event Parser and Bulb settings, I need to check it on my cameras. Let me know if you have any issues with G6.

Hi … were you able to get the Bulb mode running accuratly with bulb duration in the range of ~100ms. I noticed bulb start and stop events timing is not accurate and sometimes it jumps and even misses events. Would be interesting what experience you had on that bulb mode topic?

Hi oleg – sorry for naive questions but i wanted to get your insight:
I am trying to do the following:
Move the focus to a starting position
Shoot
Wait for thr shoot to complete (can be worked out by the tv set)
Move thr focus one step up
Repeat from shoot until a set focus position
Wait a set time and repeat fro. Step 1

I know about the missing ack after the focus move, but i am looking for how i would code this (sry complete new) i use a 5d mk ii

1) Anyone have any luck trying to set the ShootingMode property? My 60D always reports back as busy. I am guessing that it’s not possible since the EOSUtility application won’t even allow changing of the mode dial. Do I really have to manually rotate the dial to go between auto and manual?

2) I can’t seem to get anything back from operation code EOS_OC_GetDevicePropValue on my 60D. Anyone else note this?

3) When using EOS_OC_GetDeviceInfoEx and PTP_OC_GetDeviceInfo I get two completely different sets of data. The PTP_OC_GetDeviceInfo operation code returns something similar to what you have here ( https://www.circuitsathome.com/?s=60d#EOS60D ) but your canoneos.cpp sends the EOS_OC_GetDeviceInfoEx which returns data nothing like what you report on the page noted above. Can you explain the difference?

1) You can set shooting mode on your 60D only by turning mode dial manually.
2) The only correct way of getting device property value is to obtain it from the first event packet and monitor its changes later checking events. There is a class EOSEventParser in the second version of PTP library written to handle different events, especially events dealing with device properties. Check latest version of EOSRemote sketch to get the idea of how you can use it. If you have questions feel free to ask me.
3) EOS_OC_GetDeviceInfoEx is the Canon proprietary method of getting device information. It works only for Canon EOS cameras. PTP_OC_GetDeviceInfo is PTP-standard method supported by absolutely every PTP capable camera. I suggest you to use EOS_OC_GetDeviceInfoEx only when it’s absolutely necessary for your application.

Is there any exposure metering data contained in events? I am trying to accomplish both manual and automatic exposure control with the EOS series. If I left the dial in manual shooting mode AND I could obtain some exposure metering data then I could intelligently set the exposure settings (f-stop, shutter, iso) in manual mode. Definitely not as good as having control over the shooting mode but a very good workaround for my purposes. Any thoughts?

It could be true for some newer models. Old EOS cameras, such as EOS 400D, don’t send any exposure metering data in events. I am not sure about 60D because I had no chance to test it with the PTP code. the workaround could be keeping EOS in manual mode while measuring exposure with some extra circuit connected to Arduino and then set the exposure settings programmatically.

I assume these device property values would be in the canoneos.h file if they were known but I thought I’d ask anyway as they may just not be present because they aren’t commonly used. Any idea what 0xD1D3 and 0xD1C0 represent? They are both device properties changed events (0xC189). They seem to be common after a half push or release event.

0xD1D3 seems to represent focus info. About 0xD1C0 I have no idea. I will probably be able to make some assumptions if you send me a dump taken by EOSEventLab or EOSEventMonitor with a short description of what had initiated the event.

I am currently basing a project of mine with this project as a skeleton.
When the camera takes a picture acre you able to direct where the photo goes? Like can you command it to save into a specific folder?
I’m sorry if my question sounds stupid but i am trying to create an interface to be able to view, sort,delete and etc. the photos.

hi oleg
I have read source code of arduino camera control on https://github.com/felis/Arduino_Camera_Control , I cannot find the source code of 3 focus move speed, where is it?
For example:
felis-Arduino_Camera_Control-4f5b1bf\examples\EOSFocus\EOSFocus.pde
row 71 to 81
if (i > 4)
Eos.MoveFocus(3); //question: what is the meaning of number 3?
else
Eos.MoveFocus(0x8003); //question: what is the meaning of 0x8003?

probably you can help me with my problem. I am playing around with arduino controlling my 7D. Communication from Arduino to 7D works great – but in the other direction 7D -> Arduino I have a lot of problems.
How can I read for example the current Shutterspeed?

Why? Most simple compact cameras don’t allow live shooting – seeing the image in real time on the PC. Now that the Philips SPC900 webcam is more or less unobtainable, there is a gap in the market of CCD based webcams,for use in astroimaging. But some compact cameras do use CCD imaging chips, so if these cameras could be controlled to send the real time image to a PC it’s a whole new board game.

I’m getting errors when compiling PTPDevInfo. I get similar errors when trying other examples too.

In file included from devinfoparser.cpp:1:
devinfoparser.h:237: error: expected class-name before ‘{‘ token
devinfoparser.cpp: In member function ‘bool DevInfoParser::PrintFunctMode(uint8_t**, uint16_t&)’:
devinfoparser.cpp:194: error: ‘Notify’ was not declared in this scope
devinfoparser.cpp:194: error: ‘Serial’ was not declared in this scope
devinfoparser.cpp:194: error: ‘HEX’ was not declared in this scope
devinfoparser.cpp: In member function ‘void DevInfoParser::PrintOperation(uint16_t)’:
devinfoparser.cpp:202: error: ‘Serial’ was not declared in this scope
devinfoparser.cpp:202: error: ‘HEX’ was not declared in this scope
devinfoparser.cpp:203: error: ‘Notify’ was not declared in this scope
devinfoparser.cpp:216: error: ‘PTP_VENDOR_MICROSOFT’ was not declared in this scope
devinfoparser.cpp:217: error: ‘PTP_VENDOR_CANON’ was not declared in this scope
devinfoparser.cpp: In member function ‘bool DevInfoParser::PrintPTPOperation(uint16_t)’:
devinfoparser.cpp:234: error: ‘PTP_OC_InitiateOpenCapture’ was not declared in this scope
devinfoparser.cpp:236: error: ‘Notify’ was not declared in this scope
devinfoparser.cpp: In member function ‘bool DevInfoParser::PrintMTPOperation(uint16_t)’:
devinfoparser.cpp:244: error: ‘MTP_OC_SendObjectPropList’ was not declared in this scope
devinfoparser.cpp:245: error: ‘Notify’ was not declared in this scope
devinfoparser.cpp:250: error: ‘MTP_OC_GetObjectReferences’ was not declared in this scope
devinfoparser.cpp:251: error: ‘Notify’ was not declared in this scope
devinfoparser.cpp:253: error: ‘MTP_OC_SetObjectReferences’ was not declared in this scope
devinfoparser.cpp:256: error: ‘MTP_OC_Skip’ was not declared in this scope
devinfoparser.cpp: In member function ‘bool DevInfoParser::PrintPSOperation(uint16_t)’:
devinfoparser.cpp:317: error: ‘Notify’ was not declared in this scope
devinfoparser.cpp: In member function ‘bool DevInfoParser::PrintEOSOperation(uint16_t)’:
devinfoparser.cpp:365: error: ‘Notify’ was not declared in this scope
devinfoparser.cpp: In member function ‘void DevInfoParser::PrintEvent(uint16_t)’:
devinfoparser.cpp:371: error: ‘Serial’ was not declared in this scope
devinfoparser.cpp:371: error: ‘HEX’ was not declared in this scope
devinfoparser.cpp:372: error: ‘Notify’ was not declared in this scope
devinfoparser.cpp:374: error: ‘PTP_EC_UnreportedStatus’ was not declared in this scope
devinfoparser.cpp:377: error: ‘MTP_EC_ObjectReferencesChanged’ was not declared in this scope
devinfoparser.cpp: In member function ‘void DevInfoParser::PrintDevProp(uint16_t)’:
devinfoparser.cpp:386: error: ‘Serial’ was not declared in this scope
devinfoparser.cpp:386: error: ‘HEX’ was not declared in this scope
devinfoparser.cpp:387: error: ‘Notify’ was not declared in this scope
devinfoparser.cpp:389: error: ‘PTP_DPC_CopyrightInfo’ was not declared in this scope
devinfoparser.cpp:394: error: ‘MTP_DPC_Perceived_Device_Type’ was not declared in this scope
devinfoparser.cpp:400: error: ‘MTP_DPC_Playback_Rate’ was not declared in this scope
devinfoparser.cpp:403: error: ‘MTP_DPC_Playback_Object’ was not declared in this scope
devinfoparser.cpp:406: error: ‘MTP_DPC_Playback_Container’ was not declared in this scope
devinfoparser.cpp: In member function ‘void DevInfoParser::PrintFormat(uint16_t)’:
devinfoparser.cpp:422: error: ‘Serial’ was not declared in this scope
devinfoparser.cpp:422: error: ‘HEX’ was not declared in this scope
devinfoparser.cpp:423: error: ‘Notify’ was not declared in this scope
devinfoparser.cpp:425: error: ‘PTP_OFC_QT’ was not declared in this scope
devinfoparser.cpp:428: error: ‘PTP_OFC_JPX’ was not declared in this scope
devinfoparser.cpp:434: error: ‘MTP_OFC_Undefined_Firmware’ was not declared in this scope
devinfoparser.cpp:437: error: ‘MTP_OFC_Windows_Image_Format’ was not declared in this scope
devinfoparser.cpp:440: error: ‘MTP_OFC_Undefined_Audio’ was not declared in this scope
devinfoparser.cpp:443: error: ‘MTP_OFC_WMA’ was not declared in this scope
devinfoparser.cpp:446: error: ‘MTP_OFC_OGG’ was not declared in this scope
devinfoparser.cpp:449: error: ‘MTP_OFC_AAC’ was not declared in this scope
devinfoparser.cpp:452: error: ‘MTP_OFC_Audible’ was not declared in this scope
devinfoparser.cpp:455: error: ‘MTP_OFC_FLAC’ was not declared in this scope
devinfoparser.cpp:458: error: ‘MTP_OFC_Undefined_Video’ was not declared in this scope
devinfoparser.cpp:461: error: ‘MTP_OFC_WMV’ was not declared in this scope
devinfoparser.cpp:464: error: ‘MTP_OFC_MP4_Container’ was not declared in this scope
devinfoparser.cpp:467: error: ‘MTP_OFC_MP2’ was not declared in this scope
devinfoparser.cpp:470: error: ‘MTP_OFC_3GP_Container’ was not declared in this scope
devinfoparser.cpp: In member function ‘bool DevInfoParser::PrintVendor(uint8_t**, uint16_t&)’:
devinfoparser.cpp:482: error: ‘Notify’ was not declared in this scope
devinfoparser.cpp:483: error: ‘Serial’ was not declared in this scope
devinfoparser.cpp:483: error: ‘HEX’ was not declared in this scope
devinfoparser.cpp:487: error: ‘PTP_VENDOR_EASTMAN_KODAK’ was not declared in this scope
devinfoparser.cpp:490: error: ‘PTP_VENDOR_SEIKO_EPSON’ was not declared in this scope
devinfoparser.cpp:493: error: ‘PTP_VENDOR_AGILENT’ was not declared in this scope
devinfoparser.cpp:496: error: ‘PTP_VENDOR_POLAROID’ was not declared in this scope
devinfoparser.cpp:499: error: ‘PTP_VENDOR_AGFA_GEVAERT’ was not declared in this scope
devinfoparser.cpp:502: error: ‘PTP_VENDOR_MICROSOFT’ was not declared in this scope
devinfoparser.cpp:505: error: ‘PTP_VENDOR_EQUINOX’ was not declared in this scope
devinfoparser.cpp:508: error: ‘PTP_VENDOR_VIEWQUEST’ was not declared in this scope
devinfoparser.cpp:511: error: ‘PTP_VENDOR_STMICROELECTRONICS’ was not declared in this scope
devinfoparser.cpp:514: error: ‘PTP_VENDOR_NIKON’ was not declared in this scope
devinfoparser.cpp:517: error: ‘PTP_VENDOR_CANON’ was not declared in this scope
devinfoparser.cpp:520: error: ‘PTP_VENDOR_FOTONATION’ was not declared in this scope
devinfoparser.cpp:523: error: ‘PTP_VENDOR_PENTAX’ was not declared in this scope
devinfoparser.cpp:526: error: ‘PTP_VENDOR_FUJI’ was not declared in this scope
devinfoparser.cpp: In member function ‘bool DevInfoParser::PrintString(uint8_t**, uint16_t&)’:
devinfoparser.cpp:558: error: ‘Serial’ was not declared in this scope
devinfoparser.cpp: At global scope:
devinfoparser.cpp:563: error: ‘NULL’ was not declared in this scope
devinfoparser.cpp: In member function ‘bool DevInfoParser::PrintWordArray(uint8_t**, uint16_t&, void (DevInfoParser::*)(uint16_t))’:
devinfoparser.cpp:590: error: ‘Serial’ was not declared in this scope
devinfoparser.cpp:590: error: ‘HEX’ was not declared in this scope
devinfoparser.cpp: In member function ‘virtual void DevInfoParser::Parse(uint16_t, const uint8_t*, const uint32_t&)’:
devinfoparser.cpp:614: error: ‘Notify’ was not declared in this scope
devinfoparser.cpp:614: error: ‘Serial’ was not declared in this scope
devinfoparser.cpp:614: error: ‘DEC’ was not declared in this scope
devinfoparser.cpp:620: error: ‘HEX’ was not declared in this scope

Hi
1. Thanks for this work! I tryed similar functions with ftdi usb host but i was not successfull! 🙁
2. Sorry for my bad english
3. Have i a question: Is there any code-snippet who shows me how to read an image from the camera to the arduino? Is this a complex code?
The background of my question: I try to build a wireless webcam with a canon DSLR. The data were transmitted over GPRS to a webserver.

The image can be read using GetObject() method. PTPReadParser *parser is a callback which gets called upon receiving each data packet. You need to skip PTP header ( first 12 bytes ), the rest is your image.

Now i recived my USB-Shield v2.0 and i made a first test with the example program PTPDevInfo.
I use Arduino 0022 and have copied the usb and ptp lib from git to my arduino0022/libraries folder. I must rename the lib because of the special caracter in the filename. I opened the PTPDevInfo Sktech via file->Examples an Build it. It give me some errors:

In file included from C:\Users\Peter\Documents\Arduino\arduino22\arduino22\libraries\USB\SPP.cpp:18:
C:\Users\Peter\Documents\Arduino\arduino22\arduino22\libraries\USB\/SPP.h:109: error: expected ‘,’ or ‘…’ before ‘*’ token
C:\Users\Peter\Documents\Arduino\arduino22\arduino22\libraries\USB\/SPP.h:109: error: ISO C++ forbids declaration of ‘__FlashStringHelper’ with no type
C:\Users\Peter\Documents\Arduino\arduino22\arduino22\libraries\USB\/SPP.h:115: error: expected ‘,’ or ‘…’ before ‘*’ token
C:\Users\Peter\Documents\Arduino\arduino22\arduino22\libraries\USB\/SPP.h:115: error: ISO C++ forbids declaration of ‘__FlashStringHelper’ with no type
C:\Users\Peter\Documents\Arduino\arduino22\arduino22\libraries\USB\SPP.cpp:719: error: expected ‘,’ or ‘…’ before ‘*’ token
C:\Users\Peter\Documents\Arduino\arduino22\arduino22\libraries\USB\SPP.cpp:719: error: ISO C++ forbids declaration of ‘__FlashStringHelper’ with no type
C:\Users\Peter\Documents\Arduino\arduino22\arduino22\libraries\USB\SPP.cpp: In member function ‘void SPP::print(int)’:
C:\Users\Peter\Documents\Arduino\arduino22\arduino22\libraries\USB\SPP.cpp:720: error: ‘ifsh’ was not declared in this scope
C:\Users\Peter\Documents\Arduino\arduino22\arduino22\libraries\USB\SPP.cpp: At global scope:
C:\Users\Peter\Documents\Arduino\arduino22\arduino22\libraries\USB\SPP.cpp:756: error: expected ‘,’ or ‘…’ before ‘*’ token
C:\Users\Peter\Documents\Arduino\arduino22\arduino22\libraries\USB\SPP.cpp:756: error: ISO C++ forbids declaration of ‘__FlashStringHelper’ with no type
C:\Users\Peter\Documents\Arduino\arduino22\arduino22\libraries\USB\SPP.cpp: In member function ‘void SPP::println(int)’:
C:\Users\Peter\Documents\Arduino\arduino22\arduino22\libraries\USB\SPP.cpp:757: error: ‘ifsh’ was not declared in this scope

I’m new with the arduino but have some experience with avr and arm cortex m3, programming with avr studio and keil. I don’t like the arduino IDE until this moment 😉

When i try to compile the program i get the following errors
I have tried almost all examples but all give problems.
Can you tell me what i do wrong?

In file included from EOSEventLab.cpp:19:
/Users/user/Documents/Arduino/libraries/PTP/canoneos.h:77: error: expected class-name before ‘{‘ token
/Users/user/Documents/Arduino/libraries/PTP/canoneos.h:79: error: ‘PTP’ has not been declared
/Users/user/Documents/Arduino/libraries/PTP/canoneos.h:83: error: expected class-name before ‘{‘ token
/Users/user/Documents/Arduino/libraries/PTP/canoneos.h:94: error: expected class-name before ‘{‘ token
/Users/user/Documents/Arduino/libraries/PTP/canoneos.h:130: error: ‘PTPStateHandlers’ has not been declared
/Users/user/Documents/Arduino/libraries/PTP/canoneos.h:143: error: ‘PTPReadParser’ has not been declared
/Users/user/Documents/Arduino/libraries/PTP/canoneos.h:145: error: ‘PTPReadParser’ has not been declared
/Users/user/Documents/Arduino/libraries/PTP/canoneos.h:148: error: ‘PTPReadParser’ has not been declared
/Users/user/Documents/Arduino/libraries/PTP/canoneos.h:152: error: ‘PTPReadParser’ has not been declared
In file included from /Users/user/Documents/Arduino/libraries/PTP/eoseventdump.h:22,
from EOSEventLab.cpp:20:
/Users/user/Documents/Arduino/libraries/PTP/ptpcallback.h:38: error: expected initializer before ‘<' token
In file included from EOSEventLab.cpp:20:
/Users/user/Documents/Arduino/libraries/PTP/eoseventdump.h:38: error: 'MultiByteValueParser' does not name a type
/Users/user/Documents/Arduino/libraries/PTP/eoseventdump.h:39: error: 'MultiValueBuffer' does not name a type
/Users/user/Documents/Arduino/libraries/PTP/eoseventdump.h: In constructor 'EOSEventDump::EOSEventDump()':
/Users/user/Documents/Arduino/libraries/PTP/eoseventdump.h:43: error: 'valueBuffer' was not declared in this scope
/Users/user/Documents/Arduino/libraries/PTP/eoseventdump.h: In member function 'void EOSEventDump::Initialize()':
/Users/user/Documents/Arduino/libraries/PTP/eoseventdump.h:44: error: 'valueParser' was not declared in this scope
/Users/user/Documents/Arduino/libraries/PTP/eoseventdump.h:44: error: 'valueBuffer' was not declared in this scope
EOSEventLab.cpp: At global scope:
EOSEventLab.pde:-1: error: 'PTP' has not been declared
EOSEventLab.pde:-1: error: 'PTP' has not been declared
EOSEventLab.pde:-1: error: 'PTPStateHandlers' has not been declared
EOSEventLab.cpp: In member function 'virtual uint8_t CanonEos::Poll()':
EOSEventLab.pde:-1: error: 'PTP' has not been declared
EOSEventLab.pde:-1: error: no matching function for call to 'CanonEos::EventCheck(EOSEventDump*)'
/Users/user/Documents/Arduino/libraries/PTP/canoneos.h:152: note: candidates are: virtual uint16_t CanonEOS::EventCheck(int*)
EOSEventLab.cpp: At global scope:
EOSEventLab.pde:-1: error: 'USBHub' does not name a type
EOSEventLab.pde:-1: error: no matching function for call to 'CanonEos::CanonEos(USB*, CamStateHandlers*)'
EOSEventLab.cpp:44: note: candidates are: CanonEos::CanonEos(USB*, int*)
EOSEventLab.cpp:38: note: CanonEos::CanonEos(const CanonEos&)
EOSEventLab.pde:-1: error: variable or field 'OnDeviceDisconnectedState' declared void
EOSEventLab.pde:-1: error: 'PTP' was not declared in this scope
EOSEventLab.pde:-1: error: 'ptp' was not declared in this scope

I am currently in the design phase of a project where data is taken from the human eye and read into a computer. These outputs are then to be analyzed and sent to a camera to adjust the ISO (exposure) setting. As well as change the focal points based on iris tracking. Everything up to giving commands to a camera has worked very well. We had assumed that telling a camera to change ISO to 400 and move the focal point 3 mm left would be easy… learning now not so much.

With your knowledge I am wondering if it is possible to use what methods you have shown here to send these commands to a camera (digital, canon).

Which Canon? Most (relatively) modern EOS and some Powershots support what you need controlling. In the ‘examples’ directory there are examples, called EOSRemote and PSRemote, which demonstrate changing ISO, among other things. I remember seeing a property for focus point but I can’t find it at the moment – try asking on gphoto mailing list or find it yourself.

I´m trying to compile the given exmples of the ptp2 lib but with no success. I´ve got an Arduino Duemilanove and an Tinyos USB shield. After finding (hopefully) all relevant libs, I got follwoing errors. Would be great if someone could give me a hint! Thanks a lot for your great work! Compiling the “EOSFocus” sketch gives me this for example:
In file included from C:\Users\SpeedLine Rocket\Desktop\arduino-1.0.1\libraries\ptp2\/ptpdebug.h:24,
from C:\Users\SpeedLine Rocket\Desktop\arduino-1.0.1\libraries\ptp2\ptpcallback.cpp:18:
C:\Users\SpeedLine Rocket\Desktop\arduino-1.0.1\libraries\ptp2\/../USBHost/message.h: In function ‘void ErrorMessage(const char*, ERROR_TYPE)’:
C:\Users\SpeedLine Rocket\Desktop\arduino-1.0.1\libraries\ptp2\/../USBHost/message.h:31: warning: only initialized variables can be placed into program memory area
C:\Users\SpeedLine Rocket\Desktop\arduino-1.0.1\libraries\ptp2\/../USBHost/message.h:33: warning: only initialized variables can be placed into program memory area
C:\Users\SpeedLine Rocket\Desktop\arduino-1.0.1\libraries\ptp2\ptpcallback.cpp: At global scope:
C:\Users\SpeedLine Rocket\Desktop\arduino-1.0.1\libraries\ptp2\ptpcallback.cpp:20: error: ‘MultiByteValueParser’ has not been declared
C:\Users\SpeedLine Rocket\Desktop\arduino-1.0.1\libraries\ptp2\ptpcallback.cpp: In function ‘bool Parse(uint8_t**, uint16_t*)’:
C:\Users\SpeedLine Rocket\Desktop\arduino-1.0.1\libraries\ptp2\ptpcallback.cpp:22: error: ‘pBuf’ was not declared in this scope
C:\Users\SpeedLine Rocket\Desktop\arduino-1.0.1\libraries\ptp2\ptpcallback.cpp:24: warning: only initialized variables can be placed into program memory area
C:\Users\SpeedLine Rocket\Desktop\arduino-1.0.1\libraries\ptp2\ptpcallback.cpp:27: error: ‘countDown’ was not declared in this scope
C:\Users\SpeedLine Rocket\Desktop\arduino-1.0.1\libraries\ptp2\ptpcallback.cpp:28: error: ‘pBuf’ was not declared in this scope
C:\Users\SpeedLine Rocket\Desktop\arduino-1.0.1\libraries\ptp2\ptpcallback.cpp:28: error: ‘valueSize’ was not declared in this scope
C:\Users\SpeedLine Rocket\Desktop\arduino-1.0.1\libraries\ptp2\ptpcallback.cpp:30: error: ‘countDown’ was not declared in this scope
C:\Users\SpeedLine Rocket\Desktop\arduino-1.0.1\libraries\ptp2\ptpcallback.cpp:33: error: ‘countDown’ was not declared in this scope
C:\Users\SpeedLine Rocket\Desktop\arduino-1.0.1\libraries\ptp2\ptpcallback.cpp:33: error: ‘valueSize’ was not declared in this scope
C:\Users\SpeedLine Rocket\Desktop\arduino-1.0.1\libraries\ptp2\ptpcallback.cpp: At global scope:
C:\Users\SpeedLine Rocket\Desktop\arduino-1.0.1\libraries\ptp2\ptpcallback.cpp:37: error: ‘PTPListParser’ has not been declared
C:\Users\SpeedLine Rocket\Desktop\arduino-1.0.1\libraries\ptp2\ptpcallback.cpp:37: error: ‘PTP_ARRAY_EL_FUNC’ has not been declared
C:\Users\SpeedLine Rocket\Desktop\arduino-1.0.1\libraries\ptp2\ptpcallback.cpp: In function ‘bool Parse(uint8_t**, uint16_t*, int, const void*)’:
C:\Users\SpeedLine Rocket\Desktop\arduino-1.0.1\libraries\ptp2\ptpcallback.cpp:39: error: ‘nStage’ was not declared in this scope
C:\Users\SpeedLine Rocket\Desktop\arduino-1.0.1\libraries\ptp2\ptpcallback.cpp:42: error: ‘pBuf’ was not declared in this scope
C:\Users\SpeedLine Rocket\Desktop\arduino-1.0.1\libraries\ptp2\ptpcallback.cpp:42: error: ‘lenSize’ was not declared in this scope
C:\Users\SpeedLine Rocket\Desktop\arduino-1.0.1\libraries\ptp2\ptpcallback.cpp:43: error: ‘theParser’ was not declared in this scope
C:\Users\SpeedLine Rocket\Desktop\arduino-1.0.1\libraries\ptp2\ptpcallback.cpp:50: error: ‘arLen’ was not declared in this scope
C:\Users\SpeedLine Rocket\Desktop\arduino-1.0.1\libraries\ptp2\ptpcallback.cpp:52: error: ‘arLenCntdn’ was not declared in this scope
C:\Users\SpeedLine Rocket\Desktop\arduino-1.0.1\libraries\ptp2\ptpcallback.cpp:56: error: ‘valSize’ was not declared in this scope
C:\Users\SpeedLine Rocket\Desktop\arduino-1.0.1\libraries\ptp2\ptpcallback.cpp:67: error: ‘pf’ cannot be used as a function

Still i try to read out a image from the camera. I tryed a lot, made pictures and compared the outputs, produced usb-errors and so on…
First i don’t realy now, how to use GetObject(uint32_t object_id, uint32_t parent_id, PTPReadParser *parser). Therefor need an object_id.
The output of the PTPObjectHandles without any pic on the camera (5dMkII) is:

I know:
1. 4 Bytes are the total-lenght of the data-packet.
2. 4 Bytes
3. 4 Byets
4. 4 Bytes are the number of objects on the camera (Seams to bee 3)
5. 4 Bytes
6. 4 Bytes
7. 4 Bytes have already the same value

Also one Object (=the picture) more. Now which one is the object_id? Or is the id not visible on this output?

Second: What ist the parent_id?
Third: Confusion with the PTPReadParser. This is a pionter to a function which process the returning data?!? Can i create an function like the PTPObjHandleParser::Parse(const uint16_t len, const uint8_t *pbuf, const uint32_t &offset)? whitch contain:
len = length of the retuning datas
*pbuf = Pointer to the data
&offset = 12 (PTP-header)?

Sorry for this (dummy)-questions. I have experience with c but not really c++. I know the idea behind oop, but there are a lot of classes.
Am i on the right way?
Thanks for help

Peter

PS: I can you deliver PTP-Outputs of G1X and 1dMkIIn for compelment the supported cameralists

Image on a camera are accessed by so-called ‘handles’. You can get a handle of an image after a shot if you’re monitoring camera events or you can get a list of handles by issuing GetObjectHandles(). Then you call GetObject() with this handle as a parameter. Here is an example which extracts handles from a camera -> https://github.com/felis/PTP_2.0/tree/master/examples/ptpsketches/PTPObjectHandles. There is also a simpler example below.

Almost any command output from a camera is too big to store on Arduino, therefore it needs to be processed on the fly. A parser is called on each packet received. For example, this is the minimal parser for GetObjectHandles():

It skips first 12 bytes, then stores next 4 bytes as an index (number of objects ), then stores next 4 bytes as a handle of the first file, then skips the rest of the response.

A parser for GetObject() is trivial. You need to skip first 12 bytes, the rest is your image. Also, if you are sending your file somewhere, you can just transfer all GetObject() output and process it on the receiving end.

Hello Oleg
I heave already a little question: Is there any possibility to capture a image whitout the canoneos.h files?

The background of my question is:
I can read the objects on the camera, readout the image with the ptp-functions (PTP Ptp(&Usb, &CamStates);) But when i try the same with the canoneos-functions (CanonEOS Eos(&Usb, &CamStates);) i can’t read the image form the camerea. In the function CanonEOS::GetObject(uint32_t object_id, uint32_t parent_id, PTPReadParser *parser) is an additional parameter parent_id. I read the object info with PTPObjInfo and see the parameter “parent object”. But with this 32bit value as parent id in CanonEOS::GetObject i don’t became any response form the camera.

Or: must i adapt my h-file of the parser and include the eos.h file there

Sometime it helps to describe the problem:
I can use the ptp and eso funcions at the same time wehn i start it with: CanonEOS Eos(&Usb, &CamStates);
The read-out of the image takes several seconds to start! Maybe was my patience to little…

Hello Oleg
Thanks a million for your help!
I have transvered the first image from the camera to my pc (for the first test). I take a picture with the smallest resolution and compression. The picture is about 800kB and the transmission take over 2 min @ 115200 but it works.

Peter is there anyway you could past your code to transfer the image from the camera to the pc? You guys are much better at this coding than I am. So far I can take the images remotely but can not see what I’m taking from the PC.

I can run the code that Oleg pointed to and I do get lots of numbers on the Arduino terminal but I’m not sure if that is the picture data and if it is I dont know how to save it as a jpg file and view it on my PC.

It seems to be the image! 🙂
Can you open the orginal image with a hex-viewer? Then you compare the numbers in the therminal with the image. You should send the image with Serial.print(…,HEX), then it’s easy to compare!

hi oleg,
sorry for my late replay.
i do not think i have multiple copies of the libraries.

but here is step by step what i did:

I downloaded the
USB_Host_Shield_2.0-master.zip
and
Arduino_Camera_Control-master.zip

then i unpacked the two zips in
arduino-1.0.2\libraries

renamed the folders (made them shorter and without “.”)

i start the arduino software and choose from the examples/CameraContro/PTPDevInfo

when i try to verify a big bunch of errors occur

“””””””””””””””””””””””””””

In file included from devinfoparser.cpp:1:
devinfoparser.h:238: error: expected class-name before ‘{‘ token
devinfoparser.cpp: In member function ‘bool DevInfoParser::PrintFunctMode(uint8_t**, uint16_t&)’:
devinfoparser.cpp:195: error: ‘Notify’ was not declared in this scope
devinfoparser.cpp:195: error: ‘Serial’ was not declared in this scope
devinfoparser.cpp:195: error: ‘HEX’ was not declared in this scope
devinfoparser.cpp: In member function ‘void DevInfoParser::PrintOperation(uint16_t)’:
devinfoparser.cpp:203: error: ‘Serial’ was not declared in this scope
devinfoparser.cpp:203: error: ‘HEX’ was not declared in this scope
devinfoparser.cpp:204: error: ‘Notify’ was not declared in this scope
devinfoparser.cpp:217: error: ‘PTP_VENDOR_MICROSOFT’ was not declared in this scope
devinfoparser.cpp:218: error: ‘PTP_VENDOR_CANON’ was not declared in this scope
devinfoparser.cpp: In member function ‘bool DevInfoParser::PrintPTPOperation(uint16_t)’:
devinfoparser.cpp:235: error: ‘PTP_OC_InitiateOpenCapture’ was not declared in this scope
devinfoparser.cpp:237: error: ‘Notify’ was not declared in this scope
devinfoparser.cpp: In member function ‘bool DevInfoParser::PrintMTPOperation(uint16_t)’:
devinfoparser.cpp:245: error: ‘MTP_OC_SendObjectPropList’ was not declared in this scope
devinfoparser.cpp:246: error: ‘Notify’ was not declared in this scope
devinfoparser.cpp:251: error: ‘MTP_OC_GetObjectReferences’ was not declared in this scope
devinfoparser.cpp:252: error: ‘Notify’ was not declared in this scope
devinfoparser.cpp:254: error: ‘MTP_OC_SetObjectReferences’ was not declared in this scope
devinfoparser.cpp:257: error: ‘MTP_OC_Skip’ was not declared in this scope
devinfoparser.cpp: In member function ‘bool DevInfoParser::PrintPSOperation(uint16_t)’:
devinfoparser.cpp:318: error: ‘Notify’ was not declared in this scope
devinfoparser.cpp: In member function ‘bool DevInfoParser::PrintEOSOperation(uint16_t)’:
devinfoparser.cpp:366: error: ‘Notify’ was not declared in this scope
devinfoparser.cpp: In member function ‘void DevInfoParser::PrintEvent(uint16_t)’:
devinfoparser.cpp:372: error: ‘Serial’ was not declared in this scope
devinfoparser.cpp:372: error: ‘HEX’ was not declared in this scope
devinfoparser.cpp:373: error: ‘Notify’ was not declared in this scope
devinfoparser.cpp:375: error: ‘PTP_EC_UnreportedStatus’ was not declared in this scope
devinfoparser.cpp:378: error: ‘MTP_EC_ObjectReferencesChanged’ was not declared in this scope
devinfoparser.cpp: In member function ‘void DevInfoParser::PrintDevProp(uint16_t)’:
devinfoparser.cpp:387: error: ‘Serial’ was not declared in this scope
devinfoparser.cpp:387: error: ‘HEX’ was not declared in this scope
devinfoparser.cpp:388: error: ‘Notify’ was not declared in this scope
devinfoparser.cpp:390: error: ‘PTP_DPC_CopyrightInfo’ was not declared in this scope
devinfoparser.cpp:395: error: ‘MTP_DPC_Perceived_Device_Type’ was not declared in this scope
devinfoparser.cpp:401: error: ‘MTP_DPC_Playback_Rate’ was not declared in this scope
devinfoparser.cpp:404: error: ‘MTP_DPC_Playback_Object’ was not declared in this scope
devinfoparser.cpp:407: error: ‘MTP_DPC_Playback_Container’ was not declared in this scope
devinfoparser.cpp: In member function ‘void DevInfoParser::PrintFormat(uint16_t)’:
devinfoparser.cpp:423: error: ‘Serial’ was not declared in this scope
devinfoparser.cpp:423: error: ‘HEX’ was not declared in this scope
devinfoparser.cpp:424: error: ‘Notify’ was not declared in this scope
devinfoparser.cpp:426: error: ‘PTP_OFC_QT’ was not declared in this scope
devinfoparser.cpp:429: error: ‘PTP_OFC_JPX’ was not declared in this scope
devinfoparser.cpp:435: error: ‘MTP_OFC_Undefined_Firmware’ was not declared in this scope
devinfoparser.cpp:438: error: ‘MTP_OFC_Windows_Image_Format’ was not declared in this scope
devinfoparser.cpp:441: error: ‘MTP_OFC_Undefined_Audio’ was not declared in this scope
devinfoparser.cpp:444: error: ‘MTP_OFC_WMA’ was not declared in this scope
devinfoparser.cpp:447: error: ‘MTP_OFC_OGG’ was not declared in this scope
devinfoparser.cpp:450: error: ‘MTP_OFC_AAC’ was not declared in this scope
devinfoparser.cpp:453: error: ‘MTP_OFC_Audible’ was not declared in this scope
devinfoparser.cpp:456: error: ‘MTP_OFC_FLAC’ was not declared in this scope
devinfoparser.cpp:459: error: ‘MTP_OFC_Undefined_Video’ was not declared in this scope
devinfoparser.cpp:462: error: ‘MTP_OFC_WMV’ was not declared in this scope
devinfoparser.cpp:465: error: ‘MTP_OFC_MP4_Container’ was not declared in this scope
devinfoparser.cpp:468: error: ‘MTP_OFC_MP2’ was not declared in this scope
devinfoparser.cpp:471: error: ‘MTP_OFC_3GP_Container’ was not declared in this scope
devinfoparser.cpp: In member function ‘bool DevInfoParser::PrintVendor(uint8_t**, uint16_t&)’:
devinfoparser.cpp:483: error: ‘Notify’ was not declared in this scope
devinfoparser.cpp:484: error: ‘Serial’ was not declared in this scope
devinfoparser.cpp:484: error: ‘HEX’ was not declared in this scope
devinfoparser.cpp:488: error: ‘PTP_VENDOR_EASTMAN_KODAK’ was not declared in this scope
devinfoparser.cpp:491: error: ‘PTP_VENDOR_SEIKO_EPSON’ was not declared in this scope
devinfoparser.cpp:494: error: ‘PTP_VENDOR_AGILENT’ was not declared in this scope
devinfoparser.cpp:497: error: ‘PTP_VENDOR_POLAROID’ was not declared in this scope
devinfoparser.cpp:500: error: ‘PTP_VENDOR_AGFA_GEVAERT’ was not declared in this scope
devinfoparser.cpp:503: error: ‘PTP_VENDOR_MICROSOFT’ was not declared in this scope
devinfoparser.cpp:506: error: ‘PTP_VENDOR_EQUINOX’ was not declared in this scope
devinfoparser.cpp:509: error: ‘PTP_VENDOR_VIEWQUEST’ was not declared in this scope
devinfoparser.cpp:512: error: ‘PTP_VENDOR_STMICROELECTRONICS’ was not declared in this scope
devinfoparser.cpp:515: error: ‘PTP_VENDOR_NIKON’ was not declared in this scope
devinfoparser.cpp:518: error: ‘PTP_VENDOR_CANON’ was not declared in this scope
devinfoparser.cpp:521: error: ‘PTP_VENDOR_FOTONATION’ was not declared in this scope
devinfoparser.cpp:524: error: ‘PTP_VENDOR_PENTAX’ was not declared in this scope
devinfoparser.cpp:527: error: ‘PTP_VENDOR_FUJI’ was not declared in this scope
devinfoparser.cpp: In member function ‘bool DevInfoParser::PrintString(uint8_t**, uint16_t&)’:
devinfoparser.cpp:559: error: ‘Serial’ was not declared in this scope
devinfoparser.cpp: At global scope:
devinfoparser.cpp:564: error: ‘NULL’ was not declared in this scope
devinfoparser.cpp: In member function ‘bool DevInfoParser::PrintWordArray(uint8_t**, uint16_t&, void (DevInfoParser::*)(uint16_t))’:
devinfoparser.cpp:591: error: ‘Serial’ was not declared in this scope
devinfoparser.cpp:591: error: ‘HEX’ was not declared in this scope
devinfoparser.cpp: In member function ‘virtual void DevInfoParser::Parse(uint16_t, const uint8_t*, const uint32_t&)’:
devinfoparser.cpp:615: error: ‘Notify’ was not declared in this scope
devinfoparser.cpp:615: error: ‘Serial’ was not declared in this scope
devinfoparser.cpp:615: error: ‘DEC’ was not declared in this scope
devinfoparser.cpp:621: error: ‘HEX’ was not declared in this scope

Hi oleg,
I want to make an open source DSLR Controller Android app for Canon DSLR’s but for my needs I want it to be working wirelessly via WiFi (I suppose BT isn’t fast enough). One of the main features is obviously LiveView image. I never tried USB Host Shield with Arduino to control my camera (Canon 550D) via PTP. I must add that this is for my engineering thesis project.
Platforms of my choice are Arduino and Android. I need to submit my topic ASAP so my question is (I don’t have time to make tests myself) – would it be possible to get liveview image with Arduino and pass it via WiFi shield? I believe you haven’t tried it but maybe you can predict it basing on your knowledge…

You can get data of any size out of a camera using Arduino, the question is how fast you need it. I used to transfer 10Mb pictures at a pace of about 0.5mb/min via serial to WiFi interface by Roving Networks. LiveView frame is ~250Kb, you will need ~30sec to transfer it.

I’m trying to control my NikonD60. I’m working with usb host shield 2.0 and Arduino UNO. (Arduino version 1.0.2). I unpacked PTP, Arduino_Camera_Control and USB_Host_Shield_2.0 libraries in \arduino-1.0.2\libraries. And when I try to run GetDevInfo, I got this:

C:\Users\Andreu\arduino-1.0.2\hardware\tools\avr\bin\avr-g++ -c -g -Os -Wall -fno-exceptions -ffunction-sections -fdata-sections -mmcu=atmega328p -DF_CPU=16000000L -MMD -DUSB_VID=null -DUSB_PID=null -DARDUINO=102 -IC:\Users\Andreu\arduino-1.0.2\hardware\arduino\cores\arduino -IC:\Users\Andreu\arduino-1.0.2\hardware\arduino\variants\standard -IC:\Users\Andreu\arduino-1.0.2\libraries\USB_Host_Shield_20 -IC:\Users\Andreu\arduino-1.0.2\libraries\PTP C:\Users\Andreu\AppData\Local\Temp\build2184657369212545598.tmp\devinfoparser.cpp -o C:\Users\Andreu\AppData\Local\Temp\build2184657369212545598.tmp\devinfoparser.cpp.o
In file included from /devinfoparser.h:7,
from devinfoparser.cpp:1:
C:\Users\Andreu\arduino-1.0.2\libraries\USB_Host_Shield_20/../ptp/mtpconst.h:104:25: warning: missing whitespace after the macro name
C:\Users\Andreu\arduino-1.0.2\libraries\USB_Host_Shield_20/../ptp/mtpconst.h:109:20: warning: missing whitespace after the macro name
C:\Users\Andreu\arduino-1.0.2\libraries\USB_Host_Shield_20/../ptp/mtpconst.h:110:24: warning: missing whitespace after the macro name
In file included from C:\Users\Andreu\arduino-1.0.2\libraries\USB_Host_Shield_20/../ptp/ptp.h:26,
from /devinfoparser.h:8,
from devinfoparser.cpp:1:
C:\Users\Andreu\arduino-1.0.2\libraries\USB_Host_Shield_20/../ptp/ptpdebug.h:22:33: error: ../USBHost/printhex.h: No such file or directory
C:\Users\Andreu\arduino-1.0.2\libraries\USB_Host_Shield_20/../ptp/ptpdebug.h:23:32: error: ../USBHost/hexdump.h: No such file or directory
C:\Users\Andreu\arduino-1.0.2\libraries\USB_Host_Shield_20/../ptp/ptpdebug.h:24:32: error: ../USBHost/message.h: No such file or directory
In file included from C:\Users\Andreu\arduino-1.0.2\libraries\USB_Host_Shield_20/Usb.h:45,
from C:\Users\Andreu\arduino-1.0.2\libraries\USB_Host_Shield_20/../ptp/ptp.h:23,
from /devinfoparser.h:8,
from devinfoparser.cpp:1:
C:\Users\Andreu\arduino-1.0.2\libraries\USB_Host_Shield_20/message.h: In function ‘void ErrorMessage(const char*, ERROR_TYPE)’:
C:\Users\Andreu\arduino-1.0.2\libraries\USB_Host_Shield_20/message.h:31: warning: only initialized variables can be placed into program memory area
C:\Users\Andreu\arduino-1.0.2\libraries\USB_Host_Shield_20/message.h:33: warning: only initialized variables can be placed into program memory area
In file included from C:\Users\Andreu\arduino-1.0.2\libraries\USB_Host_Shield_20/../ptp/ptp.h:25,
from /devinfoparser.h:8,
from devinfoparser.cpp:1:
C:\Users\Andreu\arduino-1.0.2\libraries\USB_Host_Shield_20/../ptp/ptpmsgstr.h: At global scope:
C:\Users\Andreu\arduino-1.0.2\libraries\USB_Host_Shield_20/../ptp/ptpmsgstr.h:20: warning: only initialized variables can be placed into program memory area
C:\Users\Andreu\arduino-1.0.2\libraries\USB_Host_Shield_20/../ptp/ptpmsgstr.h:21: warning: only initialized variables can be placed into program memory area
C:\Users\Andreu\arduino-1.0.2\libraries\USB_Host_Shield_20/../ptp/ptpmsgstr.h:22: warning: only initialized variables can be placed into program memory area
In file included from devinfoparser.cpp:1:
/devinfoparser.h:10: warning: only initialized variables can be placed into program memory area

… the same from /devinfoparser.h:10 to /devinfoparser.h:200.

/devinfoparser.h:201: warning: only initialized variables can be placed into program memory area

devinfoparser.cpp:X: warning: only initialized variables can be placed into program memory area —> When X = 3,36,49,68,76,112,127,145.

devinfoparser.cpp: In constructor ‘DevInfoParser::DevInfoParser()’:
devinfoparser.cpp:175: warning: statement has no effect
devinfoparser.cpp: In member function ‘bool DevInfoParser::PrintFunctMode(uint8_t**, uint16_t&)’:
devinfoparser.cpp:195: warning: only initialized variables can be placed into program memory area
devinfoparser.cpp: In member function ‘bool DevInfoParser::PrintVendor(uint8_t**, uint16_t&)’:
devinfoparser.cpp:X: warning: only initialized variables can be placed into program memory area — When (X=483,492, 495,498,501,504,507,510,513,516,519,522,525,528,531)
devinfoparser.cpp: In member function ‘virtual void DevInfoParser::Parse(uint16_t, const uint8_t*, const uint32_t&)’:
devinfoparser.cpp:615: warning: only initialized variables can be placed into program memory area
devinfoparser.cpp:X: warning: only initialized variables can be placed into program memory area When (X=642,650,658,666,674,682,690,698,706)

devinfoparser.cpp:711: warning: only initialized variables can be placed into program memory area from /devinfoparser.h:8,

Hi Oleg.
Thank you so much for sharing this.
I would appreciate your advice on the following: I’ve installed your PTP_2.0_master library and the Time library and am just trying to compile the sketches in order to make sure all is good.
I get the following, on the following examples:
EOSBulb -> compiles fine
EOSCamController -> Well.. Here’s the error log:

hdrcapture.h:20: error: ‘Q_USER_SIG’ was not declared in this scope
hdrcapture.h:34: error: expected class-name before ‘{‘ token
hdrcapture.h:40: error: expected class-name before ‘{‘ token
hdrcapture.h:45: error: expected class-name before ‘{‘ token
hdrcapture.h:52: error: expected class-name before ‘{‘ token
hdrcapture.h:57: error: expected class-name before ‘{‘ token
hdrcapture.h:73: error: ‘QEvt’ does not name a type
hdrcapture.h:75: error: ‘QStateHandler’ does not name a type
hdrcapture.h:77: error: ‘QEvt’ was not declared in this scope
hdrcapture.h:77: error: template argument 1 is invalid
hdrcapture.h:98: error: ‘QEvt’ has not been declared
hdrcapture.h:111: error: ‘QState’ does not name a type
hdrcapture.h:112: error: ‘QState’ does not name a type
hdrcapture.h:113: error: ‘QState’ does not name a type
hdrcapture.h:114: error: ‘QState’ does not name a type
hdrcapture.h:115: error: ‘QState’ does not name a type
hdrcapture.h:116: error: ‘QState’ does not name a type
hdrcapture.h:117: error: ‘QState’ does not name a type
hdrcapture.h:118: error: ‘QState’ does not name a type
hdrcapture.h:119: error: ‘QState’ does not name a type
hdrcapture.h:120: error: ‘QState’ does not name a type
hdrcapture.h:121: error: ‘QState’ does not name a type
/hdrcapture.h: In constructor ‘HDRCapture::HDRCapture(CanonEOS&)’:
hdrcapture.h:81: error: class ‘HDRCapture’ does not have any field named ‘QHsm’
hdrcapture.h:81: error: ‘QStateHandler’ was not declared in this scope
hdrcapture.h:81: error: ‘Initial’ is not a member of ‘HDRCapture’
hdrcapture.h:93: error: class ‘HDRCapture’ does not have any field named ‘activeHistory’
hdrcapture.h:95: error: ‘struct SetTimeoutEvt’ has no member named ‘sig’
hdrcapture.h:96: error: ‘struct PTP_RC_Evt’ has no member named ‘sig’
/hdrcapture.h: In member function ‘void HDRCapture::PostEvent(int*)’:
hdrcapture.h:100: error: request for member ‘Push’ in ‘((HDRCapture*)this)->HDRCapture::theQueue’, which is of non-class type ‘int’
/hdrcapture.h: In member function ‘void HDRCapture::Run()’:
hdrcapture.h:104: error: ‘QEvt’ was not declared in this scope
hdrcapture.h:104: error: ‘e’ was not declared in this scope
hdrcapture.h:106: error: request for member ‘Pop’ in ‘((HDRCapture*)this)->HDRCapture::theQueue’, which is of non-class type ‘int’
hdrcapture.h:107: error: ‘dispatch’ was not declared in this scope
EOSCamController.cpp: At global scope:
EOSCamController.pde:-1: error: ‘QEvt’ does not name a type
EOSCamController.cpp: In function ‘void MenuRunAbort()’:
EOSCamController.pde:-1: error: ‘evtAbort’ was not declared in this scope
EOSCamController.cpp: In function ‘void MenuRun()’:
EOSCamController.pde:-1: error: ‘struct SetEvt’ has no member named ‘sig’
EOSCamController.pde:-1: error: ‘class CamHDRCapture’ has no member named ‘dispatch’
EOSCamController.pde:-1: error: ‘struct SetEvt’ has no member named ‘sig’
EOSCamController.pde:-1: error: ‘class CamHDRCapture’ has no member named ‘dispatch’
EOSCamController.pde:-1: error: ‘struct SetEvt’ has no member named ‘sig’
EOSCamController.pde:-1: error: ‘class CamHDRCapture’ has no member named ‘dispatch’
EOSCamController.pde:-1: error: ‘struct SetBktEvt’ has no member named ‘sig’
EOSCamController.pde:-1: error: ‘class CamHDRCapture’ has no member named ‘dispatch’
EOSCamController.pde:-1: error: ‘struct SetEvt’ has no member named ‘sig’
EOSCamController.pde:-1: error: ‘class CamHDRCapture’ has no member named ‘dispatch’
EOSCamController.cpp: In member function ‘virtual void CamStateHandlers::OnDeviceInitializedState(PTP*)’:
EOSCamController.pde:-1: error: ‘evtTick’ was not declared in this scope
EOSCamController.pde:-1: error: cannot declare variable ‘hnd’ to be of abstract type ‘EosEventHandlers’
/eoseventhandler.h:13: note: because the following virtual functions are pure within ‘EosEventHandlers’:
C:\Program Files (x86)\arduino-1.0.1\libraries\PTP20master/eoseventparser.h:37: note: virtual void EOSEventHandlers::OnObjectCreated(const EOSEvent*)
EOSCamController.cpp: In function ‘void setup()’:
EOSCamController.pde:-1: error: ‘evtTick’ was not declared in this scope
EOSCamController.pde:-1: error: ‘evtAbort’ was not declared in this scope
EOSCamController.pde:-1: error: ‘class CamHDRCapture’ has no member named ‘init’

Is someone else could help me out here it would be great. I’ve combed all the forums and read all the comments and still can’t figure out:
A: Has this been updated to work with IDE 1.0?
B: After downloading, extracting and renaming the various libraries, AND after replacing qp_ccp I still get errors
C: after commenting out the void operator delete(void *) on the qp_ccp file I get different errors.

I’m getting this errors when I try to compile the example for EOSCapture:

EOSCapture.pde:14:17: warning: ptp.h: No such file or directory
EOSCapture.pde:15:22: warning: canoneos.h: No such file or directory
In file included from C:\Arduino\libraries\USB_Host_Shield_20/Usb.h:40,
from EOSCapture.pde:8:
C:\Arduino\libraries\USB_Host_Shield_20/message.h: In function ‘void ErrorMessage(const char*, ERROR_TYPE)’:
C:\Arduino\libraries\USB_Host_Shield_20/message.h:48: warning: only initialized variables can be placed into program memory area
C:\Arduino\libraries\USB_Host_Shield_20/message.h:50: warning: only initialized variables can be placed into program memory area
In file included from EOSCapture.pde:8:
C:\Arduino\libraries\USB_Host_Shield_20/Usb.h: At global scope:
C:\Arduino\libraries\USB_Host_Shield_20/Usb.h:168: warning: ‘packed’ attribute ignored
EOSCapture:18: error: expected class-name before ‘{‘ token
EOSCapture:24: error: ‘PTP’ has not been declared
EOSCapture:25: error: ‘PTP’ has not been declared
EOSCapture:30: error: ‘CanonEOS’ does not name a type
EOSCapture:32: error: variable or field ‘OnDeviceDisconnectedState’ declared void
EOSCapture:32: error: ‘PTP’ was not declared in this scope
EOSCapture:32: error: ‘ptp’ was not declared in this scope

In file included from C:\Arduino\libraries\USBHost/Usb.h:40,
from EOSCapture.pde:8:
C:\Arduino\libraries\USBHost/message.h: In function ‘void ErrorMessage(const char*, ERROR_TYPE)’:
C:\Arduino\libraries\USBHost/message.h:48: warning: only initialized variables can be placed into program memory area
C:\Arduino\libraries\USBHost/message.h:50: warning: only initialized variables can be placed into program memory area
In file included from EOSCapture.pde:8:
C:\Arduino\libraries\USBHost/Usb.h: At global scope:
C:\Arduino\libraries\USBHost/Usb.h:168: warning: ‘packed’ attribute ignored
In file included from C:\Arduino\libraries\ptp/ptp.h:25,
from EOSCapture.pde:14:
C:\Arduino\libraries\ptp/ptpmsgstr.h:20: warning: only initialized variables can be placed into program memory area
C:\Arduino\libraries\ptp/ptpmsgstr.h:21: warning: only initialized variables can be placed into program memory area
C:\Arduino\libraries\ptp/ptpmsgstr.h:22: warning: only initialized variables can be placed into program memory area
EOSCapture.pde: In member function ‘virtual void CamStateHandlers::OnDeviceDisconnectedState(PTP*)’:
EOSCapture.pde:37: warning: only initialized variables can be placed into program memory area
C:\Arduino\libraries\USBHost/message.h:27: error: too few arguments to function ‘void Notify(const char*, int)’
EOSCapture:37: error: at this point in file

When I call the function SwitchLiveView(on), the camera raises the mirror as if I’m using the live view, but the LCD display won’t turn on and the camera will be busy all the time…
I’m using a Canon 40D and also tested on a Canon 5D mark III

I just stumbled across this site but know nothing about Arduino. I Use Canon A620 cameras for trail camera use. I have a control board that controls Motion sensing, Camera Power, and Camera shutter.

This is what I want to do with Arduino. Please tell me if this is possible and how to do it?

I want to connect the camera through USB to the Arduino board and a GSM board (like the picture at the beginning of this post). When the Camera snaps a picture I want to transfer the picture through USB and send the picture to my email or text through GSM.

I know the 7D will tell a 580EX what focal length the lens is at. Is there a way to have an arduino tell the camera to set the lens to specific focal length.. This way, you could take an ultrasonic rangefinder, mount it to the hot shoe, and have the arduino focus the lens based on the ping from the rangefinder kind of like how the old Polaroid cameras worked.

I’m trying to control my Canon EOS 60D via the USB Hostshield 2.0
But I’m experiencing some strange Problem when trying to start and stop recording video…
Starting (setting 0xD1B8 to 4) always works but when I try to stop it (setting 0xD1B8 to 0) it always kind of crashes the host controller..
I get this:

Hello Oleg
Long time ago i tryed to read out an image form a canon 5dmkII and with your help, it worked. Now i will continue with my project and would buy/use a canon 100d for a webcam, controlled by your usb-host shield.
have your any information about the canon 100d. Does this camera work with your library?
I can’t test the camera because i would buy it when it works.
Thanks and sorry for my bad english!
Peter

I’ve got the new Canon 5Ds working with the EOSRemote program but I’m not able to use the full range of ISO values (it only allows me to go up to 400ISO). What do I have to change in the program to get this working? I’m finding the code a little challenging to understand. I’ve looked through the camera settings and the camera is not limiting the ISO range. I’ve also got the same problem with selecting aperture sizes.