Skip to content

Commit

Permalink
Merge pull request #3 from scy-phy/modbus
Browse files Browse the repository at this point in the history
Modbus
  • Loading branch information
francozappa authored Apr 10, 2017
2 parents b2c47ab + efb84d8 commit 6f710c4
Show file tree
Hide file tree
Showing 24 changed files with 1,831 additions and 457 deletions.
18 changes: 11 additions & 7 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
# MiniCPS .travis.yml
#
# Commits that have [ci skip] anywhere in the commit messages are ignored by Travis CI.
# NOTE: Commits that have [ci skip] anywhere in the commit messages are ignored by Travis CI.
# NOTE: Validate file using https://lint.travis-ci.org/

# NOTE: When sudo is enabled Travis will use a non docker based infrastructure
# sudo: required

language: python

Expand All @@ -9,22 +13,22 @@ branches:
- master

python:
- "2.6"
- "2.7"

# travis-ci automatically preinstalls
#
# NOTE: Travis-ci automatically preinstalls
# pytest
# nose
# mock

# travis-ci automatically installs
# NOTE: Travis-ci automatically runs
#
# pip install -r requirements.txt
install:
- pip install -r requirements.txt

# TODO: add mininet-based tests
# TODO: Add mininet-based tests
script: make tests-travis

# NOTE: https://docs.travis-ci.com/user/notifications/
notifications:
email:
on_success: change
Expand Down
18 changes: 15 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
MININET = sudo mn

PYTHON = sudo python
PYTHON_OPTS =
PYTHON_OPTS =

# regex testMatch: (?:^|[b_.-])[Tt]est)
# --exe: include also executable files
Expand All @@ -14,10 +14,10 @@ PYTHON_OPTS =
# TODO: add testing conditionals for verbosity, doctest plugin and coverage plugin
# http://web.mit.edu/gnu/doc/html/make_7.html

# sudo because of mininet
# NOTE: sudo because of mininet
TESTER = sudo nosetests
TESTER_TRAVIS = nosetests
TESTER_OPTS = -s -v --exe
TESTER_OPTS = -s -v --exe --rednose
TESTER_OPTS_COV_HTML = $(TESTER_OPTS) --with-coverage --cover-html

# http://stackoverflow.com/questions/3931741/why-does-make-think-the-target-is-up-to-date
Expand Down Expand Up @@ -81,18 +81,30 @@ test-networks:
test-sdns:
$(TESTER) $(TESTER_OPTS) tests/sdns_tests.py


test-protocols:
$(TESTER) $(TESTER_OPTS) tests/protocols_tests.py

test-enip:
$(TESTER) $(TESTER_OPTS) tests/protocols_tests.py:TestEnipProtocol

test-modbus:
$(TESTER) $(TESTER_OPTS) tests/protocols_tests.py:TestModbusProtocol


test-utils:
$(TESTER) $(TESTER_OPTS) tests/utils_tests.py

test-states:
$(TESTER) $(TESTER_OPTS) tests/states_tests.py


test-devices:
$(TESTER) $(TESTER_OPTS) tests/devices_tests.py

test-device:
$(TESTER) $(TESTER_OPTS) tests/devices_tests.py:TestDevice


# clean {{{1
clean: clean-cover clean-pyc clean-logs
Expand Down
45 changes: 33 additions & 12 deletions RELEASES.md
Original file line number Diff line number Diff line change
@@ -1,18 +1,39 @@
Version 1.0.0 (2016-07-01)
==========================
# Releases and change log

Public API
----------
## Version 1.1.0 (2017-TODO-TODO)

* network API core functions: `send` and `receive`
* physical layer API core functions: `set` and `get`
### Public API

Industrial protocol support
----------------------------
* Bug fixes

* subset of Ethernet/IP: `cpppo`
### Industrial protocol support

Physical layer backend support
------------------------------
* Modbus through `pymodbus`

* SQLite3: `sqlite3`
### Test suite

* Added `rednose` for better user interface
* Added `raises` decorator to test for expected Exceptions
* Bug fixes


### Misc

* We are an awesome ICS security tool:
[![Awesome](https://cdn.rawgit.com/sindresorhus/awesome/d7305f38d29fed78fa85652e3a63e154dd8e8829/media/badge.svg)](https://github.com/hslatman/awesome-industrial-control-system-security)


## Version 1.0.0 (2016-07-01)

### Public API

* Network API core functions: `send` and `receive`
* Physical layer API core functions: `set` and `get`

### Industrial protocol support

* Subset of Ethernet/IP through `cpppo`

### Physical layer backend support

* SQLite3 through `sqlite3`
4 changes: 2 additions & 2 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,9 @@
# built documents.
#
# The short X.Y version.
version = '1.0'
version = '1.1'
# The full version, including alpha/beta/rc tags.
release = '1.0.0'
release = '1.1.0'

# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.
Expand Down
4 changes: 2 additions & 2 deletions examples/swat-s1/plc1.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,12 +81,12 @@ def main_loop(self):

# TODO: use it when implement raw water tank
# read from PLC2 (constant value)
fit201 = float(self.recieve(FIT201_2, PLC2_ADDR))
fit201 = float(self.receive(FIT201_2, PLC2_ADDR))
print "DEBUG PLC1 - receive fit201: %f" % fit201
self.send(FIT201_1, fit201, PLC1_ADDR)

# # read from PLC3
lit301 = float(self.recieve(LIT301_3, PLC3_ADDR))
lit301 = float(self.receive(LIT301_3, PLC3_ADDR))
print "DEBUG PLC1 - receive lit301: %f" % lit301
self.send(LIT301_1, lit301, PLC1_ADDR)

Expand Down
2 changes: 1 addition & 1 deletion examples/swat-s1/plc2.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ def main_loop(self):
print "DEBUG PLC2 - get fit201: %f" % fit201

self.send(FIT201_2, fit201, PLC2_ADDR)
# fit201 = self.recieve(FIT201_2, PLC2_ADDR)
# fit201 = self.receive(FIT201_2, PLC2_ADDR)
# print "DEBUG PLC2 - receive fit201: ", fit201

time.sleep(PLC_PERIOD_SEC)
Expand Down
8 changes: 4 additions & 4 deletions examples/swat-s1/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,10 @@ def __init__(self, name, net):
'plc1', 'plc2', 'plc3', 's1')

# SPHINX_SWAT_TUTORIAL RUN(
# plc2.cmd(sys.executable + ' plc2.py &')
# plc3.cmd(sys.executable + ' plc3.py &')
# plc1.cmd(sys.executable + ' plc1.py &')
# s1.cmd(sys.executable + ' physical_process.py &')
plc2.cmd(sys.executable + ' plc2.py &')
plc3.cmd(sys.executable + ' plc3.py &')
plc1.cmd(sys.executable + ' plc1.py &')
s1.cmd(sys.executable + ' physical_process.py &')
# SPHINX_SWAT_TUTORIAL RUN)

CLI(self.net)
Expand Down
2 changes: 1 addition & 1 deletion examples/toy/plc1.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ def main_loop(self, sleep=0.5):
count = 0
END = 6e6
while(True):
rec_s31 = self.recieve(SENSOR3_1, PLC1_ADDR)
rec_s31 = self.receive(SENSOR3_1, PLC1_ADDR)
# print 'DEBUG: toy plc1 receive SENSOR3_1: ', rec_s31
get_s32 = self.get(SENSOR3_2)
print 'DEBUG: toy plc1 get SENSOR3_2: ', get_s32
Expand Down
Loading

0 comments on commit 6f710c4

Please sign in to comment.