-
Notifications
You must be signed in to change notification settings - Fork 63
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 #673 from sassy-asjp/feature/667-msg-array-types
Feature/667 Message payload C array types
- Loading branch information
Showing
5 changed files
with
207 additions
and
80 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
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,88 @@ | ||
# | ||
# ISC License | ||
# | ||
# Copyright (c) 2024, Astroscale Japan | ||
# | ||
# Permission to use, copy, modify, and/or distribute this software for any | ||
# purpose with or without fee is hereby granted, provided that the above | ||
# copyright notice and this permission notice appear in all copies. | ||
# | ||
# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES | ||
# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF | ||
# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR | ||
# ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES | ||
# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN | ||
# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF | ||
# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. | ||
# | ||
|
||
# | ||
# Purpose: Test the handling of built in types for a C message payload | ||
# Author: Sasawat Prankprakma (Astroscale Japan) | ||
# Creation Date: 2024-04-17 | ||
# | ||
|
||
|
||
from Basilisk.architecture import bskLogging | ||
from Basilisk.architecture import messaging | ||
|
||
|
||
def test_cMsgTypes(): | ||
""" | ||
Test the Python-side types of various message payload C types | ||
""" | ||
|
||
bskLogging.setDefaultLogLevel(bskLogging.BSK_WARNING) | ||
|
||
test = messaging.TypesTestMsgPayload() | ||
|
||
assert type(test.i8Test) is int | ||
assert type(test.ui8Test) is int | ||
assert type(test.i16Test) is int | ||
assert type(test.ui16Test) is int | ||
assert type(test.i32Test) is int | ||
assert type(test.ui32Test) is int | ||
assert type(test.i64Test) is int | ||
assert type(test.ui64Test) is int | ||
assert type(test.f32Test) is float | ||
assert type(test.f64Test) is float | ||
|
||
assert type(test.i16TestArray[0]) is int | ||
assert type(test.ui16TestArray[0]) is int | ||
assert type(test.i32TestArray[0]) is int | ||
assert type(test.ui32TestArray[0]) is int | ||
assert type(test.i64TestArray[0]) is int | ||
assert type(test.ui64TestArray[0]) is int | ||
assert type(test.f32TestArray[0]) is float | ||
assert type(test.f64TestArray[0]) is float | ||
|
||
assert type(test.i16TestArray2[0][0]) is int | ||
assert type(test.ui16TestArray2[0][0]) is int | ||
assert type(test.i32TestArray2[0][0]) is int | ||
assert type(test.ui32TestArray2[0][0]) is int | ||
assert type(test.i64TestArray2[0][0]) is int | ||
assert type(test.ui64TestArray2[0][0]) is int | ||
assert type(test.f32TestArray2[0][0]) is float | ||
assert type(test.f64TestArray2[0][0]) is float | ||
|
||
assert len(test.i16TestArray) == messaging.TYPES_TEST_ARRAY_SIZE | ||
assert len(test.ui16TestArray) == messaging.TYPES_TEST_ARRAY_SIZE | ||
assert len(test.i32TestArray) == messaging.TYPES_TEST_ARRAY_SIZE | ||
assert len(test.ui32TestArray) == messaging.TYPES_TEST_ARRAY_SIZE | ||
assert len(test.i64TestArray) == messaging.TYPES_TEST_ARRAY_SIZE | ||
assert len(test.ui64TestArray) == messaging.TYPES_TEST_ARRAY_SIZE | ||
assert len(test.f32TestArray) == messaging.TYPES_TEST_ARRAY_SIZE | ||
assert len(test.f64TestArray) == messaging.TYPES_TEST_ARRAY_SIZE | ||
|
||
assert len(test.i16TestArray2[0]) == messaging.TYPES_TEST_ARRAY_SIZE | ||
assert len(test.ui16TestArray2[0]) == messaging.TYPES_TEST_ARRAY_SIZE | ||
assert len(test.i32TestArray2[0]) == messaging.TYPES_TEST_ARRAY_SIZE | ||
assert len(test.ui32TestArray2[0]) == messaging.TYPES_TEST_ARRAY_SIZE | ||
assert len(test.i64TestArray2[0]) == messaging.TYPES_TEST_ARRAY_SIZE | ||
assert len(test.ui64TestArray2[0]) == messaging.TYPES_TEST_ARRAY_SIZE | ||
assert len(test.f32TestArray2[0]) == messaging.TYPES_TEST_ARRAY_SIZE | ||
assert len(test.f64TestArray2[0]) == messaging.TYPES_TEST_ARRAY_SIZE | ||
|
||
|
||
if __name__ == "__main__": | ||
test_cMsgTypes() |
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,66 @@ | ||
/* | ||
ISC License | ||
Copyright (c) 2024, Astroscale Japan | ||
Permission to use, copy, modify, and/or distribute this software for any | ||
purpose with or without fee is hereby granted, provided that the above | ||
copyright notice and this permission notice appear in all copies. | ||
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES | ||
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF | ||
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR | ||
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES | ||
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN | ||
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF | ||
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. | ||
*/ | ||
|
||
#ifndef TYPES_TEST_MESSAGE_H | ||
#define TYPES_TEST_MESSAGE_H | ||
|
||
#include <stdint.h> | ||
|
||
#define TYPES_TEST_ARRAY_SIZE 3 | ||
|
||
/*! @brief Structure used to test the handling of various built-in types in message payloads across SWIG C/Python bridge */ | ||
typedef struct { | ||
// Scalars | ||
int8_t i8Test; //!< Test variable of int8_t | ||
uint8_t ui8Test; //!< Test variable of uint8_t | ||
int16_t i16Test; //!< Test variable of int16_t | ||
uint16_t ui16Test; //!< Test variable of uint16_t | ||
int32_t i32Test; //!< Test variable of int32_t | ||
uint32_t ui32Test; //!< Test variable of uint32_t | ||
int64_t i64Test; //!< Test variable of int64_t | ||
uint64_t ui64Test; //!< Test variable of uint64_t | ||
float f32Test; //!< Test variable of float | ||
double f64Test; //!< Test variable of double | ||
|
||
// 1D Arrays, integer | ||
int16_t i16TestArray[TYPES_TEST_ARRAY_SIZE]; //!< Test variable of array of int16_t | ||
uint16_t ui16TestArray[TYPES_TEST_ARRAY_SIZE]; //!< Test variable of array of uint16_t | ||
int32_t i32TestArray[TYPES_TEST_ARRAY_SIZE]; //!< Test variable of array of int32_t | ||
uint32_t ui32TestArray[TYPES_TEST_ARRAY_SIZE]; //!< Test variable of array of uint32_t | ||
int64_t i64TestArray[TYPES_TEST_ARRAY_SIZE]; //!< Test variable of array of int64_t | ||
uint64_t ui64TestArray[TYPES_TEST_ARRAY_SIZE]; //!< Test variable of array of uint64_t | ||
|
||
// 2D Arrays, integer | ||
int16_t i16TestArray2[TYPES_TEST_ARRAY_SIZE][TYPES_TEST_ARRAY_SIZE]; //!< Test variable of 2D array of int16_t | ||
uint16_t ui16TestArray2[TYPES_TEST_ARRAY_SIZE][TYPES_TEST_ARRAY_SIZE]; //!< Test variable of 2D array of uint16_t | ||
int32_t i32TestArray2[TYPES_TEST_ARRAY_SIZE][TYPES_TEST_ARRAY_SIZE]; //!< Test variable of 2D array of int32_t | ||
uint32_t ui32TestArray2[TYPES_TEST_ARRAY_SIZE][TYPES_TEST_ARRAY_SIZE]; //!< Test variable of 2D array of uint32_t | ||
int64_t i64TestArray2[TYPES_TEST_ARRAY_SIZE][TYPES_TEST_ARRAY_SIZE]; //!< Test variable of 2D array of int64_t | ||
uint64_t ui64TestArray2[TYPES_TEST_ARRAY_SIZE][TYPES_TEST_ARRAY_SIZE]; //!< Test variable of 2D array of uint64_t | ||
|
||
// 1D Arrays, floating point | ||
float f32TestArray[TYPES_TEST_ARRAY_SIZE]; //!< Test variable of array of float | ||
double f64TestArray[TYPES_TEST_ARRAY_SIZE]; //!< Test variable of array of double | ||
|
||
// 2D Arrays, floating point | ||
float f32TestArray2[TYPES_TEST_ARRAY_SIZE][TYPES_TEST_ARRAY_SIZE]; //!< Test variable of 2D array of float | ||
double f64TestArray2[TYPES_TEST_ARRAY_SIZE][TYPES_TEST_ARRAY_SIZE]; //!< Test variable of 2D array of double | ||
} TypesTestMsgPayload; | ||
|
||
#endif |