Skip to content

Commit 8a47c3e

Browse files
committed
[nasa/nos3#465] Commands working
1 parent 3dea7ab commit 8a47c3e

File tree

5 files changed

+58
-48
lines changed

5 files changed

+58
-48
lines changed

fsw/shared/generic_imu_device.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,14 @@ void GENERIC_IMU_FramePrep(can_info_t *device, uint8_t* data, uint8_t data_len)
2525
/* TX Frame */
2626
device->tx_frame.can_id = GENERIC_IMU_CFG_CAN_ID;
2727
device->tx_frame.can_dlc = data_len;
28-
CFE_PSP_MemCpy((void*)device->tx_frame.data, data, CAN_MAX_DLEN);
28+
// CFE_PSP_MemCpy((void*)device->tx_frame.data, data, CAN_MAX_DLEN);
29+
memcpy((void*)device->tx_frame.data, data, CAN_MAX_DLEN);
2930

3031
/* RX Frame */
3132
device->rx_frame.can_id = GENERIC_IMU_CFG_CAN_ID;
3233
device->rx_frame.can_dlc = 0;
33-
CFE_PSP_MemSet((void*)device->rx_frame.data, 0x00, CAN_MAX_DLEN);
34+
// CFE_PSP_MemSet((void*)device->rx_frame.data, 0x00, CAN_MAX_DLEN);
35+
memset((void*)device->rx_frame.data, 0x00, CAN_MAX_DLEN);
3436
}
3537

3638
/*

fsw/shared/generic_imu_device.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ typedef struct
4848
*/
4949
typedef struct
5050
{
51-
uint8_t CmdHeader[sizeof(CFE_MSG_CommandHeader_t)];
51+
// uint8_t CmdHeader[sizeof(CFE_MSG_CommandHeader_t)];
5252
uint8_t msg_type;
5353
uint8_t cmd_id;
5454
uint8_t src_mask;

fsw/standalone/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ endif()
2626

2727
include_directories("./")
2828
include_directories("../cfs/platform_inc")
29-
include_directories("../cfs/src")
29+
include_directories("../standalone")
3030
include_directories("../shared")
3131
include_directories("../../../../fsw/apps/hwlib/fsw/public_inc")
3232

fsw/standalone/device_cfg.h

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,17 @@
66
*/
77
#define GENERIC_imu_CFG
88
/* Note: NOS3 uart requires matching handle and bus number */
9-
#define GENERIC_imu_CFG_STRING "/dev/usart_16"
10-
#define GENERIC_imu_CFG_HANDLE 16
11-
#define GENERIC_imu_CFG_BAUDRATE_HZ 115200
12-
#define GENERIC_imu_CFG_MS_TIMEOUT 250
9+
#define GENERIC_IMU_CFG_STRING "/dev/usart_16"
10+
#define GENERIC_IMU_CFG_HANDLE 0
11+
#define GENERIC_IMU_CFG_CAN_ID 15
12+
#define GENERIC_IMU_CFG_BAUDRATE_HZ 115200
13+
#define GENERIC_IMU_CFG_MS_TIMEOUT 50 /* Max 255 */
14+
15+
#define GENERIC_IMU_CFG_CAN_BITRATE 1000000
16+
#define GENERIC_IMU_CFG_CAN_TIMEOUT 1
17+
#define GENERIC_IMU_CFG_CAN_MS_TIMEOUT 100
18+
#define GENERIC_IMU_CFG_CAN_XFER_US 5000
19+
#define GENERIC_IMU_CFG_RETRY_ATTEMPTS 3
1320
#define GENERIC_imu_CFG_DEBUG
1421

1522
#endif /* _GENERIC_imu_CHECKOUT_DEVICE_CFG_H_ */

fsw/standalone/generic_imu_checkout.c

Lines changed: 41 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*******************************************************************************
2-
** File: generic_imu_checkout.c
2+
** File: generic_IMU_checkout.c
33
**
44
** Purpose:
55
** This checkout can be run without cFS and is used to quickly develop and
@@ -10,14 +10,14 @@
1010
/*
1111
** Include Files
1212
*/
13-
#include "generic_imu_checkout.h"
13+
#include "generic_IMU_checkout.h"
1414

1515
/*
1616
** Global Variables
1717
*/
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;
2121

2222
/*
2323
** Component Functions
@@ -32,7 +32,7 @@ void print_help(void)
3232
" n - ^ \n"
3333
"hk - Request device housekeeping \n"
3434
" h - ^ \n"
35-
"generic_imu - Request generic_imu data \n"
35+
"generic_IMU - Request generic_IMU data \n"
3636
" s - ^ \n"
3737
"cfg # - Send configuration # \n"
3838
" c # - ^ \n"
@@ -74,7 +74,7 @@ int get_command(const char* str)
7474
{
7575
status = CMD_HK;
7676
}
77-
else if(strcmp(lcmd, "generic_imu") == 0)
77+
else if(strcmp(lcmd, "generic_IMU") == 0)
7878
{
7979
status = CMD_GENERIC_imu;
8080
}
@@ -114,7 +114,7 @@ int process_command(int cc, int num_tokens, char tokens[MAX_INPUT_TOKENS][MAX_IN
114114
case CMD_NOOP:
115115
if (check_number_arguments(num_tokens, 0) == OS_SUCCESS)
116116
{
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);
118118
if (status == OS_SUCCESS)
119119
{
120120
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
129129
case CMD_HK:
130130
if (check_number_arguments(num_tokens, 0) == OS_SUCCESS)
131131
{
132-
status = GENERIC_imu_RequestHK(&Generic_imuUart, &Generic_imuHK);
132+
status = GENERIC_IMU_RequestHK(&Generic_IMUcan, &Generic_IMUHK);
133133
if (status == OS_SUCCESS)
134134
{
135-
OS_printf("GENERIC_imu_RequestHK command success\n");
135+
OS_printf("GENERIC_IMU_RequestHK command success\n");
136136
}
137137
else
138138
{
139-
OS_printf("GENERIC_imu_RequestHK command failed!\n");
139+
OS_printf("GENERIC_IMU_RequestHK command failed!\n");
140140
}
141141
}
142142
break;
143143

144144
case CMD_GENERIC_imu:
145145
if (check_number_arguments(num_tokens, 0) == OS_SUCCESS)
146146
{
147-
status = GENERIC_imu_RequestData(&Generic_imuUart, &Generic_imuData);
147+
status = GENERIC_IMU_RequestData(&Generic_IMUcan, &Generic_IMUData);
148148
if (status == OS_SUCCESS)
149149
{
150-
OS_printf("GENERIC_imu_RequestData command success\n");
150+
OS_printf("GENERIC_IMU_RequestData command success\n");
151151
}
152152
else
153153
{
154-
OS_printf("GENERIC_imu_RequestData command failed!\n");
154+
OS_printf("GENERIC_IMU_RequestData command failed!\n");
155155
}
156156
}
157157
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-
175158
default:
176159
OS_printf("Invalid command format, type 'help' for more info\n");
177160
break;
@@ -196,18 +179,36 @@ int main(int argc, char *argv[])
196179
#endif
197180

198181
/* 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+
204205
if (status == OS_SUCCESS)
205206
{
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);
207208
}
208209
else
209210
{
210-
printf("UART device %s failed to initialize! \n", Generic_imuUart.deviceString);
211+
OS_printf("GENERIC_IMU: CAN port initialization success %d", status);
211212
run_status = OS_ERROR;
212213
}
213214

@@ -248,13 +249,13 @@ int main(int argc, char *argv[])
248249
}
249250

250251
// Close the device
251-
uart_close_port(&Generic_imuUart);
252+
can_close_device(&Generic_IMUcan);
252253

253254
#ifdef _NOS_ENGINE_LINK_
254255
nos_destroy_link();
255256
#endif
256257

257-
OS_printf("Cleanly exiting generic_imu application...\n\n");
258+
OS_printf("Cleanly exiting generic_IMU application...\n\n");
258259
return 1;
259260
}
260261

0 commit comments

Comments
 (0)