-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #9 from nasa-itc/nos3#381-rw-checkout-application
[nasa/nos3#381] generic_reaction_wheel checkout
- Loading branch information
Showing
12 changed files
with
612 additions
and
64 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
fsw/standalone/build/* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
62 changes: 62 additions & 0 deletions
62
fsw/cfs/platform_inc/generic_reaction_wheel_platform_cfg.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
/************************************************************************ | ||
** File: | ||
** $Id: generic_reaction_wheel_platform_cfg.h $ | ||
** | ||
** Purpose: | ||
** Define generic_reaction_wheel Platform Configuration Parameters | ||
** | ||
** Notes: | ||
** | ||
*************************************************************************/ | ||
#ifndef _GENERIC_REACTION_WHEEL_PLATFORM_CFG_H_ | ||
#define _GENERIC_REACTION_WHEEL_PLATFORM_CFG_H_ | ||
|
||
/* | ||
** Default GENERIC_REACTION_WHEEL_1 Configuration | ||
*/ | ||
#ifndef GENERIC_REACTION_WHEEL_1_CFG | ||
/* Notes: | ||
** NOS3 uart requires matching handle and bus number | ||
*/ | ||
#define GENERIC_REACTION_WHEEL_1_CFG_STRING "/dev/tty2" | ||
#define GENERIC_REACTION_WHEEL_1_CFG_HANDLE 2 | ||
#define GENERIC_REACTION_WHEEL_1_CFG_IS_OPEN PORT_CLOSED | ||
#define GENERIC_REACTION_WHEEL_1_CFG_BAUDRATE_HZ 115200 | ||
#define GENERIC_REACTION_WHEEL_1_CFG_MS_TIMEOUT 50 /* Max 255 */ | ||
/* Note: Debug flag disabled (commented out) by default */ | ||
//#define GENERIC_REACTION_WHEEL_1_CFG_DEBUG | ||
#endif | ||
|
||
/* | ||
** Default GENERIC_REACTION_WHEEL_2 Configuration | ||
*/ | ||
#ifndef GENERIC_REACTION_WHEEL_2_CFG | ||
/* Notes: | ||
** NOS3 uart requires matching handle and bus number | ||
*/ | ||
#define GENERIC_REACTION_WHEEL_2_CFG_STRING "/dev/tty3" | ||
#define GENERIC_REACTION_WHEEL_2_CFG_HANDLE 3 | ||
#define GENERIC_REACTION_WHEEL_2_CFG_IS_OPEN PORT_CLOSED | ||
#define GENERIC_REACTION_WHEEL_2_CFG_BAUDRATE_HZ 115200 | ||
#define GENERIC_REACTION_WHEEL_2_CFG_MS_TIMEOUT 50 /* Max 255 */ | ||
/* Note: Debug flag disabled (commented out) by default */ | ||
//#define GENERIC_REACTION_WHEEL_2_CFG_DEBUG | ||
#endif | ||
|
||
/* | ||
** Default GENERIC_REACTION_WHEEL_3 Configuration | ||
*/ | ||
#ifndef GENERIC_REACTION_WHEEL_3_CFG | ||
/* Notes: | ||
** NOS3 uart requires matching handle and bus number | ||
*/ | ||
#define GENERIC_REACTION_WHEEL_3_CFG_STRING "/dev/tty4" | ||
#define GENERIC_REACTION_WHEEL_3_CFG_HANDLE 4 | ||
#define GENERIC_REACTION_WHEEL_3_CFG_IS_OPEN PORT_CLOSED | ||
#define GENERIC_REACTION_WHEEL_3_CFG_BAUDRATE_HZ 115200 | ||
#define GENERIC_REACTION_WHEEL_3_CFG_MS_TIMEOUT 50 /* Max 255 */ | ||
/* Note: Debug flag disabled (commented out) by default */ | ||
//#define GENERIC_REACTION_WHEEL_3_CFG_DEBUG | ||
#endif | ||
|
||
#endif /* _GENERIC_REACTION_WHEEL_PLATFORM_CFG_H_ */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
/******************************************************************************* | ||
** File: generic_reaction_wheel_device.c | ||
** | ||
** Purpose: | ||
** This file contains the source code for the GENERIC_REACTION_WHEEL device. | ||
** | ||
*******************************************************************************/ | ||
|
||
/* | ||
** Include Files | ||
*/ | ||
#include "generic_reaction_wheel_device.h" | ||
|
||
/************************************************************************ | ||
** Get current momentum data from the UART | ||
*************************************************************************/ | ||
int32_t GetCurrentMomentum(uart_info_t *wheel, double *momentum) | ||
{ | ||
uint8_t DataBuffer[1024]; | ||
int32_t DataLen; | ||
char *reply; | ||
|
||
char *request = "CURRENT_MOMENTUM"; | ||
int32_t status = uart_write_port(wheel, (uint8_t*)request, strlen(request)); | ||
if (status < 0) { | ||
OS_printf("GetCurrentMomentum: Error writing to UART=%d\n", status); | ||
} | ||
/* check how many bytes are waiting on the uart */ | ||
DataLen = uart_bytes_available(wheel); | ||
if (DataLen > 0) | ||
{ | ||
/* grab the bytes */ | ||
status = uart_read_port(wheel, DataBuffer, DataLen); | ||
if (status < 0) { | ||
OS_printf("GetCurrentMomentum: Error reading from UART=%d\n", status); | ||
} else { | ||
DataBuffer[DataLen] = 0; // Ensure null termination | ||
reply = (char *)DataBuffer; | ||
if (strncmp(reply, "CURRENT_MOMENTUM=", 17) == 0) { | ||
*momentum = atof(&reply[17]); | ||
} else { | ||
status = 0; | ||
} | ||
} | ||
} | ||
|
||
return status; | ||
} | ||
|
||
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * **/ | ||
/* */ | ||
/* SetRWTorque(); */ | ||
/* */ | ||
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * **/ | ||
int32_t SetRWTorque( uart_info_t *wheel, double torque ) | ||
{ | ||
int32_t status; | ||
char request[22]; | ||
|
||
sprintf(request, "SET_TORQUE=%10.4f", torque); | ||
status = uart_write_port(wheel, (uint8_t*)request, strlen(request)); | ||
//OS_printf("Generic Reaction Wheel: Sending command:%s\n", request); | ||
if (status < 0) { | ||
OS_printf("Generic Reaction Wheel: Error writing to UART=%d\n", status); | ||
} else { | ||
/* Read the reply */ | ||
uint8_t DataBuffer[1024]; | ||
int32_t DataLen; | ||
/* check how many bytes are waiting on the uart */ | ||
DataLen = uart_bytes_available(wheel); | ||
if (DataLen > 0) | ||
{ | ||
uart_read_port(wheel, DataBuffer, DataLen); | ||
DataBuffer[DataLen] = 0; // Ensure null termination | ||
//OS_printf("Generic Reaction Wheel: Response on UART=%s\n", (char *)DataBuffer); | ||
} | ||
} | ||
|
||
return status; | ||
} /* End of SetRWTorque */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
/******************************************************************************* | ||
** File: generic_reaction_wheel_device.h | ||
** | ||
** Purpose: | ||
** This is the header file for the GENERIC_REACTION_WHEEL device. | ||
** | ||
*******************************************************************************/ | ||
#ifndef _GENERIC_REACTION_WHEEL_DEVICE_H_ | ||
#define _GENERIC_REACTION_WHEEL_DEVICE_H_ | ||
|
||
/* | ||
** Required header files. | ||
*/ | ||
#include "device_cfg.h" | ||
#include "hwlib.h" | ||
#include "generic_reaction_wheel_platform_cfg.h" | ||
|
||
/* Forward declarations */ | ||
int32_t GetCurrentMomentum(uart_info_t *wheel, double *momentum); | ||
int32_t SetRWTorque(uart_info_t *wheel, double torque); | ||
|
||
#endif /* _SAMPLE_DEVICE_H_ */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
cmake_minimum_required(VERSION 2.6.4) | ||
|
||
project (generic_reaction_wheel_checkout) | ||
|
||
if (NOT DEFINED TGTNAME) | ||
message(FATAL_ERROR "TGTNAME must be defined on the cmake command line (e.g. \"-DTGTNAME=cpu1\")") | ||
endif() | ||
|
||
include(../../../ComponentSettings.cmake) | ||
|
||
if(${TGTNAME} STREQUAL cpu1) | ||
find_path(_ITC_CMAKE_MODULES_ | ||
NAMES FindITC_Common.cmake | ||
PATHS ${ITC_CMAKE_MODULES} | ||
${ITC_DEV_ROOT}/cmake/modules | ||
$ENV{ITC_DEV_ROOT}/cmake/modules | ||
/usr/local/cmake/modules | ||
/usr/cmake/modules) | ||
if(NOT _ITC_CMAKE_MODULES_) | ||
message(WARNING "Unable to find ITC CMake Modules") | ||
endif() | ||
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${_ITC_CMAKE_MODULES_}) | ||
|
||
find_package(NOSENGINE REQUIRED QUIET COMPONENTS common transport client uart can i2c spi) | ||
endif() | ||
|
||
include_directories("./") | ||
include_directories("../cfs/platform_inc") | ||
include_directories("../cfs/src") | ||
include_directories("../shared") | ||
include_directories("../../../../fsw/apps/hwlib/fsw/public_inc") | ||
|
||
set(generic_reaction_wheel_checkout_src | ||
generic_reaction_wheel_checkout.c | ||
../shared/generic_reaction_wheel_device.c | ||
) | ||
|
||
if(${TGTNAME} STREQUAL cpu1) | ||
include_directories("../../../../fsw/apps/hwlib/sim/inc") | ||
set(generic_reaction_wheel_checkout_src | ||
${generic_reaction_wheel_checkout_src} | ||
../../../../fsw/apps/hwlib/sim/src/libuart.c | ||
../../../../fsw/apps/hwlib/sim/src/libcan.c | ||
../../../../fsw/apps/hwlib/sim/src/libi2c.c | ||
../../../../fsw/apps/hwlib/sim/src/libspi.c | ||
../../../../fsw/apps/hwlib/sim/src/nos_link.c | ||
) | ||
set(generic_reaction_wheel_checkout_libs | ||
${ITC_Common_LIBRARIES} | ||
${NOSENGINE_LIBRARIES} | ||
) | ||
endif() | ||
if(${TGTNAME} STREQUAL cpu2) | ||
set(generic_reaction_wheel_checkout_src | ||
${generic_reaction_wheel_checkout_src} | ||
../../../../fsw/apps/hwlib/fsw/linux/libuart.c | ||
) | ||
endif() | ||
|
||
add_executable(generic_reaction_wheel_checkout ${generic_reaction_wheel_checkout_src}) | ||
target_link_libraries(generic_reaction_wheel_checkout ${generic_reaction_wheel_checkout_libs}) | ||
|
||
if(${TGTNAME} STREQUAL cpu1) | ||
set_target_properties(generic_reaction_wheel_checkout PROPERTIES COMPILE_FLAGS "-g" LINK_FLAGS "-g") | ||
endif() |
Oops, something went wrong.