-
Notifications
You must be signed in to change notification settings - Fork 1
/
main.c
101 lines (80 loc) · 2.99 KB
/
main.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
/* Copying and distribution of this file, with or without modification,
* are permitted in any medium without royalty. This file is offered as-is,
* without any warranty.
*/
/*! @file main.c
* @brief Main file of the template application. It contains initialization
* code.
*/
#include "template.h"
#include <string.h>
#include <sched.h>
#include <errno.h>
#include <unistd.h>
#include <stdlib.h>
/*! @brief This stores all variables needed by the algorithm. */
struct TEMPLATE data;
/*********************************************************************//*!
* @brief Initialize everything so the application is fully operable
* after a call to this function.
*
* @return SUCCESS or an appropriate error code.
*//*********************************************************************/
OscFunction(static Init, const int argc, const char * argv[])
uint8 multiBufferIds[2] = {0, 1};
memset(&data, 0, sizeof(struct TEMPLATE));
/******* Create the framework **********/
OscCall( OscCreate,
&OscModule_cam,
&OscModule_bmp,
&OscModule_vis,
&OscModule_hsm,
&OscModule_ipc,
&OscModule_gpio,
&OscModule_log,
&OscModule_sup);
/* Seed the random generator */
srand(OscSupCycGet());
/* Set the camera registers to sane default values. */
OscCall( OscCamPresetRegs);
OscCall( OscCamSetupPerspective, OSC_CAM_PERSPECTIVE_DEFAULT);
/* Configure camera emulation on host */
#if defined(OSC_HOST) || defined(OSC_SIM)
OscCall( OscFrdCreateConstantReader, &data.hFileNameReader, TEST_IMAGE_FN);
OscCall( OscCamSetFileNameReader, data.hFileNameReader);
#endif /* OSC_HOST or OSC_SIM */
/* Set up two frame buffers for maximum image size. Cached memory.
* Register the buffers as multi-buffer for the camera */
OscCall( OscCamSetFrameBuffer, 0, OSC_CAM_MAX_IMAGE_WIDTH*OSC_CAM_MAX_IMAGE_HEIGHT, data.u8FrameBuffers[0], TRUE);
OscCall( OscCamSetFrameBuffer, 1, OSC_CAM_MAX_IMAGE_WIDTH*OSC_CAM_MAX_IMAGE_HEIGHT, data.u8FrameBuffers[1], TRUE);
OscCall( OscCamCreateMultiBuffer, 2, multiBufferIds);
/* Register an IPC channel to the CGI for the web interface. */
OscCall( OscIpcRegisterChannel, &data.ipc.ipcChan, USER_INTERFACE_SOCKET_PATH, F_IPC_SERVER | F_IPC_NONBLOCKING);
OscFunctionCatch()
/* Destruct framwork due to error above. */
OscDestroy();
OscMark_m( "Initialization failed!");
OscFunctionEnd()
/*********************************************************************//*!
* @brief Program entry
*
* @param argc Command line argument count.
* @param argv Command line argument strings.
* @return 0 on success
*//*********************************************************************/
OscFunction( mainFunction, const int argc, const char * argv[])
/* Initialize system */
OscCall( Init, argc, argv);
OscLogSetConsoleLogLevel(INFO);
OscLogSetFileLogLevel(WARN);
StateControl();
OscFunctionCatch()
OscDestroy();
OscLog(INFO, "Quit application abnormally!\n");
OscFunctionEnd()
int main(const int argc, const char * argv[]) {
if (mainFunction(argc, argv) == SUCCESS)
return 0;
else
return 1;
}