Skip to content

Commit

Permalink
Merge pull request #421 from FPRIME/devel
Browse files Browse the repository at this point in the history
mstarch: merging in release 1.3.1
  • Loading branch information
LeStarch authored and GitHub Enterprise committed Jan 24, 2020
2 parents 7a5d927 + 0a9ac14 commit b2ef756
Show file tree
Hide file tree
Showing 73 changed files with 6,425 additions and 2,670 deletions.
6 changes: 4 additions & 2 deletions Autocoders/Python/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -132,8 +132,10 @@ Directory containing all unit tests invoked by the cmake system. List of working
### CMakeLists.txt
Cmake file that is present in all parts of directory tree to be built by cmake. If cmake was invoked with type testing, templates and test get built. The src directory is always built as well.

### requirements.txt
Up-to-date requirements file for using the autocoder with either Python2 and Python3. It can be run using "pip install -r ./requirements.txt"
### Requirements

The Autocoder's requirements are covered by installing the F´ software package. This is is covered by the install document
found at: [INSTALL.md](../../INSTALL.md).

## Schematron
In Autocoders/Python/schema/default there are various schematron .rng files mixed with the normal F Prime RelaxNG .rng schema files. The schematron files validate xml in the same way as the RelaxNG schemas (within the XmlParser classes), but these schematron files will only generate command line errors, not exceptions like the schema files will. Here is a short description of each file:
Expand Down
9 changes: 9 additions & 0 deletions CONTRIBUTORS.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,17 @@ JPL Contributors to the F' Software Framework:
* Catchen, Michael
* Chase, Matthew
* Chen, Victor
* Daruwala, Rohan
* Daugherty, Daniel
* Day, Leonard
* Dinkel, Jack
* Dinkel, Kevin
* Gandhi, Gorang
* Gangianpour, Mehran
* Harriman, Blake
* Hofman, James
* Huynh, Thomas
* Ishii, Jordan
* Kaye, Warren
* Kooi, David
* Klemm, Roger
Expand All @@ -25,6 +28,7 @@ JPL Contributors to the F' Software Framework:
* Merewether, Eugene
* Nicolich, Eric
* Nowicki, Robert
* Oran, Kevin
* Ortega, Kevin
* Pandian, Prashanth
* Ramanan, Saikiran
Expand All @@ -41,3 +45,8 @@ JPL Contributors to the F' Software Framework:
* Wang, Eric
* Whitaker, William
* Wong, Vincent

Non-JPL Contributors to the F' Software Framework:
* acxz
* jasonduley
* keck-in-space
13 changes: 12 additions & 1 deletion Drv/LinuxSerialDriver/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ if(${CMAKE_SYSTEM_NAME} STREQUAL "Darwin")
set(SOURCE_FILES
"${CMAKE_CURRENT_LIST_DIR}/LinuxSerialDriverComponentAi.xml"
"${CMAKE_CURRENT_LIST_DIR}/LinuxSerialDriverComponentImplCommon.cpp"
"${CMAKE_CURRENT_LIST_DIR}/LinuxSerialDriverComponentImplStub.cpp"
"${CMAKE_CURRENT_LIST_DIR}/LinuxSerialDriverComponentImpl.cpp"
)
elseif(${CMAKE_SYSTEM_NAME} STREQUAL "Linux")
set(SOURCE_FILES
Expand Down Expand Up @@ -39,3 +39,14 @@ else()
endif()

register_fprime_module()

### UTs ###
set(UT_MOD_DEPS
Os
)
set(UT_SOURCE_FILES
"${CMAKE_CURRENT_LIST_DIR}/LinuxSerialDriverComponentAi.xml"
"${CMAKE_CURRENT_LIST_DIR}/test/ut/main.cpp"
"${CMAKE_CURRENT_LIST_DIR}/test/ut/Tester.cpp"
)
register_fprime_ut()
2 changes: 2 additions & 0 deletions Drv/LinuxSerialDriver/LinuxSerialDriverComponentImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -171,12 +171,14 @@ namespace Drv {
case BAUD_230K:
relayRate = B230400;
break;
#if defined TGT_OS_TYPE_LINUX
case BAUD_460K:
relayRate = B460800;
break;
case BAUD_921K:
relayRate = B921600;
break;
#endif
default:
FW_ASSERT(0,baud);
break;
Expand Down
17 changes: 17 additions & 0 deletions Drv/SocketIpDriver/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# This Makefile goes in each module, and allows building of an individual module library.
# It is expected that each developer will add targets of their own for building and running
# tests, for example.

# derive module name from directory

MODULE_DIR = Drv/SocketIpDriver
MODULE = $(subst /,,$(MODULE_DIR))

BUILD_ROOT ?= $(subst /$(MODULE_DIR),,$(CURDIR))
export BUILD_ROOT

include $(BUILD_ROOT)/mk/makefiles/module_targets.mk

# Add module specific targets here
load: ut_nocov_SDFLIGHT
adb push test/ut/linux-linaro-cross-arm-ut-nocov-gnu-bin/test_ut /home/linaro/gpio_test_ut
14 changes: 6 additions & 8 deletions Drv/SocketIpDriver/SocketIpDriverComponentImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -89,16 +89,15 @@ namespace Drv {

SocketIpDriverComponentImpl::SocketIpStatus SocketIpDriverComponentImpl :: open() {
SocketIpDriverComponentImpl::SocketIpStatus status = SocketIpDriverComponentImpl::SUCCESS;
// Only the input (TCP) socket needs closing
(void) close(m_socketInFd); // Close open sockets, to force a re-open
(void) close(m_socketOutFd);
m_socketInFd = -1;
m_socketOutFd = -1;
// Open a TCP socket for incoming commands, and outgoing data if not using UDP
if ((status = openProtocol(SOCK_STREAM)) != SocketIpDriverComponentImpl::SUCCESS) {
return status;
}
// If we need UDP sending, attempt to open UDP
if (m_send_udp && (status = openProtocol(SOCK_DGRAM, false)) != SocketIpDriverComponentImpl::SUCCESS) {
if (m_send_udp && m_socketOutFd == -1 && (status = openProtocol(SOCK_DGRAM, false)) != SocketIpDriverComponentImpl::SUCCESS) {
(void) close(m_socketInFd);
return status;
}
Expand Down Expand Up @@ -182,8 +181,9 @@ namespace Drv {
} else {
m_socketOutFd = socketFd;
}
Fw::Logger::logMsg("Connected to %s:%hu using %s\n", reinterpret_cast<POINTER_CAST>(m_hostname), m_port,
reinterpret_cast<POINTER_CAST>(m_send_udp ? "udp" : "tcp"));
Fw::Logger::logMsg("Connected to %s:%hu for %s using %s\n", reinterpret_cast<POINTER_CAST>(m_hostname), m_port,
reinterpret_cast<POINTER_CAST>(isInput ? "uplink" : "downlink"),
reinterpret_cast<POINTER_CAST>((protocol == SOCK_DGRAM) ? "udp" : "tcp"));
return SocketIpDriverComponentImpl::SUCCESS;
}

Expand All @@ -201,8 +201,8 @@ namespace Drv {
status = self->receive();
if (status != SocketIpDriverComponentImpl::SUCCESS &&
status != SocketIpDriverComponentImpl::INTERRUPTED_TRY_AGAIN) {
(void) close(self->m_socketInFd);
self->m_socketInFd = -1;
self->m_socketOutFd = -1;
}
}
}
Expand All @@ -227,8 +227,6 @@ namespace Drv {
}
// Zero bytes read means a closed socket
else if (recd == 0 || errno == ECONNRESET) {
(void) close(m_socketInFd);
m_socketInFd = -1;
status = READ_DISCONNECTED;
}
// Ignore KEEPALIVE data and send out any other data.
Expand Down
5 changes: 5 additions & 0 deletions Drv/SocketIpDriver/docs/SocketIpDriver.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<title>SocketIpDriver Component Dictionary</title>
# SocketIpDriver Component Dictionary



14 changes: 14 additions & 0 deletions Drv/SocketIpDriver/mod.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#
# Copyright 2004-2008, by the California Institute of Technology.
# ALL RIGHTS RESERVED. United States Government Sponsorship
# acknowledged.
#
#

SRC = SocketIpDriverComponentAi.xml SocketIpDriverComponentImpl.cpp

HDR = SocketIpDriverComponentImpl.hpp

SUBDIRS =


6 changes: 6 additions & 0 deletions Fw/Python/src/fprime/fbuild/cmake.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,10 @@ def __init__(self):
"""
self.build_cache = CMakeBuildCache()
self.verbose = False
try:
self._run_cmake(["--help"], capture=True)
except Exception as exc:
raise CMakeExecutionException("CMake executable 'cmake' not found", str(exc))

def set_verbose(self, verbose):
""" Sets verbosity """
Expand Down Expand Up @@ -228,6 +232,8 @@ def generate_build(self, source_dir, build_dir, args=None, ignore_output=False):
"""
if not os.path.exists(build_dir):
os.makedirs(build_dir)
# We will CD for build, so this path must become absolute
source_dir = os.path.abspath(source_dir)
args = {} if args is None else args
fleshed_args = map(lambda key: ("{}={}" if key.startswith("--") else "-D{}={}")
.format(key, args[key]), args.keys())
Expand Down
32 changes: 26 additions & 6 deletions Fw/Python/src/fprime/util/build_helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@

import fprime.fbuild


UT_SUFFIX = "-ut"
ACTION_MAP = {
"generate": {
Expand Down Expand Up @@ -90,7 +91,7 @@ def validate(parsed):
# Generation validation
elif parsed.build_dir is None:
build_inst_name = fprime.fbuild.cmake.CMakeHandler.CMAKE_DEFAULT_BUILD_NAME.format(parsed.platform)
parsed.build_dir = os.path.join(os.getcwd(), build_inst_name)
parsed.build_dir = os.path.join(parsed.path, build_inst_name)
except fprime.fbuild.cmake.CMakeProjectException as exc:
print("[ERROR] {}".format(exc))
sys.exit(1)
Expand Down Expand Up @@ -119,9 +120,11 @@ def validate(parsed):
if parsed.command == "generate":
# Look for default toolchains via FPRIME_DEFAULT_TOOLCHAIN_NAME
toolchain = parsed.platform
if parsed.platform == "default":
if toolchain == "default":
toolchain = fprime.fbuild.builder().get_fprime_configuration("FPRIME_DEFAULT_TOOLCHAIN_NAME",
cmake_dir=parsed.path)[0]
elif toolchain == "native":
toolchain = None
# Find locations of toolchain files, assuming a non-None toolchain is asked for
if toolchain is not None:
locations = fprime.fbuild.builder().get_include_locations(parsed.path)
Expand All @@ -130,7 +133,7 @@ def validate(parsed):
toolchains = list(filter(os.path.exists, toolchains_paths))
if not toolchains:
print("[ERROR] Toolchain file {} does not exist at any of {}"
.format(toolchains + ".cmake", ", ".join(list(toolchains_paths))))
.format(toolchain + ".cmake", ", ".join(list(toolchains_paths))))
sys.exit(-1)
print("[INFO] Using toolchain file {} for platform {}".format(toolchains[0], parsed.platform))
cmake_args.update({"CMAKE_TOOLCHAIN_FILE": toolchains[0]})
Expand Down Expand Up @@ -176,6 +179,12 @@ def parse_args(args):
hparser.add_argument("hash", type=lambda x: int(x, 0), help="F prime assert hash to associate with a file.")
hparser.add_argument("-t", "--unittest", default=False, action="store_true",
help="Use F prime ut build, not regular build")
# Check for a valid builder first
try:
fprime.fbuild.builder()
except Exception as exc:
print("[ERROR]", exc, exc.stderr, file=sys.stderr)
sys.exit()
# Parse and prepare to run
parsed = parser.parse_args(args)
if not hasattr(parsed, "command") or parsed.command is None:
Expand All @@ -193,7 +202,13 @@ def confirm():
"""
# Loop "forever"
while True:
confirm = input("Purge this directory (yes/no)?")
# Py 2/3
prompter = input
try:
prompter = raw_input
except NameError:
pass
confirm = prompter("Purge this directory (yes/no)?")
if confirm.lower() in ["y", "yes"]:
return True
elif confirm.lower() in ["n", "no"]:
Expand All @@ -205,8 +220,9 @@ def utility_entry(args=sys.argv[1:]):
Main interface to F prime utility.
:return: return code of the function.
"""
parsed, cmake_args, make_args, automatic_build_dir = parse_args(args)
parsed = None
try:
parsed, cmake_args, make_args, automatic_build_dir = parse_args(args)
if parsed.command == "hash-to-file":
suffix = UT_SUFFIX if parsed.unittest else ""
lines = fprime.fbuild.builder().find_hashed_file(parsed.build_dir + suffix, parsed.hash)
Expand Down Expand Up @@ -244,9 +260,13 @@ def utility_entry(args=sys.argv[1:]):
fprime.fbuild.builder().execute_known_target(action["target"], parsed.build_dir + action["build-suffix"],
parsed.path, cmake_args, make_args,
action.get("top-target", False))
except fprime.fbuild.cmake.CMakeExecutionException as exexc:
stderr = exexc.get_errors()
print("[ERROR] {}.{}".format(exexc,"\n{}".format(stderr) if stderr else ""), file=sys.stderr)
return 1
except fprime.fbuild.cmake.CMakeException as exc:
print("[ERROR] {}".format(exc), file=sys.stderr)
if parsed.command == "generate" and automatic_build_dir:
if parsed is not None and parsed.command == "generate" and automatic_build_dir:
print("[INFO] Cleaning automatic build directory at: {}".format(parsed.build_dir))
shutil.rmtree(parsed.build_dir, ignore_errors=True)
print("[INFO] Cleaning automatic unit-test build directory at: {}".format(parsed.build_dir + UT_SUFFIX))
Expand Down
1 change: 0 additions & 1 deletion Gds/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,6 @@
'multiprocess',
'Pmw',
'tkintertable==1.2',
'numpy',
'scipy',
'scimath',
'matplotlib'],
Expand Down
6 changes: 6 additions & 0 deletions Gds/src/fprime_gds/common/adapters/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,10 @@ def __init__(self, sender):
self.running_downlink = True
self.running_uplink = True

def open(self):
"""No implementation needed in base-case"""
pass

@classmethod
def set_constants(clazz):
"""
Expand Down Expand Up @@ -145,13 +149,15 @@ def run_uplink(self):
"""
Run the uplink side of the adapter.
"""
self.sender.open()
while self.running_uplink:
self.uplink()

def run_downlink(self):
"""
Run the downlink of the adapter.
"""
self.open()
while self.running_downlink:
self.downlink()

Expand Down
Loading

0 comments on commit b2ef756

Please sign in to comment.