+ All Categories
Home > Documents > Argus Camera API User Manual - SourceForgesourceforge.net/p/detectorsdp/wiki/Argus Detector...3.0...

Argus Camera API User Manual - SourceForgesourceforge.net/p/detectorsdp/wiki/Argus Detector...3.0...

Date post: 10-Jul-2020
Category:
Upload: others
View: 0 times
Download: 0 times
Share this document with a friend
20
03-032-20129-03 Argus Camera API User Manual 2012-01-16 Rev 3.0 Teledyne Dalsa Proprietary and Confidential 1 / 20 Teledyne Dalsa, 605 McMurray Road, Waterloo, Ontario, Canada, N2V2E9 http://www.teledynedalsa.com/ Argus Camera API User Manual Revision: 3.0 1 User Manual Revision History Revision Date Description 3.0 Jan 16, 2012 Added remarks, troubleshooting, and 64-bit system support information 2.0 Jan 12, 2012 Added remarks, troubleshooting section 1.0 Nov 28, 2011 Initial Separate Release
Transcript
Page 1: Argus Camera API User Manual - SourceForgesourceforge.net/p/detectorsdp/wiki/Argus Detector...3.0 Jan 16, 2012 Added remarks, troubleshooting, and 64-bit system support information

03-032-20129-03 Argus Camera API User Manual 2012-01-16 Rev 3.0

Teledyne Dalsa Proprietary and Confidential 1 / 20

Teledyne Dalsa, 605 McMurray Road, Waterloo, Ontario, Canada, N2V2E9

http://www.teledynedalsa.com/

Argus Camera API User Manual Revision: 3.0

1 User Manual Revision History

Revision Date Description

3.0 Jan 16, 2012 Added remarks, troubleshooting, and 64-bit system support information

2.0 Jan 12, 2012 Added remarks, troubleshooting section

1.0 Nov 28, 2011 Initial Separate Release

Page 2: Argus Camera API User Manual - SourceForgesourceforge.net/p/detectorsdp/wiki/Argus Detector...3.0 Jan 16, 2012 Added remarks, troubleshooting, and 64-bit system support information

03-032-20129-03 Argus Camera API User Manual 2012-01-16 Rev 3.0

Teledyne Dalsa Proprietary and Confidential 2 / 20

2 API revision History

Revision Date Description

3.0 Jan 16, 2012 Added multi-entrancy support to allow single application to multiple cameras;

Code ported and tested to support x64 system with limited support;

2.0 Sept 1st, 2011 Initial customer release

1.0 April 1st, 2011 Initial internal release

Page 3: Argus Camera API User Manual - SourceForgesourceforge.net/p/detectorsdp/wiki/Argus Detector...3.0 Jan 16, 2012 Added remarks, troubleshooting, and 64-bit system support information

03-032-20129-03 Argus Camera API User Manual 2012-01-16 Rev 3.0

Teledyne Dalsa Proprietary and Confidential 3 / 20

Table of Contents

1 User Manual Revision History ....................................................................................................................................................................................... 1

2 API revision History ........................................................................................................................................................................................................... 2

3 Argus API Overview ........................................................................................................................................................................................................... 4

4 Data Structure ...................................................................................................................................................................................................................... 4

5 Application Programming Interface (API) Functions ........................................................................................................................................... 6

5.1 DLLDIR_C_API(int) _camera_connect( ... ) ....................................................................................................................................................... 6

5.1.1 Arguments: ............................................................................................................................................................................................................ 6

5.1.2 Example: ................................................................................................................................................................................................................. 6

5.1.3 Notes: ...................................................................................................................................................................................................................... 6

5.2 DLLDIR_C_API(int) _camera_cmd( ... )............................................................................................................................................................... 7

5.2.1 Arguments: ............................................................................................................................................................................................................ 7

5.2.2 Example: ................................................................................................................................................................................................................. 7

5.2.3 Notes: ...................................................................................................................................................................................................................... 7

5.3 DLLDIR_C_API (int) _camera_get_image( ... ) ................................................................................................................................................. 8

5.3.1 Arguments ............................................................................................................................................................................................................. 8

5.3.2 Example: ................................................................................................................................................................................................................. 8

5.3.3 Notes: ...................................................................................................................................................................................................................... 8

5.4 DLLDIR_C_API(int) _camera_disconnect( ... ) ................................................................................................................................................. 9

5.4.1 Arguments ............................................................................................................................................................................................................. 9

5.4.2 Example: ................................................................................................................................................................................................................. 9

5.4.3 Notes: ...................................................................................................................................................................................................................... 9

6 How to use the .dll .......................................................................................................................................................................................................... 10

7 Example Code ................................................................................................................................................................................................................... 10

8 Remarks ............................................................................................................................................................................................................................... 17

8.1 Network Reliability ............................................................................................................................................................................................... 17

8.2 64-bit support ........................................................................................................................................................................................................ 17

9 Troubleshooting ............................................................................................................................................................................................................... 19

9.1 Troubleshooting basics ....................................................................................................................................................................................... 19

9.2 Error / Warning Messages ................................................................................................................................................................................. 19

Page 4: Argus Camera API User Manual - SourceForgesourceforge.net/p/detectorsdp/wiki/Argus Detector...3.0 Jan 16, 2012 Added remarks, troubleshooting, and 64-bit system support information

03-032-20129-03 Argus Camera API User Manual 2012-01-16 Rev 3.0

Teledyne Dalsa Proprietary and Confidential 4 / 20

3 Argus API Overview

Controlling Argus camera using the supplied Application Programming Interface is very simple.

There are 5 basic steps to follow:

In order to programmatically communicate with the detector please run the SDK installer supplied by Teledyne Dalsa. If not

otherwise specified, the DLLs you will need to use are under:

C:\Program Files\Teledyne Dalsa\ArgusAPI\

td_telnet.dll contains camera control mechanism

td_wget.dll contains image download mechanism

In order to control the Camera and download acquired images, you would need to:

1. Initiate communication by calling _camera_connect(…) function;

2. Once camera is connected, any camera control commands can be executed by calling _camera_cmd(…) function;

3. When the camera and the X-Ray system is ready to acquire an image, send “acq” command using _camera_cmd(…)

function;

4. To Download the acquired image please call _camera_get_image(…) function;

5. Repeating step 4 allows user to download image multiple times;

6. To finish operation, call _camera_disconnect(…) function to disconnect the camera.

Please contact Teledyne Dalsa ([email protected]), for further integration support.

See example code in this user manual for an example of camera control demonstration using

4 Data Structure

typedef struct { char Login[INIT_STR_LEN]; char Password[INIT_STR_LEN]; char CameraIP[INIT_STR_LEN]; char CameraResp[DLL_MSG_LEN]; int WSAStatus; int TARGET_PORT; } _CAM_INFO; static _CAM_INFO _cam_info = {0};

Camera Control Information, value assigned in main() Login : camera login user name “root” Password: camera login password “root” CameraIP: camera IP address “192.168.5.100” CameraResp: must be equal or greater than CAM_RESP_LEN defined in td_telnet.dll, now defined as len=256*25 WSAStatus: winsock status TARGET_PORT: telnet port 23

char *get_image_argv[] = { arguments pass to _camera_get_image( ... )

Connect Camera

_camera_connect(...)

Setup Camera

_camera_cmd(...)

Acquire Image

_camera_cmd(...)

Download Image

_camera_get_image(...)

Disconnect Camera

_camera_disconnect(...)

Page 5: Argus Camera API User Manual - SourceForgesourceforge.net/p/detectorsdp/wiki/Argus Detector...3.0 Jan 16, 2012 Added remarks, troubleshooting, and 64-bit system support information

03-032-20129-03 Argus Camera API User Manual 2012-01-16 Rev 3.0

Teledyne Dalsa Proprietary and Confidential 5 / 20

"_camera_get_image", "-w", "2", "-T", "15", "-O", "image.tiff", "-o", "_camera_get_image.log", "http://192.168.5.100/images/tp.tiff", };

argument: “-o” “_camera_get_image.log”, _camera_get_image will redirect progress to a log file as named. Note: For safe operation, please try to use exact same argument list provided in example code, except for download file names “image.tiff”

Page 6: Argus Camera API User Manual - SourceForgesourceforge.net/p/detectorsdp/wiki/Argus Detector...3.0 Jan 16, 2012 Added remarks, troubleshooting, and 64-bit system support information

03-032-20129-03 Argus Camera API User Manual 2012-01-16 Rev 3.0

Teledyne Dalsa Proprietary and Confidential 6 / 20

5 Application Programming Interface (API) Functions

5.1 DLLDIR_C_API(int) _camera_connect( ... )

The purpose of this function is to establish camera communication session.

5.1.1 Arguments:

char *pTargetAddr camera IP address “192.168.5.100”

int TargetPort telnet port 23

int *WSAStatus winsock status, can be used for error check

char *pResp camera response buffer must be large enough to fit all camera responses, minimum defined as len=256*25

char *pLogin camera login user name “root”

char *pPassword camera login password “root”

int timeout Command timeout (in millisecond), recommend use a value great than 25000.

return (int) 0 means OK; if !0, .dll process error, and attach error message to *pResp.

5.1.2 Example:

/* Connect to Camera */ /* telnet connect default is 60sec, CmdTimeout doesn't affect telnet connect */ ret = _camera_connect( _cam_info.CameraIP, _cam_info.TARGET_PORT, &_cam_info.WSAStatus, _cam_info.CameraResp, _cam_info.Login, _cam_info.Password, CmdTimeout ); printf("%s", _cam_info.CameraResp); if(ret != 0) { return ret; }

5.1.3 Notes:

_camera_connect(…) uses string comparison of server prompt.

Server prompt string tokens are hardcoded in .dll

/* Camera init command */ #define CAM_INIT_CMD "app_main\r" /* Camera mainApp after login */ /* Camera Status Prompt pattern */ #define CAM_LOGIN "login:" #define CAM_PASS "Password:" #define CAM_PROMPT "~ #" #define CAM_APP_PROMPT "OK>" #define CAM_ENG_PROMPT "ENG>" #define CAM_FACT_PROMPT "FACT>" ...

Page 7: Argus Camera API User Manual - SourceForgesourceforge.net/p/detectorsdp/wiki/Argus Detector...3.0 Jan 16, 2012 Added remarks, troubleshooting, and 64-bit system support information

03-032-20129-03 Argus Camera API User Manual 2012-01-16 Rev 3.0

Teledyne Dalsa Proprietary and Confidential 7 / 20

5.2 DLLDIR_C_API(int) _camera_cmd( ... )

The purpose of this function is to send camera commands to the camera.

For a complete list of available commands and their corresponding parameters please refer to Appendix A in the “03-032-

20109 DM-20-08K10-00-R Argus Detector User Manual”.

5.2.1 Arguments:

char *pCmd camera control command

char *pResp camera response buffer must be large enough to fit all camera responses, minimum defined as len=256*25

int timeout

Command timeout (in millisecond). Please note that the time out duration needs to be sufficiently long to complete the image acquisition. Minimum Limit is set as CAM_MIN_WAIT = 2000 (millisecond) Caveat: This timeout value is for API communication purpose only. Other than command “acq” (please see notes below), all camera commands should complete within its range; otherwise API function will return, Camera status is ignored.

return (int) 0 means OK; if !0, camera error message or .dll process error, and attach error message to *pResp. Positive return values are Camera Errors, Negatives return values are API errors.

5.2.2 Example:

char Cmd[CMD_LEN] = {0}; int CmdTimeout = 20000; /* in millisecond */ /* Set the Camera parameters, software trigger */ strcpy_s( Cmd, "gcp" ); ret = _camera_cmd( Cmd, _cam_info.CameraResp, CmdTimeout ); printf("%s", _cam_info.CameraResp); if(ret != 0) { return ret; }

/* acquire image */ printf("Acquire Image, please wait ...\n"); strcpy_s( Cmd, "acq" ); ret = _camera_cmd( Cmd, _cam_info.CameraResp, CmdTimeout); printf("%s", _cam_info.CameraResp); if(ret != 0) { return ret; }

5.2.3 Notes:

This API serves as a control mechanism only. Each individual command described in Argus Detector Use Manual is passed to

Camera by one _camera_cmd(…) call.

Please define appropriate timeout for individual command. Regular camera command should return within 3sec.

timeout value for “acq” image acquisition command depends on trigger source, please assign a reasonable

timeout for it to complete.

Actual acquisition duration is about:

For example:

Note: Please use timeout value in millisecond for API functions

(maximum line rate) Timeout is =

(minimum line rate) Timeout is =

Page 8: Argus Camera API User Manual - SourceForgesourceforge.net/p/detectorsdp/wiki/Argus Detector...3.0 Jan 16, 2012 Added remarks, troubleshooting, and 64-bit system support information

03-032-20129-03 Argus Camera API User Manual 2012-01-16 Rev 3.0

Teledyne Dalsa Proprietary and Confidential 8 / 20

Windows constant “INFINITE” as a timeout value is supported only for “acq” command starting from API v3.0,

Please note: Camera has an internal timeout value of 150 seconds for the “acq” command regardless trigger

presence.

When Camera times out the _camera_cmd(…) returns 0 with message in pResp “Run command timeout,

please check ExSync/Active signal! (status_reg = 0x17)”

If the API timeout value set shorter than the actual execution time of the command, API function returns and

the Camera status is ignored.

Example Scenario: Trigger mode is set to external, “acq” send with timeout value of “100 sec”, and user fail to

provide enough trigger within this “100 sec”. _camera_cmd(…) returns with timeout error, and Camera is left

waiting for external triggers. At this point API is off sync with the Camera. Camera will either timeout or

complete image acquisition depends on presence of enough trigger signals. Before Camera finishing up

executing the left over “acq” command, API is not able to send more commands.

“upd” firmware update: The whole process is about 3mins to finish. API recognizes this command and will clean up

established camera connection and return.

“rc” reboots the camera: Once received by camera, camera goes to reboot. API recognizes this command therefore it will

clean up established camera connection and return.

5.3 DLLDIR_C_API (int) _camera_get_image( ... )

5.3.1 Arguments

int argc number of arguments

char *const *argv argument string array for td_wget to grab image

char *pResp camera response buffer

return (int) 0 means OK; if !0, .dll process error, and attach error message to *pResp.

5.3.2 Example:

/* get image function argument */ /* argv[] gets permuted in wget automatically * url is moved to the last position always */ char *get_image_argv[] = { "_camera_get_image", "-w", //wait for 2 second, value from original .bat file "2", "-T", //timeout 15 second, value from original .bat file "15", "-O", //output file name, can use absolute path to it, but have to use Linux path divider "/" "c:/your_folder/image.tiff", "-o", //use log file, supress dll output to stdout, caller crashes if stdout is not handled "c:/your_folder/_camera_get_image.log", /* please create a folder to keep the log file */ "http://192.168.5.100/images/tp.tiff", }; int get_image_argc; get_image_argc = (sizeof(get_image_argv) / sizeof(get_image_argv[0]));

ret = _camera_get_image( get_image_argc, get_image_argv, _cam_info.CameraResp ); printf("%s", _cam_info.CameraResp); if(ret != 0) { return ret; }

5.3.3 Notes:

_camera_get_image( … ) function must be called only after “acq” camera command was successfully executed.

For safe operation, please try to use exact same argument list provided in the example code, except for download file names

Page 9: Argus Camera API User Manual - SourceForgesourceforge.net/p/detectorsdp/wiki/Argus Detector...3.0 Jan 16, 2012 Added remarks, troubleshooting, and 64-bit system support information

03-032-20129-03 Argus Camera API User Manual 2012-01-16 Rev 3.0

Teledyne Dalsa Proprietary and Confidential 9 / 20

“c:/your_folder/image.tiff”. To download image to client, please make sure the destination path exists before making

the call.

To download image to client workstation, please make sure the destination folder exists before making the call.

5.4 DLLDIR_C_API(int) _camera_disconnect( ... )

5.4.1 Arguments

int *WSAStatus winsock status, can be used for error check

char *pResp camera response buffer

int timeout Command timeout(in millisecond).

return (int) 0 means OK; if !0, .dll process error, and attach error message to *pResp.

5.4.2 Example:

printf("Close Camera control session.\n"); ret = _camera_disconnect( &_cam_info.WSAStatus, _cam_info.CameraResp, CmdTimeout ); printf("%s", _cam_info.CameraResp); if(ret != 0) { return ret; }

5.4.3 Notes:

_camera_disconnect( … ) function will terminate app_main and exit td_telnet session.

Please always use _camera_disconnect( … ) function to before terminating your application process. If the function is not

called and user application process terminated, depending on user application design (whether the connection session is

closed properly) there is a chance the camera app_main function is left running which prevents further

_camera_connect( … ) to succeed without terminating app_main or reboot the camera.

In case of camera app_main was left running by previous exited control operation, _camera_connect(…) will fail with follow-

ing error message: Error -205: DALSW_EVNT_WAIT_SEQ_ERR; Camera app_main fail to start, please make sure no other control session is running or Camera app_main is not already running.

User needs to terminate the running app_main manually by use telnet or reboot the camera:

To terminate app_main manually:

# killall app_main

user can also use “ps” command to double check the presence of the app_main after “killall” # ps | grep app_main

After cleaning up left running app_main, the API control sequence can start over.

Some commands “upd”, “rc” and “bye” will terminate camera firmware or reboot, _camera_cmd(…) recognizes

these command and will remove established camera connection afterwards. So it is not necessary to call

_camera_disconnect(…) after issuing such commands.

Page 10: Argus Camera API User Manual - SourceForgesourceforge.net/p/detectorsdp/wiki/Argus Detector...3.0 Jan 16, 2012 Added remarks, troubleshooting, and 64-bit system support information

03-032-20129-03 Argus Camera API User Manual 2012-01-16 Rev 3.0

Teledyne Dalsa Proprietary and Confidential 10 / 20

6 How to use the .dll

The example project included in the installation, can be used as a starting point. To support various linking option, import

library file (.lib) are included in the installation too.

Header file please, use ...\Include\ArgusAPI.h.

As for Visual Studio project, please add reference to the .lib files to compile the application.

A Microsoft merge module is provided for redistribution installer use.

7 Example Code

The purpose of the code below is to provide example on how to control the camera using the Teledyne Dalsa API. (see Argus User Manual for a full list of commands) Preparation: 1. Load Camera Info: ipaddress, telnet port, login name, password 2. Load image download wget parameter set Camera Operation: 1. Connect to camera 2. Check Current Camera Settings 3. Set image mode to 1 (internal trigger) 4. Start image acquisition 5. Download image to client (saved file name is configurable in char *get_image_argv[6]) 6. Close camera connection and terminate network communication to the Camera.

/*!\brief @file * The header file of the ArgusCaller */ #ifndef _ARGUS_CALLER_H_ #define _ARGUS_CALLER_H_ #include "ArgusAPI.h" /* */ #define TELNET_PORT 23 /* standard telnet port number */ #define CAM_RESP_LEN (256 * 25) /* Camera response maximum length, must be greater than RXBUF_LEN longest camera response burst is FACT>h = 54?? bytes */ #define CAM_TX_BUF_LEN 30 /* string length limit of the camera command */ #define INIT_STR_LEN 20 /* Length limit for user entry to dll */ /* Demo Code Constant Alias */ #define DLL_MSG_LEN CAM_RESP_LEN /* Camera resonse, MUST be greater or equal to dll buffer size CAM_RESP_LEN */ #define CMD_LEN CAM_TX_BUF_LEN /* Command string length */ #endif // _ARGUS_CALLER_H_

//////////////////////////////////////////////////////////////////////// // ArgusCaller.cpp (c) 2011 by Teledyne Dalsa // // Description: // This file contains the implementation of example code to operate Argus Camera // NOTE: SHOULD FLUSH CameraResp buffer after dump //////////////////////////////////////////////////////////////////////// #include "stdafx.h" #include <windows.h> #include "ArgusCaller.h" //using namespace std; HANDLE stdin1; HANDLE stdout1; typedef struct { char Login[INIT_STR_LEN]; char Password[INIT_STR_LEN]; char CameraIP[INIT_STR_LEN];

Page 11: Argus Camera API User Manual - SourceForgesourceforge.net/p/detectorsdp/wiki/Argus Detector...3.0 Jan 16, 2012 Added remarks, troubleshooting, and 64-bit system support information

03-032-20129-03 Argus Camera API User Manual 2012-01-16 Rev 3.0

Teledyne Dalsa Proprietary and Confidential 11 / 20

char CameraResp[DLL_MSG_LEN]; int WSAStatus; int TARGET_PORT; } _CAM_INFO; static _CAM_INFO _cam_info = {0}; int _tmain(int argc, _TCHAR* argv[]) { int ret = 0; char Cmd[CMD_LEN] = {0}; int CmdTimeout = 20000; /* Must be greater or equal to CAM_MIN_WAIT(2000) in millisecond */ memset( &_cam_info, 0, sizeof(_cam_info) ); /* Argus Camera Login */ strcpy_s( _cam_info.CameraIP, "192.168.5.100"); _cam_info.TARGET_PORT = TELNET_PORT; /* use IPPORT_TELNET is include <winsock.h> */ strcpy_s( _cam_info.Login, "root" ); strcpy_s( _cam_info.Password, "root" ); _cam_info.WSAStatus = 0; /* get image function argument */ /* argv[] gets permuted in wget automatically * url is moved to the last position always */ char *get_image_argv[] = { "_camera_get_image", "-w", //wait for 2 second, value from original .bat file "2", "-T", //timeout 15 second, value from original .bat file "15", "-O", //output file name, can use absolute path to it, but have to use Linux path divider "/" "c:/your_folder/image.tiff", "-o", //use log file, supress dll output to stdout, caller may crash if stdout is not handled "c:/your_folder/_camera_get_image.log", /* please create a folder to keep the log file */ "http://192.168.5.100/images/tp.tiff", }; int get_image_argc; get_image_argc = (sizeof(get_image_argv) / sizeof(get_image_argv[0])); // SetConsoleMode( stdin1, ENABLE_LINE_INPUT | ENABLE_ECHO_INPUT | ENABLE_PROCESSED_INPUT ); printf("Connecting to camera: %s ...\n", _cam_info.CameraIP); // SetConsoleTitle("Argus Camera Control Interface..."); stdin1 = GetStdHandle( STD_INPUT_HANDLE ); stdout1 = GetStdHandle( STD_OUTPUT_HANDLE ); /* Connect to Camera */ /* must define long enough timeout */ /* telnet connect default is 60sec, CmdTimeout doesn't affect telnet connect */ ret = _camera_connect( _cam_info.CameraIP, _cam_info.TARGET_PORT, &_cam_info.WSAStatus, _cam_info.CameraResp, _cam_info.Login, _cam_info.Password, CmdTimeout ); printf("%s\n", _cam_info.CameraResp); if(ret != 0) { return ret; } /* Get current Camera Settings */ strcpy_s( Cmd, "gcp" ); ret = _camera_cmd( Cmd, _cam_info.CameraResp, CmdTimeout ); printf("%s\n", _cam_info.CameraResp); if(ret != 0) {

Page 12: Argus Camera API User Manual - SourceForgesourceforge.net/p/detectorsdp/wiki/Argus Detector...3.0 Jan 16, 2012 Added remarks, troubleshooting, and 64-bit system support information

03-032-20129-03 Argus Camera API User Manual 2012-01-16 Rev 3.0

Teledyne Dalsa Proprietary and Confidential 12 / 20

return ret; } /* acquire image, please make sure trigger mode is set properly before grabbing */ /* Set Image Mode 1 */ strcpy_s( Cmd, "sim 1" ); ret = _camera_cmd( Cmd, _cam_info.CameraResp, CmdTimeout ); printf("%s\n", _cam_info.CameraResp); if(ret < 0) { return ret; } printf("Acquire Image, please wait ...\n"); strcpy_s( Cmd, "acq" ); ret = _camera_cmd( Cmd, _cam_info.CameraResp, CmdTimeout ); printf("%s\n", _cam_info.CameraResp); if(ret != 0) { return ret; } printf("Downloading image from Camera ... \n"); ret = _camera_get_image( get_image_argc, get_image_argv, _cam_info.CameraResp ); printf("Image downloaded... \n"); printf("%s\n", _cam_info.CameraResp); if(ret != 0) { return ret; } /* Close Camera operation */ printf("Close Camera control session.\n"); ret = _camera_disconnect( &_cam_info.WSAStatus, _cam_info.CameraResp, CmdTimeout ); printf("%s\n", _cam_info.CameraResp); if(ret != 0) { return ret; } else printf("Camera Control Demo is closed gracefully.\n"); return 0; }

Another Example: Preparation: 1. Load Camera Info: ipaddress, telnet port, login name, password 2. Load image download wget parameter set 3. For multiple image download, define string for TargetFileName & TargetLogName Camera Operation: 1. Connect to camera. 2. Loop begins: 3. Set binning mode 2x2. 4. Set image mode to “1” – TDI with Internal Trigger. 5. Display camera settings. 6. Grab image. 7. Set output file name and download image. 8. Set output file name and download image again. 9. Set binning mode 4x4. 10. Set image mode to “1” – TDI with Internal Trigger. 11. Display camera settings. 12. Grab image. 13. Set output file name and download image. 14. Loop jumps. 15. Loop ends, disconnect camera.

////////////////////////////////////////////////////////////////////////

Page 13: Argus Camera API User Manual - SourceForgesourceforge.net/p/detectorsdp/wiki/Argus Detector...3.0 Jan 16, 2012 Added remarks, troubleshooting, and 64-bit system support information

03-032-20129-03 Argus Camera API User Manual 2012-01-16 Rev 3.0

Teledyne Dalsa Proprietary and Confidential 13 / 20

// ArgusCaller_testcase1.cpp (c) 2011 by Teledyne Dalsa // // Description: // This file contains the implementation of example code to operate Argus Camera // NOTE: SHOULD FLUSH CameraResp buffer after dump // TESTCASE: continus run to test network stability // NOTE: // //////////////////////////////////////////////////////////////////////// #include "stdafx.h" #include <windows.h> #include "ArgusCaller.h" //using namespace std; HANDLE stdin1; HANDLE stdout1; typedef struct { char Login[INIT_STR_LEN]; char Password[INIT_STR_LEN]; char CameraIP[INIT_STR_LEN]; char CameraResp[DLL_MSG_LEN]; int WSAStatus; int TARGET_PORT; } _CAM_INFO; static _CAM_INFO _cam_info = {0}; int _tmain(int argc, _TCHAR* argv[]) { FILE *checkfp; int ret = 0; char Cmd[CMD_LEN] = {0}; int CmdTimeout = 3000; /* Must be greater or equal to CAM_MIN_WAIT(2000) in millisecond */ int CamConnectTimout = 60000; /* Timeout value for _camera_conect() */ char TargetFileName[50] = {0}; char TargetLogName[50] = {0}; int testid = 0; int testCnt = 300; /* test run count */ memset( &_cam_info, 0, sizeof(_cam_info) ); /* Argus Camera Login */ strcpy_s( _cam_info.CameraIP, "192.168.5.100"); _cam_info.TARGET_PORT = TELNET_PORT; /* use IPPORT_TELNET is include <winsock.h> */ strcpy_s( _cam_info.Login, "root" ); strcpy_s( _cam_info.Password, "root" ); _cam_info.WSAStatus = 0; /* get image function argument */ /* argv[] gets permuted in wget automatically * url is moved to the last position always */ char *get_image_argv[] = { "_camera_get_image", "-w", //wait for 2 second, value from original .bat file "2", "-T", //timeout 15 second, value from original .bat file "15", "-O", //output file name, can use absolute path to it, but have to use Linux path divider "/" "c:/your_folder/image_2x2.tiff", "-o", //use log file, supress dll output to stdout, caller crashes if stdout is not handled "c:/your_folder/_camera_get_image.log", /* please create a folder to keep the log file */

Page 14: Argus Camera API User Manual - SourceForgesourceforge.net/p/detectorsdp/wiki/Argus Detector...3.0 Jan 16, 2012 Added remarks, troubleshooting, and 64-bit system support information

03-032-20129-03 Argus Camera API User Manual 2012-01-16 Rev 3.0

Teledyne Dalsa Proprietary and Confidential 14 / 20

"http://192.168.5.100/images/tp.tiff", }; int get_image_argc; get_image_argc = (sizeof(get_image_argv) / sizeof(get_image_argv[0])); printf("Connecting to camera: %s ...\n", _cam_info.CameraIP); stdin1 = GetStdHandle( STD_INPUT_HANDLE ); stdout1 = GetStdHandle( STD_OUTPUT_HANDLE ); get_image_argv[6] = TargetFileName; get_image_argv[8] = TargetLogName; /* Connect to Camera */ /* must define long enough timeout */ /* telnet connect default is 60sec, CmdTimeout doesn't affect telnet connect */ ret = _camera_connect( _cam_info.CameraIP, _cam_info.TARGET_PORT, &_cam_info.WSAStatus, _cam_info.CameraResp, _cam_info.Login, _cam_info.Password, CamConnectTimout ); printf("%s\n", _cam_info.CameraResp); if(ret != 0) { return ret; } for (testid = 0; testid < testCnt; testid++) { printf("=======================================>test#%d: running \n", testid); /* binning 2x2 */ strcpy_s( Cmd, "sbm 2" ); ret = _camera_cmd( Cmd, _cam_info.CameraResp, CmdTimeout ); printf("%s\n", _cam_info.CameraResp); if(ret != 0) { return ret; } /* Set the Camera parameters, software trigger */ strcpy_s( Cmd, "sim 1" ); ret = _camera_cmd( Cmd, _cam_info.CameraResp, CmdTimeout ); printf("%s\n", _cam_info.CameraResp); if(ret != 0) { return ret; } /* display camera settings */ strcpy_s( Cmd, "gcp" ); ret = _camera_cmd( Cmd, _cam_info.CameraResp, CmdTimeout ); printf("%s\n", _cam_info.CameraResp); if(ret != 0) { return ret; } /* grab image */ strcpy_s( Cmd, "acq" ); ret = _camera_cmd( Cmd, _cam_info.CameraResp, CmdTimeout * 10 ); printf("%s\n", _cam_info.CameraResp); if(ret != 0) { return ret; } sprintf_s(TargetFileName, "c:/your_folder/image_2x2_a_%d.tiff", testid); sprintf_s(TargetLogName, "c:/your_folder/_camera_get_image_a_%d.log", testid);

Page 15: Argus Camera API User Manual - SourceForgesourceforge.net/p/detectorsdp/wiki/Argus Detector...3.0 Jan 16, 2012 Added remarks, troubleshooting, and 64-bit system support information

03-032-20129-03 Argus Camera API User Manual 2012-01-16 Rev 3.0

Teledyne Dalsa Proprietary and Confidential 15 / 20

printf("Downloading image from Camera ... \n"); ret = _camera_get_image( get_image_argc, get_image_argv, _cam_info.CameraResp ); printf("Image downloaded... \n"); printf("%s\n", _cam_info.CameraResp); if(ret != 0) { printf("ret = %d\n", ret); return ret; } sprintf_s(TargetFileName, "c:/your_folder/image_2x2_b_%d.tiff", testid); sprintf_s(TargetLogName, "c:/your_folder/_camera_get_image_b_%d.log", testid); printf("Downloading image again from Camera ... \n"); ret = _camera_get_image( get_image_argc, get_image_argv, _cam_info.CameraResp ); printf("Image downloaded... \n"); printf("%s\n", _cam_info.CameraResp); if(ret != 0) { printf("ret = %d\n", ret); return ret; } /* binning 4x4 */ strcpy_s( Cmd, "sbm 4" ); ret = _camera_cmd( Cmd, _cam_info.CameraResp, CmdTimeout ); printf("%s\n", _cam_info.CameraResp); if(ret != 0) { return ret; } /* Set the Camera parameters, software trigger */ strcpy_s( Cmd, "sim 1" ); ret = _camera_cmd( Cmd, _cam_info.CameraResp, CmdTimeout ); printf("%s\n", _cam_info.CameraResp); if(ret != 0) { return ret; } /* display camera settings */ strcpy_s( Cmd, "gcp" ); ret = _camera_cmd( Cmd, _cam_info.CameraResp, CmdTimeout ); printf("%s\n", _cam_info.CameraResp); if(ret != 0) { return ret; } /* grab image */ strcpy_s( Cmd, "acq" ); ret = _camera_cmd( Cmd, _cam_info.CameraResp, CmdTimeout * 10 ); printf("%s\n", _cam_info.CameraResp); if(ret != 0) { return ret; } sprintf_s(TargetFileName, "c:/your_folder/image_4x4_%d.tiff", testid); sprintf_s(TargetLogName, "c:/your_folder/_camera_get_image_4x4_%d.log", testid); printf("Downloading image from Camera ... \n"); ret = _camera_get_image( get_image_argc, get_image_argv, _cam_info.CameraResp ); printf("Image downloaded... \n"); printf("%s\n", _cam_info.CameraResp); if(ret != 0) { return ret;

Page 16: Argus Camera API User Manual - SourceForgesourceforge.net/p/detectorsdp/wiki/Argus Detector...3.0 Jan 16, 2012 Added remarks, troubleshooting, and 64-bit system support information

03-032-20129-03 Argus Camera API User Manual 2012-01-16 Rev 3.0

Teledyne Dalsa Proprietary and Confidential 16 / 20

} } // end of for (testid = 0; testid < testCnt; testid++); /* Close Camera operation */ printf("Close Camera control session.\n"); ret = _camera_disconnect( &_cam_info.WSAStatus, _cam_info.CameraResp, CmdTimeout ); printf("%s\n", _cam_info.CameraResp); if(ret != 0) { return ret; } printf("Camera Control Demo is closed gracefully.\n"); return 0; }

Page 17: Argus Camera API User Manual - SourceForgesourceforge.net/p/detectorsdp/wiki/Argus Detector...3.0 Jan 16, 2012 Added remarks, troubleshooting, and 64-bit system support information

03-032-20129-03 Argus Camera API User Manual 2012-01-16 Rev 3.0

Teledyne Dalsa Proprietary and Confidential 17 / 20

8 Remarks

8.1 Network Reliability

Telnet protocol is designed to provide simple connectivity, in order to gain maximum network reliability. Please setup a

dedicated network for camera and control workstation.

To control a single camera, a dedicated network adaptor is highly recommended.

To control multiple cameras by single workstation, a dedicated network hub/switch is recommended.

Please do not connect camera through a router/switch which provides regular network service to your workstation.

Camera performance and reliability will suffer.

Some application polls all network adaptors, could cause unnecessary interference to the camera control link also.

For instance, dropbox (www.dropbox.com) “LAN sync” feature broadcasts to all LAN interfaces; that will introduce

unnecessary packets delay for telnet connection. Simply disable the “LAN sync” feature, dropbox still works over WAN but

less interference is with camera control.

8.2 64-bit support

Argus API mainstream is designed and compiled for 32-bit OS.

The API executes under WOW64 on the 32-bit common language runtime on a 64-bit Windows Platform. WOW64 is a

compatibility environment provided by the operating system that allows a 32-bit application to run on a Windows 64-bit

operating system.

TeledyneDalsa 32-bit API caller application with 32-bit API passed test on Win7 Ultimate x64.

If issues are found while using the API on a 64-bit system, please consider to run your application in Window 32 bit

compatibility mode with administrator privilege level enabled. See following screenshot for how to.

Right click on your executable and click Properties from the

pop up menu.

Click Compatibility tab.

check “Run this program in compatibility mode for:” and click

on the drop-down arrow and select either “Windows XP

(Service Pack 2)” or “Windows XP (Service Pack 3)”.

In the Privilege Level section, please check “Run this program

as an administrator”

Page 18: Argus Camera API User Manual - SourceForgesourceforge.net/p/detectorsdp/wiki/Argus Detector...3.0 Jan 16, 2012 Added remarks, troubleshooting, and 64-bit system support information

03-032-20129-03 Argus Camera API User Manual 2012-01-16 Rev 3.0

Teledyne Dalsa Proprietary and Confidential 18 / 20

When starting your application, click Yes in User Account

Control dialog pop up.

Windows 7 XP mode can be considered as another alternative if user would use Windows XP compatibility mode to run

application. The Windows 7 XP mode should work as a native Windows XP as advertised by Microsoft. Windows 7 XP mode

is not tested by Teledyne Dalsa.

A set of .dlls compiled for x64 platform are also included from API v3.0 ([installation_path]\x64\) to facilitate user integration.

Please do not use .dlls compiled for x64 bit on any 32-bit system. They will not be loaded by Windows 7 x64. Please also note:

limited by existing TeledyneDalsa testing engineering toolsets, the x64 .dlls didn’t go through as much as rigorous operational

tests as their 32-bit counterpart. Please give your preference to the 32-bit .dlls whenever possible.

Page 19: Argus Camera API User Manual - SourceForgesourceforge.net/p/detectorsdp/wiki/Argus Detector...3.0 Jan 16, 2012 Added remarks, troubleshooting, and 64-bit system support information

03-032-20129-03 Argus Camera API User Manual 2012-01-16 Rev 3.0

Teledyne Dalsa Proprietary and Confidential 19 / 20

9 Troubleshooting

9.1 Troubleshooting basics

API Caller application should test all API functions calls, if any function doesn’t return “0”, an error and troubleshooting hints

message is bundled with the error code saved in pResp array. Most of the error messages are self-explaining. Positive return

values are Camera Errors, Negatives return values are API errors.

User can always bypass the API and use telnet to control the camera. In troubleshooting your application, using telnet can

isolate issues in the API or in the Camera. A function succeeds in Camera should succeed in API given enough timeout value.

Please try to use this guide for troubleshooting reference, after going through this guide if issue still remains; please contact

Teledyne Dalsa with following information:

A brief description of your control sequence.

Context, name, and return of the function call which generates error.

Test result of repeated control by using direct telnet (if applicable).

9.2 Error / Warning Messages

In the following section, a list of complete error messages with possible cause explained is presented.

In normal operation the only possible error message is: -202, DALSW_EVNT_TIMEOUT

Error Code

Error Name Troubleshooting Hints

Postive Number

Camera Error Code API function completed properly, the return value is a Camera Error message. Please read the return string.

-3 DALSW_ERROR_ARG_INVALID Invalid argument, a more detailed message is provided in pResp

-5 DALSW_ERROR_WSA_ERROR WinSock 1.1 DLL is not initialized properly. or WinSock Error, WSAStartup() failed.

It’s an OS resource failure; you will have to save your work and reboot the machine.

Remarks: It is very rare if reboot won’t fix the problem. Please make sure your target machine has WinSock 1.1 or 2.0 support. Windows 7 or Windows XP by default has native support to WinSock 2.0. If reboot doesn’t fix the problem, you probably have some issue with the winsock32.dll. Search Microsoft Dev Center for help.

-6 DALSW_ERROR_SOCK_CREAT Socket class creation failure. API failed in creating a new socket, it’s winsock failure, or system resource inquiry failure. Normally a reboot will fix the problem.

-7 DALSW_ERROR_SOCK_CONNECT Socket connect failed, please make sure the Camera is powered up and connection settings are correct.

-8 DALSW_ERROR_SOCK_CLOSE In camera disconnect, closesocket() failed. It won’t affect camera control.

-9 DALSW_ERROR_SOCK_RX Rx Socket Error. Please try to rerun your application.

-10 DALSW_ERROR_SOCK_TX Tx Socket Send Error. Please try to rerun your application.

-11 DALSW_ERROR_SOCK_RX_OBJ Socket error caused Rx Thread exit. Please try to rerun your application.

-12 DALSW_ERROR_SOCK_TX_OBJ Socket error caused Tx Thread exit. Please try to rerun your application.

-14 DALSW_ERROR_CAMERA_NOT_RDY Camera not ready, call _camera_cmd() before _camera_connect() can produce this error.

-30 DALSA_ERROR_WGET_INVALID_ARG wget main function got invalid arguments

-102 DALSW_ERROR_ILLEGAL_CALL Wrong calling sequence, multiple calls of _camera_connect() will produce this error.

-201 DALSW_EVNT_WAIT_ABORT Event wait abort, a system wait() failure. Please try to rerun your application or further reboot the machine.

-202 DALSW_EVNT_TIMEOUT Camera response was not received within given timeout. Please make sure camera power and connection.

-203 DALSW_EVNT_WAIT_FAILED system wait() function failure, see attached System Error Code, reference to MSDN: GetLastError().

Page 20: Argus Camera API User Manual - SourceForgesourceforge.net/p/detectorsdp/wiki/Argus Detector...3.0 Jan 16, 2012 Added remarks, troubleshooting, and 64-bit system support information

03-032-20129-03 Argus Camera API User Manual 2012-01-16 Rev 3.0

Teledyne Dalsa Proprietary and Confidential 20 / 20

Please try to rerun your application or further reboot the machine.

-204 DALSW_EVNT_WAIT_UNKNOWN system wait() function failure, please try to rerun your application or further reboot the machine.

-205 DALSW_EVNT_WAIT_SEQ_ERR Wrong Camera status detected, please rerun your application.

Camera app_main could be left running by previous control sequence. In such scenario _camera_connect(…) won’t succeed. Error message “DALSW_EVNT_WAIT_SEQ_ERR; Camera app_main fail to start, please make sure no other control session is running or Camera app_main is not already running.”

You can either telnet to the camera and manually terminate the running app_main by doing the following: # killall app_main or reboot the camera.

There is no method to communicate with a left running app_main if a control process is already terminated.

-210 DALSW_ERROR_EVENT_CREATE system CreateEvent() or ResetEvent() failure, please get reference from MSDN for attached GetLastError() return.

-220 DALSW_MUTEX_CREATE system CreateMutex() failure, please get reference from MSDN for attached GetLastError() return.

-221 DALSW_MUTEX_WAIT_ABANDONED system wait function abandoned, please try rerun your application.

-222 DALSW_MUTEX_TIMEOUT wait() function timed out while waiting for mutex, most like cause is thread exceptional exit without releasing the mutex. Restart application will reinitialize the mutex.

-223 DALSW_MUTEX_WAIT_FAILED a system wait() failure, please try to rerun your application.

-224 DALSW_MUTEX_WAIT_UNKNOWN system wait function failure, please try to rerun your application or further reboot the machine

-301 DALSW_THREAD_CON_CLOSED Camera has closed the connection, please reconnect

-302 DALSW_THREAD_BUF_OVERFLOW Camera response internal buffer overflow. Camera response is longer than hardcoded internal buffer size 256*25

-303 DALSW_THREAD_UNEXPECTED_RETURN Tx or Rx thread unexpected return, more detailed info attached

-304 DALSW_WARN_LIMIT_REACHED Camera warning message limit reached. API caller won’t report this error code to user, but a information message will be posted to pResp.

Please make sure you understand the warning messages themselves, sending “reset_warn” command or restarting your application will reset the warning count.


Recommended