Skip to content

Commit

Permalink
Public release MSCL 52.2.1
Browse files Browse the repository at this point in the history
  • Loading branch information
mgill committed Sep 9, 2019
1 parent d2dad58 commit c45b978
Show file tree
Hide file tree
Showing 184 changed files with 5,197 additions and 3,840 deletions.
2 changes: 2 additions & 0 deletions BuildScripts/buildReadme_Linux.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ Pre-built versions are available for download. To get it, head over to the [MSCL
- \>= python2.7 (for Python build)
- \>= python2.7-dev (for Python build)

#### Note
On some systems, you may get a virtual memory error when compiling MSCL (ex. `Virtual memory exhausted: Cannot allocate memory`). It may be necessary to temporarily increase your Swapfile size. For an example, see [this post](https://www.bitpi.co/2015/02/11/how-to-change-raspberry-pis-swapfile-size-on-rasbian/) explaining this for the Raspberry Pi. Keep in mind that you may want to change back to the original swapfile size when you are done compiling MSCL (especially if using an SD card), as it can cause a lot of unnecessary writes to your disk.

## Building MSCL for C++

Expand Down
21 changes: 21 additions & 0 deletions CHANGELOG.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,27 @@ RENAMED - A function/class has been renamed.
REMOVED - A function/class has been removed.
======================================================================================================

52.2.1 - 2019-09-03
- update jam files for static dependency support

52.2.0 - 2019-08-27
- InertialNode::setUARTBaudRate()
- add optional parameter to prevent the serial connection automatically being closed and re-opened at the new baud rate
- add 250 ms sleep between sending the command to the device and re-establishing port connection to account for the delay on the device

52.1.0 - 2019-08-20
- add ability to close and re-establish serial connections with an different baud rate via SerialConnection::updateBaudRate
- automatically re-establish connection when inertial device baud rate is changed via InertialNode::setUARTBaudRate or InertialNode::sendCommandBytes
- add missing type documentation to ExposedInertialTypes.h
- add function selector 0x06 - USE_NEW_SETTINGS_NO_ACKNACK to MipTypes::FunctionSelector enum

52.0.0 - 2019-08-08
- updating to 52.0.0 which should have been done on the last commit due to the non-backwards compatible change
- using the enum keyword for maps in the the SWIG interface to fix an issue with newer versions of SWIG

51.0.2 - 2019-08-07
- RENAMED captureTareOrientation to tareOrientation

51.0.1 - 2019-07-12
- fix for Sync Sampling network logic divide by 0.0 when no channels are active

Expand Down
40 changes: 7 additions & 33 deletions HowToUseMSCL.md
Original file line number Diff line number Diff line change
@@ -1,27 +1,14 @@
# How to use MSCL

- [Drivers](https://github.com/LORD-MicroStrain/MSCL/blob/master/HowToUseMSCL.md#drivers)
- [Windows](https://github.com/LORD-MicroStrain/MSCL/blob/master/HowToUseMSCL.md#windows)
- [Python](https://github.com/LORD-MicroStrain/MSCL/blob/master/HowToUseMSCL.md#python)
- [.NET](https://github.com/LORD-MicroStrain/MSCL/blob/master/HowToUseMSCL.md#net-c-vb)
- [C++](https://github.com/LORD-MicroStrain/MSCL/blob/master/HowToUseMSCL.md#c)
- [Linux](https://github.com/LORD-MicroStrain/MSCL/blob/master/HowToUseMSCL.md#linux)
- [Python](https://github.com/LORD-MicroStrain/MSCL/blob/master/HowToUseMSCL.md#python-1)
- [C++](https://github.com/LORD-MicroStrain/MSCL/blob/master/HowToUseMSCL.md#c-1)

---

## Drivers

Make sure you have the Windows/Linux drivers for our products installed. If you have installed our desktop software, [SensorConnect](http://www.microstrain.com/software/sensorconnect) on Windows, then the drivers were installed with it. If you want to install the drivers seperately, please visit our [drivers page](https://github.com/LORD-MicroStrain/Drivers).

---

## Windows

Download the [pre-built Windows binaries](https://github.com/LORD-MicroStrain/MSCL#mscl---the-microstrain-communication-library).

#### Python
### Python

You can copy the `mscl.py` and `_mscl.pyd` files into a path where python searches for modules. If you do this, you can simply use mscl from anywhere by adding `import mscl` to the top of your python files. To find where Python looks searches for modules on your system, print `sys.path` in your python environment.

Expand All @@ -32,15 +19,15 @@ sys.path.append('<pathToMsclPythonFiles>')
import mscl
```

#### .NET (C#, VB)
### .NET

Add `MSCL_Managed.dll` as a Reference to your project

Place `MSCL.dll` next to your executable

Set your Platform Target to either `x86` or `x64`

#### C++
### C++

*Note:* The C++ MSCL library depends on Boost 1.68. You can download and install the [pre-built Boost libraries](https://sourceforge.net/projects/boost/files/boost-binaries/) (recommended), or build boost from source.

Expand All @@ -54,7 +41,6 @@ Point your compiler to the Boost headers and lib files:
* Link directory: `<boostInstallPath>/lib64_msvc-14.0` (or whatever folder contains the boost `.lib` files)
* Link to: `libboost_system-vc140-mt-s-x64-1_68.lib` (or equivalent for your build environment)

---

## Linux

Expand All @@ -75,19 +61,14 @@ sudo yum install ./<PACKAGE_NAME>.rpm #install MSCL and it's dependencies

*Note:* to uninstall MSCL, run: `sudo yum remove <PACKAGE_NAME>.rpm`

#### Python
### Python
After installing the package, a folder was created in `/usr/share/`. The name of the folder varies depending on which package you install (`/usr/share/python2-mscl` or `/usr/share/python3-mscl`)

Inside this folder, there will be two files:
* `mscl.py`
* `_mscl.so`

If you copy these files into a path where python searches for modules, you can simply use mscl from anywhere by adding `import mscl` to the top of your python files. To find where Python looks searches for modules on your system, print `sys.path` in your python environment. For example, on one machine Python's output of `sys.path` included the folder `/usr/lib/python2.7/dist-packages`. In this scenario, we would do the following:

```
cp /usr/share/python2-mscl/mscl.py /usr/lib/python2.7/dist-packages
cp /usr/share/python2-mscl/_mscl.so /usr/lib/python2.7/dist-packages
```
If you copy these files into a path where python searches for modules, you can simply use mscl from anywhere by adding `import mscl` to the top of your python files. To find where Python looks searches for modules on your system, print `sys.path` in your python environment.

Alternatively, you can import mscl by adding the full mscl path to sys.path:
```py
Expand All @@ -96,18 +77,11 @@ sys.path.append('/usr/share/<PYTHON_MSCL_FOLDER_NAME>/')
import mscl
```

#### C++
### C++

After installing the package, a folder was created in `/usr/share/` called `c++-mscl`.

This folder contains the MSCL headers, as well as a `boost` folder with the Boost library headers and libraries. You will need to tell your compiler to include these MSCL and Boost headers, as well as link to `libmscl.so`.

For example:
```
g++ -I/usr/share/c++-mscl/source -I/usr/share/c++-mscl/Boost/include YourFile.cpp -o YourProgram -L/usr/share/c++-mscl -lmscl -lstdc++ -std=c++11
```

You may also need to add `/usr/share/c++-mscl` to your `LD_LIBRARY_PATH` environment variable:
```
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/share/c++-mscl
```
```g++ -I/usr/share/c++-mscl/source -I/usr/share/c++-mscl/Boost/include YourFile.cpp -o YourProgram -L/usr/share/c++-mscl -lmscl -lstdc++ -std=c++11```
5 changes: 1 addition & 4 deletions Jamroot.jam
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,4 @@ build-project MSCL_Examples ;
alias stage : MSCL//stage_all ;

#Make the user explicitly tell bjam to build the stage alias
explicit stage ;

alias stage_dynamic : MSCL//stage_python_dynamic MSCL//stage_c++ MSCL//stage_headers ;
explicit stage_dynamic ;
explicit stage ;
53 changes: 21 additions & 32 deletions MSCL/Jamfile
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,24 @@ rule compileflags
return $(flags) ;
}

rule boost-libs
{
local boostlib ;
if --static in [ modules.peek : ARGV ]
{
#TODO: Figure out if we need pthread and the libraries rules as defined below
boostlib = boost_system/<link>static boost_filesystem/<link>static ;
ECHO "Using statically linked dependencies" ;
}
else
{
boostlib = boost_system boost_filesystem pthread [ libraries ] ;
ECHO "NOT using statically linked dependencies" ;
}

return $(boostlib) ;
}

local configured-flags = [ compileflags ] ;

#Define the project
Expand All @@ -77,19 +95,16 @@ lib pthread ;
alias unixsocket_cpp : : <target-os>windows ;
alias upnp_files : source/mscl/Communication/WsdaFinder.h source/mscl/Communication/WsdaFinder.cpp source/mscl/Communication/UpnpService.h source/mscl/Communication/UpnpService.cpp source/mscl/Communication/UpnpDeviceFinderCallback.h source/mscl/Communication/UpnpDeviceFinderCallback.cpp : <target-os>windows ;
alias boostLibs : : <target-os>windows ;
alias boostStaticLibs : : <target-os>windows ;

#linux aliases
alias unixsocket_cpp : source/mscl/Communication/UnixSocketConnection.cpp : <target-os>linux ;
alias upnp_files : : <target-os>linux ;
alias boostLibs : boost_system boost_filesystem pthread [ libraries ] : <target-os>linux ;
alias boostStaticLibs : boost_system/<link>static : <target-os>linux ;
alias boostLibs : [ boost-libs ] : <target-os>linux ;

#darwin aliases
alias unixsocket_cpp : source/mscl/Communication/UnixSocketConnection.cpp : <target-os>darwin ;
alias upnp_files : : <target-os>darwin ;
alias boostLibs : boost_system boost_filesystem pthread [ libraries ] : <target-os>darwin ;
alias boostStaticLibs : boost_system/<link>static : <target-os>darwin ;
alias boostLibs : [ boost-libs ] : <target-os>darwin ;

alias msclSrcs
: [ glob source/*.cpp ]
Expand Down Expand Up @@ -127,7 +142,6 @@ make $(SWIG_PYTHON) : : @common.mkdir ;

#Setup dependencies for the mscl python project
DEPENDS _mscl : $(SWIG_PYTHON) ;
DEPENDS _mscl-dynamic : $(SWIG_PYTHON) ;

alias MSCL_Main_Interface.cpp : [ cast _ swigi : source/mscl/Wrapper/MSCL_Main_Interface.i ] ; #Reference the .i file as a swig_i file

Expand All @@ -148,23 +162,6 @@ python-extension _mscl
<target-os>darwin:<define>UNIX_BUILD
;

#Define the python mscl build
python-extension _mscl-dynamic
: MSCL_Main_Interface.cpp
mscl #Include the MSCL Source
boostLibs
: <include>source/mscl/Wrapper/
<swig-options>-python
<swig-options>-modern
<swig-options>"-outdir \"$(SWIG_PYTHON)\""
<swig-options>"$(configured-flags)"
<cflags>"$(configured-flags)"
<target-os>linux:<swig-options>-DUNIX_BUILD
<target-os>linux:<define>UNIX_BUILD
<target-os>darwin:<swig-options>-DUNIX_BUILD
<target-os>darwin:<define>UNIX_BUILD
;

#Copy all the header files and put them in an output directory
install stage_headers
: [ glob-tree *.h : .svn stdafx.h ]
Expand All @@ -180,14 +177,12 @@ install stage_c++
;
explicit stage_c++ ;


#Copy the python directory
install stage_python
: _mscl [ path.glob-tree $(SWIG_PYTHON) : *.py ]
: <location>$(STAGING_DIR)/Python/
;
explicit stage_python_x86 ;

explicit stage_python ;

#Copy the python (x86) directory
install stage_python_x86
Expand All @@ -203,12 +198,6 @@ install stage_python_x64
;
explicit stage_python_x64 ;

install stage_python_dynamic
: _mscl-dynamic [ path.glob-tree $(SWIG_PYTHON) : *.py ]
: <location>$(STAGING_DIR)/Python
;
explicit stage_python_dynamic ;

#Make an alias for all of the copying
alias stage_all
: stage_c++ stage_python_x86 stage_python_x64 #stage_headers
Expand Down
5 changes: 5 additions & 0 deletions MSCL/source/mscl/Communication/Connection.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -261,5 +261,10 @@ namespace mscl
return result;
}

void Connection::updateBaudRate(uint32 baudRate)
{
m_impl->updateBaudRate(baudRate);
}

//====================================================================================================================================================
}
11 changes: 11 additions & 0 deletions MSCL/source/mscl/Communication/Connection.h
Original file line number Diff line number Diff line change
Expand Up @@ -340,6 +340,17 @@ namespace mscl
//Exceptions:
// - <Error_Connection>: a connection error has occurred, such as the device being unplugged.
ConnectionDebugDataVec getDebugData(uint32 timeout = 0);

//API Function: updateBaudRate
// Updates the serial connection baud rate. If this is not a serial connection, this function does nothing.
// Important: The connection to the port will be closed and re-opened at the new baud rate.
//
//Parameters:
// baudRate - the baud rate at which to reestablish the connection
//
//Exceptions:
// - <Error_Connection>: a connection error has occurred, such as the device being unplugged.
void updateBaudRate(uint32 baudRate);
};

}
11 changes: 11 additions & 0 deletions MSCL/source/mscl/Communication/Connection_Impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,17 @@ namespace mscl
//Exceptions:
// - <Error_Connection>: a connection error has occurred, such as the device being unplugged.
virtual void getDebugData(ConnectionDebugDataVec& data, uint32 timeout) = 0;

//API Function: updateBaudRate
// Updates the serial connection baud rate. If this is not a serial connection, this function does nothing.
// Important: The connection to the port will be closed and re-opened at the new baud rate.
//
//Parameters:
// baudRate - the baud rate at which to reestablish the connection
//
//Exceptions:
// - <Error_Connection>: a connection error has occurred, such as the device being unplugged.
virtual void updateBaudRate(uint32 baudRate) {};
};


Expand Down
12 changes: 12 additions & 0 deletions MSCL/source/mscl/Communication/SerialConnection.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -99,4 +99,16 @@ namespace mscl
m_established = true;
}
}

void SerialConnection::updateBaudRate(uint32 baudRate)
{
if (m_baudRate == baudRate)
{
return;
}

disconnect();
m_baudRate = baudRate;
reconnect();
}
}
11 changes: 11 additions & 0 deletions MSCL/source/mscl/Communication/SerialConnection.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,17 @@ namespace mscl
// A description of the connection
virtual std::string description();

//API Function: updateBaudRate
// Updates the serial connection baud rate.
// Important: The connection to the port will be closed and re-opened at the new baud rate.
//
//Parameters:
// baudRate - the baud rate at which to reestablish the connection
//
//Exceptions:
// - <Error_Connection>: a connection error has occurred, such as the device being unplugged.
void updateBaudRate(uint32 baudRate) override;

private:
//Function: establishConnection
// Initializes and opens the current connection
Expand Down
4 changes: 2 additions & 2 deletions MSCL/source/mscl/LibVersion.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ MIT Licensed. See the included LICENSE.txt for a copy of the full MIT License.

#ifndef SWIG
//update with each release
#define MSCL_MAJOR 51
#define MSCL_MINOR 0
#define MSCL_MAJOR 52
#define MSCL_MINOR 2
#define MSCL_PATCH 1
#endif

Expand Down
21 changes: 21 additions & 0 deletions MSCL/source/mscl/MicroStrain/Inertial/Commands/UARTBaudRate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,27 @@ namespace mscl
return returnData;
}

uint32 UARTBaudRate::peekParameterValue(const Bytes& commandBytes)
{
// parameter index is first value after fn selector, 4 bytes long
uint8 index = GenericMipCommand::CMD_FN_SELCTOR_INDEX + 1;
uint8 size = 4;

if (commandBytes.size() < static_cast<size_t>(index + size))
{
return 0;
}

uint32 r = commandBytes[index];
for (uint8 i = 1; i < size; i++)
{
r = r << 8;
r |= commandBytes[index + i];
}

return r;
}

UARTBaudRate::operator ByteStream() const
{
ByteStream byteCommand;
Expand Down
13 changes: 12 additions & 1 deletion MSCL/source/mscl/MicroStrain/Inertial/Commands/UARTBaudRate.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,20 @@ namespace mscl
// response - The <GenericMipCmdResponse> object from which to get formatted data.
//
//Returns:
// ConstellationSettingsData - An object with the data returned from the device.
// uint32 - The baud rate value returned from the device.
static uint32 getResponseData(const GenericMipCmdResponse& response);

//Function: peekParameterValue
// Read the baud rate parameter value from the provided UART Baud Rate command bytes.
// Note: The provided command bytes are assumed to be formatted properly, no validation occurs.
//
//Parameter:
// commandBytes - The <Bytes> representing a complete UART Baud Rate command
//
//Returns:
// uint32 - the baud rate parameter value within the commandBytes object, returns 0 if parameter value is beyond the bounds of commandBytes
static uint32 peekParameterValue(const Bytes& commandBytes);

//Function: operator ByteStream
// Converts this class to a ByteStream.
operator ByteStream() const;
Expand Down
Loading

0 comments on commit c45b978

Please sign in to comment.