Difference between revisions of "Run WCPS On Mac Guide"

From Cyber-Physical Systems Laboratory
Jump to navigationJump to search
 
(32 intermediate revisions by the same user not shown)
Line 1: Line 1:
 
==Upgrade to El Capitan==
 
==Upgrade to El Capitan==
  
==0.1 Install Xcode==
+
==Download WCPSv3 installation folder from Github==
 +
[https://github.com/WU-CPSL/WCPSv3 WCPSv3 installation folder] for Mac user.
 +
 
 +
==Install Xcode==
 
<pre>
 
<pre>
 
If Apple store doesn't work or get stuck (which is the usual case) then install it from apple developer web page.
 
If Apple store doesn't work or get stuck (which is the usual case) then install it from apple developer web page.
 
</pre>
 
</pre>
  
==1. Install gcc==
+
==Install gcc==
 
:'''a.'''    Do this first: '''xcode-select --install'''
 
:'''a.'''    Do this first: '''xcode-select --install'''
 
   
 
   
Line 21: Line 24:
  
  
==='''1.1 Trouble Shooting'''===
+
==='''Trouble Shooting'''===
  
 
:Error: Current platform "darwin 15" does not match expected platform "darwin 14"
 
:Error: Current platform "darwin 15" does not match expected platform "darwin 14"
Line 43: Line 46:
 
::---Might need to do '''sudo xcodebuild -license'''
 
::---Might need to do '''sudo xcodebuild -license'''
  
==='''1.2 Check:'''===
+
==='''Check:'''===
  
 
:Successful installation of gcc43 could be checked by the command: '''gcc --version'''. If the below message is shown, then the installation is successful.
 
:Successful installation of gcc43 could be checked by the command: '''gcc --version'''. If the below message is shown, then the installation is successful.
Line 49: Line 52:
 
:::[[File:Image001.png|500px]]
 
:::[[File:Image001.png|500px]]
  
 
+
==Install JDK==
 
 
=='''2. Install JDK'''==
 
  
 
:'''a.'''  Find the package: jdk-8u65-macosx-x64.dmg
 
:'''a.'''  Find the package: jdk-8u65-macosx-x64.dmg
 
:'''b.'''  Install package using the installer
 
:'''b.'''  Install package using the installer
  
 
+
==Install msp430-gcc version 4.6.3==
=='''3. Install msp430-gcc version 4.6.3'''==
 
 
:'''a.'''  sudo port install msp430-gcc
 
:'''a.'''  sudo port install msp430-gcc
 
:'''b.'''    sudo port install msp430-libc
 
:'''b.'''    sudo port install msp430-libc
 
: Go back to step 1 if error.
 
: Go back to step 1 if error.
  
 +
==Download TinyOS from Github==
  
=='''4. Download TinyOS from Github'''==
+
==Download nesC-1.3.4 from Sourceforge and install==
 
 
 
 
=='''5. 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".
 
:'''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".
 
   
 
   
Line 86: Line 84:
 
::Replace step c by '''./configure --prefix=$TOSROOT/../nesc''' and reinstall.
 
::Replace step c by '''./configure --prefix=$TOSROOT/../nesc''' and reinstall.
  
 
+
==Install TinyOS tools==
=='''6. Install TinyOS tools'''==
 
 
:a.    autoconf and automake are not included so needed to be installed (run the command, '''sudo port install automake autoconf libtool''')
 
:a.    autoconf and automake are not included so needed to be installed (run the command, '''sudo port install automake autoconf libtool''')
 
   
 
   
Line 104: Line 101:
 
::iv.        '''sudo make install'''
 
::iv.        '''sudo make install'''
  
 
+
==Create TinyOS.sh file in the TinyOS folder, and add source and classpath to ~/.bashrc==
=='''7.    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:
 
:.bashrc file should contain and only contain the following line:
 
:'''''source <local-tinyos-path>/tinyos.sh'''''
 
:'''''source <local-tinyos-path>/tinyos.sh'''''
Line 116: Line 112:
 
:If not, please run the command: '''source ~/.bashrc''' after starting terminal.
 
:If not, please run the command: '''source ~/.bashrc''' after starting terminal.
  
 
+
==Testing the TinyOS system==
=='''8. Testing the TinyOS system'''==
 
 
:In '''tinyos-2.x/apps/Blink''', run the following command: '''make telosb'''.
 
:In '''tinyos-2.x/apps/Blink''', run the following command: '''make telosb'''.
 
   
 
   
Line 124: Line 119:
 
:::[[File:Image007.png|500px]]
 
:::[[File:Image007.png|500px]]
  
 
+
==Installing Matlab r2013a (No need to Uninstall newer versions)==
=='''9. Installing Matlab r2013a (No need to Uninstall newer versions)'''==
 
 
:'''a.''' Go to MathWorks and follow the instructions for downloading Matlab r2013a.                 
 
:'''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.''
 
:''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.''
Line 138: Line 132:
 
:''Matlab_r2013a should be fully functional by now.''
 
:''Matlab_r2013a should be fully functional by now.''
  
 
+
==Build micaz TOSSIM library==
=='''10. Build micaz TOSSIM library'''==
+
:'''a.'''    In the LinearSystemWCPS_publish folder, find Makefile and change the path:
:'''a.'''    In the wcps_iccps15_bo_version_v2 folder, find Makefile and change the path:
 
 
:PFLAGS += <local-path-to-TinyOS-2.x-jhu>/TinyOS-2.x-jhu/pure-tdma
 
:PFLAGS += <local-path-to-TinyOS-2.x-jhu>/TinyOS-2.x-jhu/pure-tdma
 
      
 
      
Line 146: Line 139:
 
:change '''#include <Python.h>''' to '''#include <Python/Python.h>''' in line 149.
 
:change '''#include <Python.h>''' to '''#include <Python/Python.h>''' in line 149.
 
   
 
   
:'''c.'''    In terminal, in the directory of wcps_iccps15_bo_version_v2, run command:
+
:'''c.'''    In terminal, in the directory of LinearSystemWCPS_publish, run command:
 
:'''make micaz sim'''.
 
:'''make micaz sim'''.
  
Line 157: Line 150:
 
:https://www.python.org/downloads/release/python-2710/ to download.
 
:https://www.python.org/downloads/release/python-2710/ to download.
  
 
+
==Run WNCS simulation==
=='''11. Run the Matlab model'''==
 
 
:'''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.py''' to launch the Python server.
:'''b.'''    Run the command: '''python tossim-event-server-iccps15.py -69''' to launch the Python server
+
:'''c.'''    Run '''Linear_WCS_main.m''' in Matlab 2013a.
+
    Possible Matlab Error: matlab mex macosx.10.7
:'''c.'''    Possible Matlab Error: matlab mex macosx.10.7
 
 
::'''i.''' In the MATLAB Command Window, execute the following commands:
 
::'''i.''' In the MATLAB Command Window, execute the following commands:
 
:::'''cd(matlabroot)'''
 
:::'''cd(matlabroot)'''
Line 178: Line 169:
 
:In line 819, change code to:  '''''typedef UINT16_T CHAR16_T;'''''
 
:In line 819, change code to:  '''''typedef UINT16_T CHAR16_T;'''''
 
   
 
   
:'''e.'''    Run: CoupledTanks_WCPS_2_DoublePS.m
+
:'''e.'''    Run: '''Linear_WCS_main.m''' again.
 
   
 
   
 
:'''f.'''    If successful, the command window should look like:
 
:'''f.'''    If successful, the command window should look like:

Latest revision as of 15:11, 17 February 2017

Upgrade to El Capitan

Download WCPSv3 installation folder from Github

WCPSv3 installation folder for Mac user.

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.py to launch the Python server.
c. Run Linear_WCS_main.m in Matlab 2013a.
   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: Linear_WCS_main.m again.
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 : )