Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/devel' into fpp-component-inte…
Browse files Browse the repository at this point in the history
…gration
  • Loading branch information
bocchino committed Aug 1, 2023
2 parents 94dea07 + 92c9f07 commit 596087d
Show file tree
Hide file tree
Showing 97 changed files with 661 additions and 7,564 deletions.
11 changes: 10 additions & 1 deletion .github/actions/spelling/expect.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
Aadil
aarch
abcd
ABCDE
ABCDEF
Expand Down Expand Up @@ -102,6 +103,7 @@ bfree
bibtex
Bies
bindir
binrel
Bitfields
bitmaps
bitset
Expand Down Expand Up @@ -392,6 +394,8 @@ dumpobj
DVI
DWN
dylib
eabi
eabihf
EACCES
EAGAIN
eay
Expand Down Expand Up @@ -522,7 +526,7 @@ FPCONFIG
fpconfighpp
FPGA
fpi
fpl
FPL
fpp
fppi
FPport
Expand Down Expand Up @@ -602,6 +606,7 @@ Gnc
Gnd
gnd
GNUC
gnueabi
gnueabihf
google
googletest
Expand Down Expand Up @@ -766,6 +771,7 @@ kislyuk
kitware
Kooi
kthxbye
Kubernetes
Lammert
lammertbies
LASTLOG
Expand Down Expand Up @@ -914,6 +920,7 @@ namespaced
nano
nanosleep
nargs
nasafprime
nathan
nbits
ncsl
Expand Down Expand Up @@ -1150,6 +1157,7 @@ RAbrack
radd
RAII
Ramanan
rancherdesktop
randtbl
rapidscat
raspberrypi
Expand Down Expand Up @@ -1653,6 +1661,7 @@ WRONLY
wrs
Wshadow
Wsign
wsl
WSL
Wundef
www
Expand Down
8 changes: 7 additions & 1 deletion .github/actions/spelling/patterns.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@

# hit-count: 106 file-count: 28
# Compiler flags
(?:^|[\t ,"'`=(])-[DPWXYLlf](?=[A-Z]{2,}|[A-Z][a-z]|[a-z]{2,})
(?:^|[\t ,"'`=(])-(?:[DLP](?=[A-Z]{2,})|[WXYlf](?=[A-Z]{2,}|[A-Z][a-z]|[a-z]{2,}))

# http|ftp|file URLs
#(?:\b(?:https?|ftp|file)://)[-A-Za-z0-9+&@#/%?=~_|!:,.;]+[-A-Za-z0-9+&@#/%=~_|]

# hit-count: 48 file-count: 18
# GitHub SHAs (markdown)
Expand Down Expand Up @@ -123,3 +126,6 @@ GithubProjectProperty

# ignore long runs of a single character:
\b([A-Za-z])\g{-1}{3,}\b

# ignore docker platform paths
--platform=(linux|darwin)/(amd64|arm|arm32v5|arm32v6|arm32v7|arm64v8|i386|ppc64le|s390x|x86_64)
27 changes: 24 additions & 3 deletions Drv/LinuxSpiDriver/LinuxSpiDriverComponentImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,8 @@ namespace Drv {

bool LinuxSpiDriverComponentImpl::open(NATIVE_INT_TYPE device,
NATIVE_INT_TYPE select,
SpiFrequency clock) {
SpiFrequency clock,
SpiMode spiMode) {

this->m_device = device;
this->m_select = select;
Expand All @@ -97,9 +98,29 @@ namespace Drv {

// Configure:
/*
* SPI Mode 0
* SPI Mode 0, 1, 2, 3
*/
U8 mode = SPI_MODE_0; // Mode 0 (CPOL = 0, CPHA = 0)

U8 mode; // Mode Select (CPOL = 0/1, CPHA = 0/1)
switch(spiMode) {
case SpiMode::SPI_MODE_CPOL_LOW_CPHA_LOW:
mode = SPI_MODE_0;
break;
case SpiMode::SPI_MODE_CPOL_LOW_CPHA_HIGH:
mode = SPI_MODE_1;
break;
case SpiMode::SPI_MODE_CPOL_HIGH_CPHA_LOW:
mode = SPI_MODE_2;
break;
case SpiMode::SPI_MODE_CPOL_HIGH_CPHA_HIGH:
mode = SPI_MODE_3;
break;
default:
//Assert if the device SPI Mode is not in the correct range
FW_ASSERT(0, spiMode);
break;
}

ret = ioctl(fd, SPI_IOC_WR_MODE, &mode);
if (ret == -1) {
DEBUG_PRINT("ioctl SPI_IOC_WR_MODE fd %d failed. %d\n",fd,errno);
Expand Down
22 changes: 21 additions & 1 deletion Drv/LinuxSpiDriver/LinuxSpiDriverComponentImpl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,25 @@ namespace Drv {
SPI_FREQUENCY_20MHZ = 20000000UL,
};

/**
* SPI Mode Select
*
* Defines the SPI Clock Polarity and Phase for each SPI Transaction.
*
* SPI Clock Polarity(CPOL): Defines clock polarity as idle low (CPOL = 0) or idle high(CPOL = 1)
* SPI Clock Phase(CPHA): Defines if data is shifted out on the rising clock edge and sampled
* on the falling clock edge(CPHA = 0) or if data is shifted out on the
* falling clock edge and sampled on the rising clock edge(CPHA=1)
*
*/
enum SpiMode
{
SPI_MODE_CPOL_LOW_CPHA_LOW, ///< (CPOL = 0, CPHA = 0)
SPI_MODE_CPOL_LOW_CPHA_HIGH,///< (CPOL = 0, CPHA = 1)
SPI_MODE_CPOL_HIGH_CPHA_LOW,///< (CPOL = 1, CPHA = 0)
SPI_MODE_CPOL_HIGH_CPHA_HIGH,///< (CPOL = 1, CPHA = 1)
};

class LinuxSpiDriverComponentImpl: public LinuxSpiDriverComponentBase {

public:
Expand All @@ -59,7 +78,8 @@ namespace Drv {
//! Open device
bool open(NATIVE_INT_TYPE device,
NATIVE_INT_TYPE select,
SpiFrequency clock);
SpiFrequency clock,
SpiMode spiMode = SpiMode::SPI_MODE_CPOL_LOW_CPHA_LOW);

PRIVATE:

Expand Down
3 changes: 2 additions & 1 deletion Drv/LinuxSpiDriver/LinuxSpiDriverComponentImplStub.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ namespace Drv {

bool LinuxSpiDriverComponentImpl::open(NATIVE_INT_TYPE device,
NATIVE_INT_TYPE select,
SpiFrequency clock) {
SpiFrequency clock,
SpiMode spiMode) {
//TODO: fill this function out
return false;
}
Expand Down
12 changes: 10 additions & 2 deletions Fw/Buffer/Buffer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,15 @@ Buffer::Buffer(): Serializable(),
{}

Buffer::Buffer(const Buffer& src) : Serializable(),
m_serialize_repr(src.m_bufferData, src.m_size),
m_serialize_repr(),
m_bufferData(src.m_bufferData),
m_size(src.m_size),
m_context(src.m_context)
{}
{
if(src.m_bufferData != nullptr){
this->m_serialize_repr.setExtBuffer(src.m_bufferData, src.m_size);
}
}

Buffer::Buffer(U8* data, U32 size, U32 context) : Serializable(),
m_serialize_repr(),
Expand All @@ -57,6 +61,10 @@ bool Buffer::operator==(const Buffer& src) const {
return (this->m_bufferData == src.m_bufferData) && (this->m_size == src.m_size) && (this->m_context == src.m_context);
}

bool Buffer::isValid() const {
return (this->m_bufferData != nullptr) && (this->m_size > 0);
}

U8* Buffer::getData() const {
return this->m_bufferData;
}
Expand Down
4 changes: 4 additions & 0 deletions Fw/Buffer/Buffer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,10 @@ class Buffer : public Fw::Serializable {
// Accessor functions
// ----------------------------------------------------------------------

//! Returns true if the buffer is valid (data pointer != nullptr and size > 0)
//!
bool isValid() const;

//! Returns wrapped data pointer
//!
U8* getData() const;
Expand Down
26 changes: 18 additions & 8 deletions Fw/Buffer/docs/sdd.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
This module provides the following elements:

* A type `Fw::Buffer` representing a wrapper around a variable-size buffer. This allows for passing a reference to the
allocated memory around without a copy. Typically the memory is allocated in a buffer manager or similar component but
allocated memory around without a copy. Typically the memory is allocated in a buffer manager or similar component but
this is not required.
* A port `Fw::BufferGet` for requesting a buffer of type `Fw::Buffer` from
a [`BufferManager`](../../../Svc/BufferManager/docs/sdd.md) and similar components.
Expand All @@ -30,8 +30,14 @@ Name | Type | Accessors | Purpose
`m_context` | `U32` | `getContext()`/`setContext()` | Context of buffer's origin. Used to track buffers created by [`BufferManager`](../../../Svc/BufferManager/docs/sdd.md)
`m_serialize_repr` | `Fw::ExternalSerializeBuffer` | `getSerializeRepr()` | Interface for serialization to internal buffer

If the size of the data is set to 0, the pointer returned by `getData()` and the serialization interface returned by
`getSerializeRepr()` are considered invalid and should not be used.
A value _B_ of type `Fw::Buffer` is **valid** if `m_bufferData != nullptr` and
`m_size > 0`; otherwise it is **invalid**.
The interface function `isValid` reports whether a buffer is valid.
Calling this function on a buffer _B_ returns `true` if _B_ is valid, otherwise `false`.

If a buffer _B_ is invalid, then the pointer returned by _B_ `.getData()` and the
serialization interface returned by
_B_ `.getSerializeRepr()` are considered invalid and should not be used.

The `getSerializeRepr()` function may be used to interact with the wrapped data buffer by serializing types to and from
the data region.
Expand All @@ -40,7 +46,7 @@ the data region.
### 2.2 The Port Fw::BufferGet

As shown in the following diagram, `Fw::BufferGet` has one argument `size` of type `U32`. It returns a value of type
`Fw::Buffer`. The returned `Fw::Buffer`'s size must be checked for validity before using.
`Fw::Buffer`. The returned `Fw::Buffer` must be checked for validity before using.

![`Fw::BufferGet` Diagram](img/BufferGetBDD.jpg "Fw::BufferGet Port")

Expand All @@ -53,16 +59,20 @@ As shown in the following diagram, `Fw::BufferSend` has one argument `fwBuffer`
## 3 Usage Notes

Components allocating `Fw::Buffer` objects may use the `m_context` field at their discretion. This field is typically
used to track the origin of the buffer for eventual allocation. When a component fails to allocate memory, it must set
the `m_size` field to zero to indicate that the buffer is invalid.
used to track the origin of the buffer for eventual allocation.

When a component fails to allocate memory, it must set
the `m_bufferData` field to `nullptr` and/or set the `m_size` field to zero to indicate that the buffer is invalid.

Receivers of `Fw::Buffer` objects are expected to check the `m_size` field before using the buffer.
A receiver of an `Fw::Buffer` object _B_ must check that _B_ is valid before accessing the
data stored in _B_.
To check validity, you can call the interface function `isValid()`.

### Serializing and Deserializing with `Fw::Buffer`

Users can obtain a SerializeBuffer, `sb`, by calling `getSerializeRepr()`. This serialize buffer is backed by the memory
of the `Fw::Buffer` and is initially empty. Users can serialize and deserialize through `sb` to copy to/from the backed
memory.
memory.

The state of `sb` persists as long as the current `Fw::Buffer` object exists as it is stored as a member. However, all
`Fw::Buffer` constructors initialize `sb` to an empty state including the `Fw::Buffer` copy constructor. Thus, if an
Expand Down
2 changes: 1 addition & 1 deletion Fw/Types/Serializable.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -707,7 +707,7 @@ namespace Fw {
}

void ExternalSerializeBuffer::setExtBuffer(U8* buffPtr, NATIVE_UINT_TYPE size) {
FW_ASSERT(buffPtr);
FW_ASSERT(buffPtr != nullptr);
this->m_buff = buffPtr;
this->m_buffSize = size;
}
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ Then, create a new project with:
fprime-util new --project
```

See the [HelloWorld Tutorial](https://nasa.github.io/fprime/Tutorials/HelloWorld/Tutorial.html) to guide you through all the steps of developing an F´ project.
See the [HelloWorld Tutorial](https://fprime-community.github.io/fprime-tutorial-hello-world/) to guide you through all the steps of developing an F´ project.

New users are encouraged to read through the [User Guide](https://nasa.github.io/fprime/UsersGuide/guide.html) and explore the [other tutorials](https://nasa.github.io/fprime/Tutorials/README.html).

Expand Down
4 changes: 4 additions & 0 deletions Ref/Top/RefPackets.xml
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,10 @@
<channel name="typeDemo.ExtraChoicesCh"/>
<channel name="typeDemo.ChoicePairCh"/>
<channel name="typeDemo.ChoiceSlurryCh"/>
<channel name="typeDemo.Float1Ch"/>
<channel name="typeDemo.Float2Ch"/>
<channel name="typeDemo.Float3Ch"/>
<channel name="typeDemo.FloatSet"/>
</packet>

<!-- Ignored packets -->
Expand Down
12 changes: 12 additions & 0 deletions Ref/TypeDemo/TypeDemo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -123,4 +123,16 @@ void TypeDemo ::DUMP_TYPED_PARAMETERS_cmdHandler(const FwOpcodeType opCode, cons
this->cmdResponse_out(opCode, cmdSeq, Fw::CmdResponse::OK);
}

void TypeDemo ::DUMP_FLOATS_cmdHandler(const FwOpcodeType opCode, const U32 cmdSeq) {
Ref::FloatSet invalid;
invalid[0] = std::numeric_limits<float>::infinity();
invalid[1] = -1 * std::numeric_limits<float>::infinity();
invalid[2] = (std::numeric_limits<float>::has_quiet_NaN) ? std::numeric_limits<float>::quiet_NaN() : 0.0f;
this->log_ACTIVITY_HI_FloatEv(invalid[0], invalid[1], invalid[2], invalid);
this->tlmWrite_Float1Ch(invalid[0]);
this->tlmWrite_Float2Ch(invalid[1]);
this->tlmWrite_Float3Ch(invalid[2]);
this->tlmWrite_FloatSet(invalid);
this->cmdResponse_out(opCode, cmdSeq, Fw::CmdResponse::OK);
}
} // end namespace Ref
25 changes: 25 additions & 0 deletions Ref/TypeDemo/TypeDemo.fpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@ module Ref {
choicePair: ChoicePair
}

@ Set of floating points to emit
array FloatSet = [3] F32;

@ Component to demonstrate multiple type configurations
passive component TypeDemo {
#####
Expand Down Expand Up @@ -192,6 +195,28 @@ module Ref {
@ Dump the typed parameters
sync command DUMP_TYPED_PARAMETERS()

#####
# FloatSet outputs
#####
@ A set of floats in an event
event FloatEv(float1: F32, float2: F32, float3: F32, floats: FloatSet) severity activity high \
format "Floats: {} {} {} as a set: {}"

@ Float output channel 1
telemetry Float1Ch: F32

@ Float output channel 2
telemetry Float2Ch: F32

@ Float output channel 3
telemetry Float3Ch: F32

@ Float set output channel
telemetry FloatSet: FloatSet

@ Dump the float values
sync command DUMP_FLOATS()

# ----------------------------------------------------------------------
# Special ports
# ----------------------------------------------------------------------
Expand Down
Loading

0 comments on commit 596087d

Please sign in to comment.