GWSOFT.co.uk  

Site by Graham Wharton 
November 21st 2008 06:05:30 PM 



NOTE : This project is not currently in development and is totally unsupported. These pages are here for information only.

openCamera

Declaration

extern "C" status_t openCamera(void);

Description

This function must be implemented in the plugin. This function does not accept any parameters, but returns a status_t error code to indicate the success of the operation. Any of the status_t error codes can be used, but it is suggested that you stick to using B_NO_ERROR for success and B_ERROR for failure.

The function should attempt to set up a connection with the camera. No serial port information, etc is passed to this function. To setup the communication settings for the camera, either the optional level 2 function of configurePlugin should be implemented, or the user should be instructed to manually edit a settings file for the plugin to specify the various settings. Either way the port settings etc, should be stored in a file, and read everytime this function executes.

Example Implementation - Kodak DC210 Plugin

status_t openCamera(void) { LoadSettingsFromFile(); //Obtain the Serial Port Settings unsigned char* buffer = new unsigned char[1]; //New up the serial port object and set it's settings to //match the default camera settings ComPort = new BSerialPort(); ComPort->SetDataRate(B_9600_BPS); ComPort->SetFlowControl(0); ComPort->SetBlocking(true); ComPort->SetTimeout(3000000); //Make sure the port is open before sending if (ComPort->Open(serialportsetting.String()) < B_NO_ERROR) return(B_ERROR); //Switch the camera to the correct Baud rate by sending appropriate command switch(speed) { case B_9600_BPS: { ComPort->Write("\x41\x00\x96\x00\x00\x00\x00\x1A",8); break; } case B_19200_BPS: { ComPort->Write("\x41\x00\x19\x20\x00\x00\x00\x1A",8); break; } case B_38400_BPS: { ComPort->Write("\x41\x00\x38\x40\x00\x00\x00\x1A",8); break; } case B_57600_BPS: { ComPort->Write("\x41\x00\x57\x60\x00\x00\x00\x1A",8); break; } case B_115200_BPS: { ComPort->Write("\x41\x00\x11\x52\x00\x00\x00\x1A",8); break; } default: { ComPort->Write("\x41\x00\x11\x52\x00\x00\x00\x1A",8); break; } } ComPort->Read(buffer,1); while (buffer[0] == 0xf0) ComPort->Read(buffer,1); //check for busy byte if (buffer[0] == 0xe2) return(B_ERROR); else if (buffer[0] == 0xd1) { //Wait a while before changing the baud rate of the computer snooze(100000); ComPort->SetDataRate(speed); } return(B_NO_ERROR); }
BDCP Developers Home Page