Skip to content

Commit

Permalink
Release v1.0.0 (#14)
Browse files Browse the repository at this point in the history
  • Loading branch information
sanketgr authored Sep 27, 2022
1 parent 17eb63d commit 05a9d52
Show file tree
Hide file tree
Showing 11 changed files with 1,013 additions and 1,115 deletions.
21 changes: 10 additions & 11 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,19 @@
# Change Log

## future release (TBD)
## v1.0.0 (Sept 27, 2022)
Bugfixes:
* Fixed an OBD bug in which software requests more than six PID ranges in one message. The new revision request the extra range in a separate message.
* Fixed a bug in CANDataSource in which software didn't handle CAN message with extended ID correctly.

## v0.1.4 (Aug 29, 2022)
https://s3.console.aws.amazon.com/s3/object/aws-iot-fleetwise?prefix=v0.1.4/aws-iot-fleetwise-edge.zip
Improvements:
* Remove the html version of developer guide.
* Remove source code in S3 bucket. The S3 bucket will only be used to host quick demo cloud formation.
* Remove convertToPeculiarFloat function from DataCollectionProtoWriter.
* Set default checkin period to 2-min in static-config.json. The quick demo will still use 5 second as checkin period.
* Update FleetWise CLI Model to GA release version.
* Update Customer Demo to remove service-linked role creation for FleetWise Account Registration.

## v0.1.4 (Aug 29, 2022)
Bugfixes:
* Fixed a bug in which software will continue requesting OBD-II PIDs or decoding CAN messages after all collection schemes removed.

Expand All @@ -17,8 +24,6 @@ Improvements:
* Improve OBD logging to log CAN ISOTP raw bytes for better debugging

## v0.1.3 (Aug 3, 2022)
https://s3.console.aws.amazon.com/s3/object/aws-iot-fleetwise?prefix=v0.1.3/aws-iot-fleetwise-edge.zip

Customer Demo:
* Updated demo scripts to match with latest AWS IoT FleetWise Cloud [API changes](https://docs.aws.amazon.com/iot-fleetwise/latest/developerguide/update-sdk-cli.html)
* Fix a bug in demo script that might render scatter plot incorrectly.
Expand All @@ -44,8 +49,6 @@ Improvements:
* Improvement to cansim to better handle ISO-TP error.

## v0.1.2 (February 24, 2022)
https://s3.console.aws.amazon.com/s3/object/aws-iot-fleetwise?prefix=v0.1.2/aws-iot-fleetwise-edge.zip

Features:
* No new features.

Expand All @@ -66,8 +69,6 @@ Bugfixes/Improvements:
* Developer guide converted to Markdown.

## v0.1.1 (January 25, 2022)
https://s3.console.aws.amazon.com/s3/object/aws-iot-fleetwise?prefix=v0.1.1/aws-iot-fleetwise-edge.zip

Features:
* No new features.

Expand All @@ -93,8 +94,6 @@ Bugfixes/Improvements:
* Edge agent now compiled and run on the same EC2 instance, rather than using CodePipeline.

## v0.1.0 (November 29, 2021)
https://s3.console.aws.amazon.com/s3/object/aws-iot-fleetwise?prefix=v0.1.0/aws-iot-fleetwise-edge.zip

Features:
* Initial preview release

Expand Down
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

cmake_minimum_required(VERSION 3.10.2)

project(iotfleetwise VERSION 0.1.4)
project(iotfleetwise VERSION 1.0.0)

# AWS IoT FleetWise Edge uses C++14 for compatibility reasons with
# Automotive middlewares ( Adaptive AUTOSAR, ROS2)
Expand Down
1 change: 0 additions & 1 deletion docs/dev-guide/edge-agent-dev-guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ or may not be affiliated with, connected to, or sponsored by Amazon.

**Note**

- AWS IoT FleetWise is in preview release and is subject to change. We recommend that you use the service, including the AWS IoT FleetWise Edge Agent software, only with test data, and not in production environments.
- AWS IoT FleetWise is currently available in US East (N. Virginia) and Europe (Frankfurt).

**AWS IoT FleetWise** provides a set of tools that enable automakers to collect, transform, and transfer vehicle data to the cloud at scale. With AWS IoT FleetWise you can build virtual representations of vehicle networks and define data collection rules to transfer only high-value data from your vehicles to AWS Cloud.
Expand Down
3 changes: 0 additions & 3 deletions docs/rpi-tutorial/raspberry-pi-tutorial.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,6 @@ Amazon.

**Note**

* AWS IoT FleetWise is in preview release and is subject to change. We recommend that you use the
service, including the AWS IoT FleetWise Edge Agent software, only with test data, and not in
production environments.
* AWS IoT FleetWise is currently available in US East (N. Virginia) and Europe (Frankfurt).
* The AWS IoT FleetWise in-vehicle software component is licensed to you under the Amazon Software
License. You are solely responsible for ensuring such software and any updates and modifications
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,17 +114,6 @@ class DataCollectionProtoWriter

bool serializeVehicleData( std::string *out ) const;

/**
* @brief This function translates the IEEE 754 double format to the quotient and
* divisor format by mapping the fraction to the quotient and the exponent
* to the divisor, clipping and translating as appropriate.
*
* @param physicalValue physical value of the signal
* @param quotient Quotient
* @param divisor Divisor
*/
static void convertToPeculiarFloat( double physicalValue, uint32_t &quotient, uint32_t &divisor );

private:
Timestamp mTriggerTime;
unsigned mVehicleDataMsgCount{}; // tracks the number of messages being sent in the edge to cloud payload
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,6 @@
// Includes
#include "DataCollectionProtoWriter.h"

// Refer to the following for definitions of significand and exponent:
// https://en.wikipedia.org/wiki/Double-precision_floating-point_format
#define DBL_SIGNIFICAND_BITS 52U
#define DBL_SIGNIFICAND_MASK ( ( 1ULL << DBL_SIGNIFICAND_BITS ) - 1U )
#define DBL_SIGNIFICAND_FULL_BITS ( DBL_SIGNIFICAND_BITS + 1U ) // Including 'hidden' 53rd bit
#define DBL_EXPONENT_BITS 11U
#define DBL_EXPONENT_MASK ( ( 1U << DBL_EXPONENT_BITS ) - 1U )

namespace Aws
{
namespace IoTFleetWise
Expand All @@ -40,63 +32,6 @@ DataCollectionProtoWriter::~DataCollectionProtoWriter()
google::protobuf::ShutdownProtobufLibrary();
}

void
DataCollectionProtoWriter::convertToPeculiarFloat( double physicalValue, uint32_t &quotient, uint32_t &divisor )
{
/*
IEEE 754 double format:
SEEEEEEEEEEEFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
^^ ^^ ^
|| || |
|| |----------------------------------------------------- 52-bit fraction
|------------ 11-bit exponent (biased)
-- 1-bit sign
Formula:
number = (-1)^sign * (((2^52 + fraction) / 2^52) * (2^(exponent - 1023))
Output formula:
number = quotient / divisor
The following code translates the IEEE 754 double format to the quotient and divisor format by
mapping the fraction to the quotient and the exponent to the divisor, clipping and translating
as appropriate.
*/

// Decode IEEE 754 'binary64' (a.k.a. 'double') format (ignore the sign, it is encoded separately):
uint64_t raw = 0x0ULL;
memcpy( &raw, &physicalValue, sizeof( raw ) );
uint64_t fraction = raw & DBL_SIGNIFICAND_MASK;
int exponent = static_cast<int>( ( raw >> DBL_SIGNIFICAND_BITS ) & DBL_EXPONENT_MASK );

fraction |= 1ULL << ( DBL_SIGNIFICAND_FULL_BITS - 1U ); // Set the 'hidden' 53rd bit
exponent -= 1023; // Remove exponent bias

if ( exponent >= UINT32_WIDTH ) // physicalValue is too big, infinite or NaN: return UINT32_MAX
{
quotient = UINT32_MAX;
divisor = 1U;
return;
}
if ( exponent <= -UINT32_WIDTH ) // physicalValue is too small or zero: return zero
{
quotient = 0U;
divisor = 1U;
return;
}
// Note: exponent is now in the range -31 to 31

if ( exponent < 0 ) // physicalValue is less than 1.0
{
// Multiply by 2^exponent, i.e. right shift by -exponent, then set the exponent to zero,
// so that the divisor will be 2^31 below:
fraction >>= static_cast<unsigned>( -exponent );
exponent = 0;
}
// Throw away lowest 21-bits of precision:
quotient = static_cast<uint32_t>( fraction >> ( DBL_SIGNIFICAND_FULL_BITS - UINT32_WIDTH ) );
divisor = 1U << ( ( UINT32_WIDTH - 1U ) - static_cast<unsigned>( exponent ) );
}

void
DataCollectionProtoWriter::setupVehicleData( const TriggeredCollectionSchemeDataPtr triggeredCollectionSchemeData,
uint32_t collectionEventID )
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,27 +22,6 @@ using namespace Aws::IoTFleetWise::Platform::Linux;
class DataCollectionProtoWriterTest : public ::testing::Test
{
public:
void
check( double input, double diff, bool print = true )
{
uint32_t quotient;
uint32_t divisor;
DataCollectionProtoWriter::convertToPeculiarFloat( input, quotient, divisor );
double output = (double)quotient / (double)divisor;
if ( print )
{
printf( "input=%g, output=%u/%u=%g\n", input, quotient, divisor, output );
}
if ( isnan( input ) || isinf( input ) )
{
EXPECT_EQ( UINT32_MAX, output );
}
else
{
EXPECT_NEAR( abs( input ), output, abs( input ) * diff );
}
}

std::string
convertProtoToHex( const std::string &proto )
{
Expand All @@ -57,92 +36,6 @@ class DataCollectionProtoWriterTest : public ::testing::Test
}
};

TEST_F( DataCollectionProtoWriterTest, TestPeculiarFloatZero )
{
check( 0.0, 0.0 );
}

TEST_F( DataCollectionProtoWriterTest, TestPeculiarFloat1 )
{
check( 1.0, 0.0 );
}

TEST_F( DataCollectionProtoWriterTest, TestPeculiarFloatMinus1 )
{
check( -1.0, 0.0 );
}

TEST_F( DataCollectionProtoWriterTest, TestPeculiarFloat1000 )
{
check( 1000.0, 0.0 );
}

TEST_F( DataCollectionProtoWriterTest, TestPeculiarFloatU32Max )
{
check( UINT32_MAX, 0.0 );
}

TEST_F( DataCollectionProtoWriterTest, TestPeculiarFloat0_5 )
{
check( 0.5, 0.0 );
}

TEST_F( DataCollectionProtoWriterTest, TestPeculiarFloat0_333 )
{
check( 1.0 / 3.0, 0.000000001 );
}

TEST_F( DataCollectionProtoWriterTest, TestPeculiarFloat0_111 )
{
check( 1.0 / 9.0, 0.000000001 );
}

TEST_F( DataCollectionProtoWriterTest, TestPeculiarFloatMin )
{
check( 1.0 / (double)( 1U << 31 ), 0.0 );
}

TEST_F( DataCollectionProtoWriterTest, TestPeculiarFloatEpsilon )
{
check( DBL_EPSILON, 1.0 );
}

TEST_F( DataCollectionProtoWriterTest, TestPeculiarFloatMoreThan9SigFig )
{
// This test broke decimalToFraction
check( 5.000000001, 0.000000001 );
}

TEST_F( DataCollectionProtoWriterTest, TestPeculiarFloatPi )
{
check( M_PI, 0.000000001 );
}

TEST_F( DataCollectionProtoWriterTest, TestPeculiarFloatInfinity )
{
check( INFINITY, INFINITY );
}

TEST_F( DataCollectionProtoWriterTest, TestPeculiarFloatMinusInfinity )
{
check( -INFINITY, INFINITY );
}

TEST_F( DataCollectionProtoWriterTest, TestPeculiarFloatNan )
{
check( NAN, NAN );
}

TEST_F( DataCollectionProtoWriterTest, TestPeculiarFloatRandom )
{
srand( (unsigned)time( NULL ) );
for ( auto i = 0; i < 10000000; i++ )
{
double r = ( (double)rand() * 100000.0 ) / (double)RAND_MAX;
check( r, 0.000000001, false );
}
}

// Test the edge to cloud payload fields in the proto
TEST_F( DataCollectionProtoWriterTest, TestVehicleData )
{
Expand Down
4 changes: 3 additions & 1 deletion src/vehiclenetwork/src/CANDataSource.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ namespace VehicleNetwork
using namespace Aws::IoTFleetWise::Platform::Utility;
static const std::string INTERFACE_NAME_KEY = "interfaceName";
static const std::string THREAD_IDLE_TIME_KEY = "threadIdleTimeMs";
static constexpr uint32_t MSB_MASK = 0X7FFFFFFFU;
CANDataSource::CANDataSource( bool useKernelTimestamp )
: mUseKernelTimestamp{ useKernelTimestamp }
{
Expand Down Expand Up @@ -284,7 +285,8 @@ CANDataSource::doWork( void *data )
{
rawData.emplace_back( frame[i].data[j] );
}
message.setup( frame[i].can_id, rawData, syntheticData, timestamp );
// Compose the correct CAN Frame ID by clearing the MSB
message.setup( frame[i].can_id & MSB_MASK, rawData, syntheticData, timestamp );
if ( message.isValid() )
{
if ( !dataSource->mCircularBuffPtr->push( message ) )
Expand Down
49 changes: 49 additions & 0 deletions src/vehiclenetwork/test/CANDataSourceTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,21 @@ sendTestMessage( int socketFD )
ASSERT_EQ( bytesWritten, sizeof( struct can_frame ) );
}

static void
sendTestMessageExtendedID( int socketFD )
{
struct can_frame frame = {};
frame.can_id = 0x123 | CAN_EFF_FLAG;

frame.can_dlc = 4;
for ( uint8_t i = 0; i < 3; ++i )
{
frame.data[i] = i;
}
ssize_t bytesWritten = write( socketFD, &frame, sizeof( struct can_frame ) );
ASSERT_EQ( bytesWritten, sizeof( struct can_frame ) );
}

class CANDataSourceTest : public ::testing::Test
{
public:
Expand Down Expand Up @@ -283,3 +298,37 @@ TEST_F( CANDataSourceTest, testSourceIdsAreUnique )
}
ASSERT_EQ( NUM_SOURCES, sourceIDs.size() );
}

TEST_F( CANDataSourceTest, testExtractExtendedID )
{
LocalDataSourceEventListener listener;
ASSERT_TRUE( socketFD != -1 );

static_cast<void>( socketFD >= 0 );
VehicleDataSourceConfig sourceConfig;
sourceConfig.transportProperties.emplace( "interfaceName", "vcan0" );
sourceConfig.transportProperties.emplace( "threadIdleTimeMs", "1000" );
sourceConfig.maxNumberOfVehicleDataMessages = 1000;
std::vector<VehicleDataSourceConfig> sourceConfigs = { sourceConfig };
CANDataSource dataSource;
ASSERT_TRUE( dataSource.init( sourceConfigs ) );
ASSERT_TRUE( dataSource.subscribeListener( &listener ) );

ASSERT_TRUE( dataSource.connect() );
ASSERT_TRUE( listener.gotConnectCallback );
ASSERT_TRUE( dataSource.isAlive() );
// Set the Channel in an active acquire state
dataSource.resumeDataAcquisition();
ASSERT_EQ( dataSource.getVehicleDataSourceIfName(), "vcan0" );
ASSERT_EQ( dataSource.getVehicleDataSourceProtocol(), VehicleDataSourceProtocol::RAW_SOCKET );
ASSERT_EQ( dataSource.getVehicleDataSourceType(), VehicleDataSourceType::CAN_SOURCE );
sendTestMessageExtendedID( socketFD );
// Sleep for sometime on this thread to allow the other thread to finish
std::this_thread::sleep_for( std::chrono::seconds( 2 ) );
VehicleDataMessage msg;
ASSERT_TRUE( dataSource.getBuffer()->pop( msg ) );
ASSERT_EQ( msg.getMessageID(), 0x123 );
ASSERT_TRUE( dataSource.disconnect() );
ASSERT_TRUE( dataSource.unSubscribeListener( &listener ) );
ASSERT_TRUE( listener.gotDisConnectCallback );
}
Loading

0 comments on commit 05a9d52

Please sign in to comment.