Difference between revisions of "Run WCPS On Mac Guide"

From Cyber-Physical Systems Laboratory
Jump to navigationJump to search
Line 148: Line 148:
 
==Run WNCS simulation==
 
==Run WNCS simulation==
 
:'''a.'''      cd to where the application code is,
 
:'''a.'''      cd to where the application code is,
::e.g. <local-directory>/wcps_iccps15_bo_version_v2
+
::e.g. <local-directory>/LinearSystemWCPS_publish
+
:'''b.'''    Run the command: '''python tossim-event-server''' to launch the Python server
:'''b.'''    Run the command: '''python tossim-event-server-iccps15.py -69''' to launch the Python server
 
 
   
 
   
 
:'''c.'''    Possible Matlab Error: matlab mex macosx.10.7
 
:'''c.'''    Possible Matlab Error: matlab mex macosx.10.7

Revision as of 20:22, 30 August 2016

Upgrade to El Capitan

Install Xcode

If Apple store doesn't work or get stuck (which is the usual case) then install it from apple developer web page.

Install gcc

a. Do this first: xcode-select --install
b. sudo port install gcc43
sudo port install gcc_select
port select --list gcc
sudo port select --set gcc mp-gcc43
Please reboot terminal after installing gcc.


Trouble Shooting

Error: Current platform "darwin 15" does not match expected platform "darwin 14"
Error: OS platform mismatch while executing "mportinit ui_options global_options global_variations"
Error: /opt/local/bin/port: Failed to initialize MacPorts , OS platform mismatch
---If seen the above error(s), and if you recently updated to OS X El Capitan, then please go to "https://trac.macports.org/wiki/Migration" and follow the instructions to download the command line tool (if not yet downloaded) and get the latest Xcode, reinstall new Macports base, and reinstall all your ports.
---Note that building gcc48 may take relatively long time (depends on the number of ports previously installed on the computer).
---Please do not forget to reboot terminal after finishing the above steps.
Error: The following dependencies were not installed: libgcc libgcc45
---To report a bug, follow the instructions in the guide:
http://guide.macports.org/#project.tickets
Error: Processing of port gcc43 failed
---Might need to do sudo xcodebuild -license

Check:

Successful installation of gcc43 could be checked by the command: gcc --version. If the below message is shown, then the installation is successful.
Image001.png

Install JDK

a. Find the package: jdk-8u65-macosx-x64.dmg
b. Install package using the installer

Install msp430-gcc version 4.6.3

a. sudo port install msp430-gcc
b. sudo port install msp430-libc
Go back to step 1 if error.

Download TinyOS from Github

Download nesC-1.3.4 from Sourceforge and install

a. change directories to the correct directories for the two files: ncc and mig. The files should be find in "tinyos-2.x-tools/bin".
b. In the directory of "nescc 1.3.4", do make clean
c. In the same directory, do ./configure
If you get permission denied do chmod +x configure
d. make
If you get permission denied for a file, then it might be set to non-executable, use chmod a+x to make the file executable.
e. sudo make install
f. Check by doing ncc --version if seen the below message then the software is successfully installed.
Image003.png
If you're not getting this, troubleshoot:
Replace step c by ./configure --prefix=$TOSROOT/../nesc and reinstall.

Install TinyOS tools

a. autoconf and automake are not included so needed to be installed (run the command, sudo port install automake autoconf libtool)
b. Go to TinyOS folder>>tools
c. Fix the following files (should be already fixed)
i. In NativeSerial_darwin.cpp add #include <string.h> and #include <stdlib.h>
ii. In tos-locate-jre add jhome=/System/Library/Frameworks/JavaVM.framework/Versions/Current,
xcode_jdk=/System/Library/Frameworks/JavaVM.framework/Versions/Current/Headers
d. Install TinyOS tools
In directory tinyos-2.x/tools, do the following:
i. ./Bootstrap
ii. ./configure
iii. make
iv. sudo make install

Create TinyOS.sh file in the TinyOS folder, and add source and classpath to ~/.bashrc

.bashrc file should contain and only contain the following line:
source <local-tinyos-path>/tinyos.sh
e.g.
Image005.png
Note: When starting terminal, .bashrc should run automatically to set environmental variables. Environmental variables could be checked by the command: env.
If not, please run the command: source ~/.bashrc after starting terminal.

Testing the TinyOS system

In tinyos-2.x/apps/Blink, run the following command: make telosb.
If the following is shown, then the TinyOS system is good to go.
Image007.png

Installing Matlab r2013a (No need to Uninstall newer versions)

a. Go to MathWorks and follow the instructions for downloading Matlab r2013a.
Note that for OS, uncheck Safari's Open "safe" files after downloading so that the files we download are in ".zip". Please make sure to download all packages in order to save yourself from future hassle.
b. Check out the link below to install Java SE6 for Matlab r2013a because upgrading the System to El Capitan might uninstall the previous Java SE 6. And you will need to use the terminal to make sure the computer uses SE6 to install Matlab.
http://www.mathworks.com/matlabcentral/answers/161347-how-can-i-install-matlab-versions-r2011a-r2013a-on-mac-os-x-10-10-yosemite-or-later
c. After successfully installing Matlab, if you get error starting it, please check out the link below and download a patch file for Matlab_r2013a.
https://www.mathworks.com/support/bugreports/1098655
Matlab_r2013a should be fully functional by now.

Build micaz TOSSIM library

a. In the LinearSystemWCPS_publish folder, find Makefile and change the path:
PFLAGS += <local-path-to-TinyOS-2.x-jhu>/TinyOS-2.x-jhu/pure-tdma
b. If python cannot be found, please go to: /TinyOS-2.x-jhu/opt/tinyos-2.x/tos/lib/tossim/tossim_wrap.cxx,
change #include <Python.h> to #include <Python/Python.h> in line 149.
c. In terminal, in the directory of LinearSystemWCPS_publish, run command:
make micaz sim.
Successful built should look like:
Image009.png
Note: make sure that Python 2.7.10 is installed on the computer. If not please go to:
https://www.python.org/downloads/release/python-2710/ to download.

Run WNCS simulation

a. cd to where the application code is,
e.g. <local-directory>/LinearSystemWCPS_publish
b. Run the command: python tossim-event-server to launch the Python server
c. Possible Matlab Error: matlab mex macosx.10.7
i. In the MATLAB Command Window, execute the following commands:
cd(matlabroot)
cd bin
edit mexopts.sh
ii. Save a backup copy of this file somewhere in case you make a mistake and need to revert your changes.
iii. Scroll down to the Mac ("maci64") section of this file, beginning at line 128.
iv. Replace all instances of 10.7 with 10.11(the current version); there are four of these in all (a fifth may be found in comments only)
v. Save the file, then execute the following command in the MATLAB Command Window: mex -setup
d. Modify the file in the following path:
/Applications/MATLAB_R2013a.app/extern/include/tmwtypes.h
In line 819, change code to: typedef UINT16_T CHAR16_T;
e. Run: CoupledTanks_WCPS_2_DoublePS.m
f. If successful, the command window should look like:
Image011.png
Note: Other errors might due to lack of certain package in step 9.
Congratulations you came through all of this, now you can finally enjoy using WCPS : )