Giter Site home page Giter Site logo

tolk's People

Contributors

appeltabak avatar jaapz avatar orangetux avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

tolk's Issues

Implement custom JSON-RPC Errors.

Currently when a Modbus server returns an Modbus error code, Tolk returns a JSON-RPC error with code -32603: Internal JSON-RPC error containing the stacktrace. Response below fails with Modbus exception code 2: Illegal Data Address.

{
    "error": {
        "code": -32603,
        "data": "Traceback (most recent call last):\n  File \"/home/auke/projects/tolk/.env/local/lib/python2.7/site-packages/pyjsonrpc/rpclib.py\", line 115, in call\n    result = rpc_function(*positional_params, **named_params)\n  File \"/home/auke/projects/tolk/scripts/../tolk/json_rpc.py\", line 25, in read_coils\n    int(quantity))\n  File \"/home/auke/projects/tolk/.env/local/lib/python2.7/site-packages/modbus_tk/utils.py\", line 26, in new\n    raise excpt\nModbusError: Modbus Error: Exception code = 2\n",
        "message": "Internal JSON-RPC error."
    },
    "id": 246344073102444981514353044232564665595,
    "jsonrpc": "2.0"
}

The JSON-RPC specification leaves room for custom errors.
Below the surface Tolk uses Modbus-TK which implements 7 Modbus error codes. Tolk should return custom JSON-RPC errors reflecting the Modbus error code that was returned. Tolk should implement the following error codes:

  • 1: Illegal Function as JSON-RPC error -32001: Illegal Function
  • 2: Illegal Data Address as JSON-RPC error -32002: Illegal Data Address
  • 3: Illegal Data Value as JSON-RPC error -32003: Illegal Data Value
  • 4: Slave Device Failure as JSON-RPC error -32004: Slave Device Failure
  • 5: Command Acknowledge as JSON-RPC error -32005: Command Acknowledge
  • 6: Slave Device Busy as JSON-RPC error -32006: Slave Device Busy
  • 8: Memory Parity Error as as JSON-RPC error -32008: Memory Parity Error

An error response now could look like this:

{
    "error": {
        "code": -32001,
        "data": "Function code 27 is not  valid."
    },
    "id": 246344073102444981514353044232564665595,
    "jsonrpc": "2.0"
}

Python 3 support

We need to support python 3. This is going to need a complete rewrite of the modbus protocol implementation, as modbus_tk is not python3 compatible, and is generally not very nice to work with (bad exception handling, etc).

This issue serves as a central place for discussing python 3 support and implementation progress.

Move to umodbus

Tolk should switch from modbus_tk to umodbus when it's stable and feature complete enough.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.