Coder Social home page Coder Social logo

epics-modules / modbus Goto Github PK

View Code? Open in Web Editor NEW
35.0 20.0 25.0 5.49 MB

EPICS support for communication with Programmable Logic Controllers (PLCs) and other devices via the Modbus protocol over TCP, serial RTU, and serial ASCII links

License: Other

Makefile 1.68% IDL 0.40% C 12.14% C++ 67.95% Batchfile 17.49% Python 0.36%
epics modbus

modbus's Introduction

An EPICS module that supports communication with Programmable Logic Controllers (PLCs) and other devices via the Modbus protocol over TCP, serial RTU, and serial ASCII links.

The modbus software provides a layer between standard EPICS asyn device support, and the EPICS asyn TCP/IP or serial port driver.

Additional information:

modbus's People

Contributors

anjohnson avatar gabrielfedel avatar justincslac avatar krisztianloki avatar markrivers avatar nickez avatar nusaqib avatar prjemian avatar ralphlange avatar rsluiter avatar timmmooney avatar tynanford avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

modbus's Issues

Support for absolute Modbus addressing.

Currently each driver is limited to addressing at most 125 registers (read operations) or 123 registers (write operations), and the asyn "addr" field specified an offset relative to the modbusStartAddress passed as the fifth argument to drvAsynModbusConfigure().

This is inconvenient when many Modbus registers need to be written to and these are widely scattered over the 16-bit Modbus address space.

Need to support 64-bit integers and byte-swapped versions of 32-bit and 64-bit datatypes

Currently this driver supports big-endian and little-endian versions of 32-bit integer numbers, and big-endian and little-endian versions of 32 and 64-bit floating point numbers. However, some vendors also swap the bytes within the 16-bit words for these data types.

I looked at the Modbus Slave Emulator program I have installed on my PC. It handles the byte-swapped versions of all 32-bit and 64-bit data types, i.e. both INT and FLOAT.

Now that EPICS supports int64in and int64out records 64-bit integer values should also be supported.

We thus need to add support for 10 more data types:

  • INT32_LE_BS
  • INT32_BE_BS
  • INT64_LE
  • INT64_LE_BS
  • INT64_BE
  • INT64_BE_BS
  • FLOAT32_LE_BS
  • FLOAT32_BE_BS
  • FLOAT64_LE_BS
  • FLOAT64_BE_BS

segmentation fault

I occasionally get a SIGSEGV in the modbus IOC. Now for the first time it happened when running in gdb. The backtrace is

2016/06/15 14:42:52.928 drvModbusAsyn::doModbusIO port block1316 error calling writeRead, error=127.0.0.1:5502 timeout: Resource temporarily unavailable, nwrite=6/6, nread=0

Program received signal SIGSEGV, Segmentation fault.
[Switching to Thread 0x7ffff42c3700 (LWP 315)]
lockPort (pasynUser=0x0) at ../../asyn/asynDriver/asynManager.c:1677
1677 port *pport = puserPvt->pport;
(gdb) bt

0 lockPort (pasynUser=0x0) at ../../asyn/asynDriver/asynManager.c:1677

1 0x00007ffff7bd28ae in readPoller (pPlc=0x6ae7b0) at ../drvModbusAsyn.c:1319

2 0x00007ffff61fb07f in start_routine (arg=0x6b0d10)

at ../../../src/libCom/osi/os/posix/osdThread.c:385

3 0x00007ffff5379454 in start_thread (arg=0x7ffff42c3700) at pthread_create.c:334

4 0x00007ffff5677edd in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:109

I will leave the gdb session open so that I can give more feedback as required.

String support

The Modbus driver has not supported string data type. Some vendors use Modbus registers to contain string data. The driver should support reading and writing strings to Modbus devices.

drvModbusAsynConfigure should accept strings for the dataType argument

The drvInfo string uses strings like INT32_LE for the datatype of a specific record. However, drvModbusAsynConfigure only allows integer values, which are the modbusDataType_t enums, for the dataType argument.

drvModbusAsynConfigure should accept either numbers or the same strings used by the records for the dataType argument. If the first character of the string is a digit then it should be assumed to be the enum value, for backwards compatibility. If it is not a digit then it must be one of the datatype strings defined in drvModbusAsyn.h. The comparison should be case-insensitive.

This has been implemented in the datatype_string branch.

asynInterposeEos should be enabled for low-level drivers

The current modbus documentation and example IOCs do not load the asynInterposeEos interface (they set noProcessEos=1), except for Modbus serial.

This works OK with real Modbus TCP devices because the response will be returned in a single packet that should contain the requested number of bytes. But for devices with a serial interface, including those with an Ethernet terminal server, the response may be broken into multiple packets. In that case the asynInterposeEos layer is needed so that it does not return until the requested number of bytes have been received, or there is a timeout.

It does not hurt to load the asynInterposeEos interface even if it is not strictly needed. The documentation and example IOCs should be changed to set noProcessEos=0.

Minor: Still relies on a modbusInclude.dbd file

An EPICS user wanted to run QSRV on the modbus IOC. My initial instructions on how to do that assumed that the IOC's DBD file was generated in the Makefile. I recommend replacing the modbusInclude.dbd file with the more modern approach.

Making this change might be a good Codeathon project.

The report() function does not show the default datatype of the port

The report function previously did not report the default datatype for that port.

This has now been added in the datatype_string branch.

It shows the default datatype, both as the integer enum value, and as the corresponding string. For example:

modbus port: A300_In_Word
    initialized:        true
    asynOctet server:   sim1
    modbusSlave:        0
    modbusFunction:     3
    modbusStartAddress: 0454
    modbusLength:       0120
    absoluteAddressing: false
    dataType:           22 (FLOAT32_LE_BS)
    plcType:
    I/O errors:         0
    Read OK:            1
    Write OK:           0
    pollDelay:          0.100000
    Time for last I/O   11 msec
    Max. I/O time:      11 msec
    Time per hist. bin: 1 msec

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.