Skip to content

Commit 08b348b

Browse files
committed
[nasa/nos3#462] Updated the File logic in device to be togged with a tag in platform_cfg/device_cfg for checkout, and made it so it is disabled by default (as it has been) for cFS, and enabled by default for the checkout.
1 parent 5977dd9 commit 08b348b

File tree

5 files changed

+52
-38
lines changed

5 files changed

+52
-38
lines changed

fsw/cfs/platform_inc/cam_platform_cfg.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,8 @@ [email protected]
4646
//#define OV2640
4747
#define OV5640
4848
//#define OV5642
49+
//enable file mode:
50+
//#define FILE_MODE
4951
#endif
5052

5153
#endif

fsw/shared/cam_device.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -501,7 +501,7 @@ int32_t CAM_read(char* buf, uint16_t* i, uint8_t* status)
501501
uint8_t spiw[2] = { 0x3D, 0x00}; // FIFO read
502502

503503
#ifdef FILE_OUTPUT
504-
FILE *fp1 = fopen("pic.jpg", "a");
504+
FILE *fp1 = fopen("/home/jstar/Desktop/github-nos3/pic.jpg", "a");
505505
if (!fp1)
506506
{
507507
OS_printf("\t ERROR: Could not create file\n");

fsw/shared/cam_device.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,9 @@ [email protected]
2626
/************************************************************************
2727
** Debug Definitions
2828
*************************************************************************/
29-
//#define FILE_OUTPUT
29+
#ifdef FILE_MODE
30+
#define FILE_OUTPUT
31+
#endif
3032
//#define STF1_DEBUG
3133

3234
/************************************************************************

fsw/standalone/arducam_checkout.c

Lines changed: 45 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -93,87 +93,96 @@ int get_command(const char* str)
9393

9494
int take_picture(uint8_t size)
9595
{
96-
int32_t status = OS_SUCCESS;
96+
uint8_t status = 1;
9797
uint32_t length = 0;
9898
uint8_t data[CAM_DATA_SIZE];
9999
uint16_t x = 0;
100+
int32_t result = OS_ERROR;
101+
int32_t read_result = OS_SUCCESS;
100102

101-
// Initialize Inter-Integrated Circuit
102-
status = CAM_init_i2c();
103-
if (status != OS_SUCCESS) return OS_ERROR;
103+
while( status == 1)
104+
{
105+
// Initialize Inter-Integrated Circuit
106+
result = CAM_init_i2c();
107+
if (result != OS_SUCCESS) return OS_ERROR;
104108
OS_printf("I2C initialization success\n");
105109

106110
// Initialize Serial Peripheral Interface
107-
status = CAM_init_spi();
108-
if (status != OS_SUCCESS) return OS_ERROR;
111+
result = CAM_init_spi();
112+
if (result != OS_SUCCESS) return OS_ERROR;
109113
OS_printf("SPI initialization success\n");
110114

111115
// Configure Camera for Upload
112-
status = CAM_config();
113-
if (status != OS_SUCCESS) return OS_ERROR;
116+
result = CAM_config();
117+
if (result != OS_SUCCESS) return OS_ERROR;
114118
OS_printf("Configuration success\n");
115119

116120
// Configure Registers
117-
status = CAM_jpeg_init();
118-
if (status != OS_SUCCESS) return OS_ERROR;
121+
result = CAM_jpeg_init();
122+
if (result != OS_SUCCESS) return OS_ERROR;
119123
OS_printf("JPEG init success\n");
120124

121125
// Configure Registers
122-
status = CAM_yuv422();
123-
if (status != OS_SUCCESS) return OS_ERROR;
126+
result = CAM_yuv422();
127+
if (result != OS_SUCCESS) return OS_ERROR;
124128
OS_printf("YUV422 success\n");
125129

126130
// Configure Registers
127-
status = CAM_jpeg();
128-
if (status != OS_SUCCESS) return OS_ERROR;
131+
result = CAM_jpeg();
132+
if (result != OS_SUCCESS) return OS_ERROR;
129133
OS_printf("JPEG success\n");
130134

131135
// Configure Camera for Size
132-
status = CAM_setup();
133-
if (status != OS_SUCCESS) return OS_ERROR;
136+
result = CAM_setup();
137+
if (result != OS_SUCCESS) return OS_ERROR;
134138
OS_printf("Configuration success\n");
135139

136140
// Upload Size
137-
status = CAM_setSize(size);
138-
if (status != OS_SUCCESS) return OS_ERROR;
141+
result = CAM_setSize(size);
142+
if (result != OS_SUCCESS) return OS_ERROR;
139143
OS_printf("Set size success\n");
140144

141145
// Prepare for Capture
142-
status = CAM_capture_prep();
143-
if (status != OS_SUCCESS) return OS_ERROR;
146+
result = CAM_capture_prep();
147+
if (result != OS_SUCCESS) return OS_ERROR;
144148
OS_printf("Capture prep success\n");
145149

146150
// Capture Image
147-
status = CAM_capture();
148-
if (status != OS_SUCCESS) return OS_ERROR;
151+
result = CAM_capture();
152+
if (result != OS_SUCCESS) return OS_ERROR;
149153
OS_printf("Capture success\n");
150154

151155
// Read FIFO Size
152-
status = CAM_read_fifo_length(&length);
153-
if (status != OS_SUCCESS) return OS_ERROR;
156+
result = CAM_read_fifo_length(&length);
157+
if (result != OS_SUCCESS) return OS_ERROR;
154158
OS_printf("Read fifo length success\n");
155159

156160
// Prepare for FIFO Read
157-
status = CAM_read_prep((char*) &data, (uint16_t*) &x);
158-
if (status != OS_SUCCESS) return OS_ERROR;
161+
result = CAM_read_prep((char*) &data, (uint16_t*) &x);
162+
if (result != OS_SUCCESS) return OS_ERROR;
159163
OS_printf("Read prep success\n");
160164

161165
//// Read FIFO
162-
FILE *expFile;
163-
expFile = fopen("exp.jpg", "wb");
164-
165-
if(expFile == NULL)
166+
while( (status > 0) && (status <= 8) )
166167
{
167-
OS_printf("Error opening file!\n");
168-
status = OS_ERROR;
169-
}
170168

171-
status = CAM_read((char*) &data, (uint16_t*) &x, (uint8_t*) &status);
169+
read_result = CAM_read((char*) &data, (uint16_t*) &x, (uint8_t*) &status);
170+
171+
if (read_result != OS_SUCCESS)
172+
{
173+
OS_printf("CAM read error");
174+
}
175+
if (read_result != OS_SUCCESS) break;
176+
x = 0;
177+
178+
OS_TaskDelay(250);
179+
}
172180

173-
fwrite(data, x, 1, expFile);
174-
fclose(expFile);
175181
if (status != OS_SUCCESS) return OS_ERROR;
176182
OS_printf("FIFO success\n");
183+
break;
184+
}
185+
177186

178187
return OS_SUCCESS;
179188
}

fsw/standalone/device_cfg.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,5 +19,6 @@
1919
//#define OV2640
2020
#define OV5640
2121
//#define OV5642
22+
#define FILE_MODE
2223

2324
#endif /* _ARDUCAM_CHECKOUT_DEVICE_CFG_H_ */

0 commit comments

Comments
 (0)