1
1
/*******************************************************************************
2
- ** File: generic_imu_checkout .c
2
+ ** File: generic_IMU_checkout .c
3
3
**
4
4
** Purpose:
5
5
** This checkout can be run without cFS and is used to quickly develop and
10
10
/*
11
11
** Include Files
12
12
*/
13
- #include "generic_imu_checkout .h"
13
+ #include "generic_IMU_checkout .h"
14
14
15
15
/*
16
16
** Global Variables
17
17
*/
18
- uart_info_t Generic_imuUart ;
19
- GENERIC_imu_Device_HK_tlm_t Generic_imuHK ;
20
- GENERIC_imu_Device_Data_tlm_t Generic_imuData ;
18
+ can_info_t Generic_IMUcan ;
19
+ GENERIC_IMU_Device_HK_tlm_t Generic_IMUHK ;
20
+ GENERIC_IMU_Device_Data_tlm_t Generic_IMUData ;
21
21
22
22
/*
23
23
** Component Functions
@@ -32,7 +32,7 @@ void print_help(void)
32
32
" n - ^ \n"
33
33
"hk - Request device housekeeping \n"
34
34
" h - ^ \n"
35
- "generic_imu - Request generic_imu data \n"
35
+ "generic_IMU - Request generic_IMU data \n"
36
36
" s - ^ \n"
37
37
"cfg # - Send configuration # \n"
38
38
" c # - ^ \n"
@@ -74,7 +74,7 @@ int get_command(const char* str)
74
74
{
75
75
status = CMD_HK ;
76
76
}
77
- else if (strcmp (lcmd , "generic_imu " ) == 0 )
77
+ else if (strcmp (lcmd , "generic_IMU " ) == 0 )
78
78
{
79
79
status = CMD_GENERIC_imu ;
80
80
}
@@ -114,7 +114,7 @@ int process_command(int cc, int num_tokens, char tokens[MAX_INPUT_TOKENS][MAX_IN
114
114
case CMD_NOOP :
115
115
if (check_number_arguments (num_tokens , 0 ) == OS_SUCCESS )
116
116
{
117
- status = GENERIC_imu_CommandDevice ( & Generic_imuUart , GENERIC_imu_DEVICE_NOOP_CMD , 0 );
117
+ status = GENERIC_IMU_CommandDevice ( & Generic_IMUcan , GENERIC_IMU_DEVICE_NOOP_CMD );
118
118
if (status == OS_SUCCESS )
119
119
{
120
120
OS_printf ("NOOP command success\n" );
@@ -129,49 +129,32 @@ int process_command(int cc, int num_tokens, char tokens[MAX_INPUT_TOKENS][MAX_IN
129
129
case CMD_HK :
130
130
if (check_number_arguments (num_tokens , 0 ) == OS_SUCCESS )
131
131
{
132
- status = GENERIC_imu_RequestHK ( & Generic_imuUart , & Generic_imuHK );
132
+ status = GENERIC_IMU_RequestHK ( & Generic_IMUcan , & Generic_IMUHK );
133
133
if (status == OS_SUCCESS )
134
134
{
135
- OS_printf ("GENERIC_imu_RequestHK command success\n" );
135
+ OS_printf ("GENERIC_IMU_RequestHK command success\n" );
136
136
}
137
137
else
138
138
{
139
- OS_printf ("GENERIC_imu_RequestHK command failed!\n" );
139
+ OS_printf ("GENERIC_IMU_RequestHK command failed!\n" );
140
140
}
141
141
}
142
142
break ;
143
143
144
144
case CMD_GENERIC_imu :
145
145
if (check_number_arguments (num_tokens , 0 ) == OS_SUCCESS )
146
146
{
147
- status = GENERIC_imu_RequestData ( & Generic_imuUart , & Generic_imuData );
147
+ status = GENERIC_IMU_RequestData ( & Generic_IMUcan , & Generic_IMUData );
148
148
if (status == OS_SUCCESS )
149
149
{
150
- OS_printf ("GENERIC_imu_RequestData command success\n" );
150
+ OS_printf ("GENERIC_IMU_RequestData command success\n" );
151
151
}
152
152
else
153
153
{
154
- OS_printf ("GENERIC_imu_RequestData command failed!\n" );
154
+ OS_printf ("GENERIC_IMU_RequestData command failed!\n" );
155
155
}
156
156
}
157
157
break ;
158
-
159
- case CMD_CFG :
160
- if (check_number_arguments (num_tokens , 1 ) == OS_SUCCESS )
161
- {
162
- config = atoi (tokens [0 ]);
163
- status = GENERIC_imu_CommandDevice (& Generic_imuUart , GENERIC_imu_DEVICE_CFG_CMD , config );
164
- if (status == OS_SUCCESS )
165
- {
166
- OS_printf ("Configuration command success with value %u\n" , config );
167
- }
168
- else
169
- {
170
- OS_printf ("Configuration command failed!\n" );
171
- }
172
- }
173
- break ;
174
-
175
158
default :
176
159
OS_printf ("Invalid command format, type 'help' for more info\n" );
177
160
break ;
@@ -196,18 +179,36 @@ int main(int argc, char *argv[])
196
179
#endif
197
180
198
181
/* Open device specific protocols */
199
- Generic_imuUart .deviceString = GENERIC_imu_CFG_STRING ;
200
- Generic_imuUart .handle = GENERIC_imu_CFG_HANDLE ;
201
- Generic_imuUart .isOpen = PORT_CLOSED ;
202
- Generic_imuUart .baud = GENERIC_imu_CFG_BAUDRATE_HZ ;
203
- status = uart_init_port (& Generic_imuUart );
182
+ Generic_IMUcan .handle = GENERIC_IMU_CFG_HANDLE ;
183
+ Generic_IMUcan .isUp = CAN_INTERFACE_DOWN ;
184
+ Generic_IMUcan .loopback = false;
185
+ Generic_IMUcan .listenOnly = false;
186
+ Generic_IMUcan .tripleSampling = false;
187
+ Generic_IMUcan .oneShot = false;
188
+ Generic_IMUcan .berrReporting = false;
189
+ Generic_IMUcan .fd = false;
190
+ Generic_IMUcan .presumeAck = false;
191
+ Generic_IMUcan .bitrate = GENERIC_IMU_CFG_CAN_BITRATE ;
192
+ Generic_IMUcan .second_timeout = GENERIC_IMU_CFG_CAN_TIMEOUT ;
193
+ Generic_IMUcan .microsecond_timeout = GENERIC_IMU_CFG_CAN_MS_TIMEOUT ;
194
+ Generic_IMUcan .xfer_us_delay = GENERIC_IMU_CFG_CAN_XFER_US ;
195
+
196
+ status = can_init_dev (& Generic_IMUcan );
197
+
198
+
199
+
200
+ // Generic_IMUcan.deviceString = GENERIC_IMU_CFG_STRING;
201
+ // Generic_IMUcan.handle = GENERIC_IMU_CFG_HANDLE;
202
+ // Generic_IMUcan.isOpen = PORT_CLOSED;
203
+ // Generic_IMUcan.baud = GENERIC_IMU_CFG_BAUDRATE_HZ;
204
+
204
205
if (status == OS_SUCCESS )
205
206
{
206
- printf ( "UART device %s configured with baudrate %d \n " , Generic_imuUart . deviceString , Generic_imuUart . baud );
207
+ OS_printf ( "GENERIC_IMU: CAN port initialization success %d " , status );
207
208
}
208
209
else
209
210
{
210
- printf ( "UART device %s failed to initialize! \n " , Generic_imuUart . deviceString );
211
+ OS_printf ( "GENERIC_IMU: CAN port initialization success %d " , status );
211
212
run_status = OS_ERROR ;
212
213
}
213
214
@@ -248,13 +249,13 @@ int main(int argc, char *argv[])
248
249
}
249
250
250
251
// Close the device
251
- uart_close_port ( & Generic_imuUart );
252
+ can_close_device ( & Generic_IMUcan );
252
253
253
254
#ifdef _NOS_ENGINE_LINK_
254
255
nos_destroy_link ();
255
256
#endif
256
257
257
- OS_printf ("Cleanly exiting generic_imu application...\n\n" );
258
+ OS_printf ("Cleanly exiting generic_IMU application...\n\n" );
258
259
return 1 ;
259
260
}
260
261
0 commit comments