TOP Contributors

  1. MIKROE (2760 codes)
  2. Alcides Ramos (374 codes)
  3. Shawon Shahryiar (307 codes)
  4. jm_palomino (118 codes)
  5. Bugz Bensce (90 codes)
  6. S P (73 codes)
  7. dany (71 codes)
  8. MikroBUS.NET Team (35 codes)
  9. NART SCHINACKOW (34 codes)
  10. Armstrong Subero (27 codes)

Most Downloaded

  1. Timer Calculator (139227 times)
  2. FAT32 Library (71732 times)
  3. Network Ethernet Library (57114 times)
  4. USB Device Library (47426 times)
  5. Network WiFi Library (43051 times)
  6. FT800 Library (42401 times)
  7. GSM click (29832 times)
  8. mikroSDK (28051 times)
  9. PID Library (26881 times)
  10. microSD click (26197 times)
Libstock prefers package manager

Package Manager

We strongly encourage users to use Package manager for sharing their code on Libstock website, because it boosts your efficiency and leaves the end user with no room for error. [more info]

< Back
Project

Modbus Common Gateway Interface (CGI)

Rating:

2

Author: Simon Platten

Last Updated: 2013-02-27

Package Version: 1.0.0.4

Category: Communication

Downloaded: 1803 times

Not followed.

License: MIT license  

This is a modbus CGI which can be used with any Windows web-server. I used Apache 2.2 to develop and test this.

It allows you to send requests to a modbus network using HTTP get requests.

No Abuse Reported

Do you want to subscribe in order to receive notifications regarding "Modbus Common Gateway Interface (CGI)" changes.

Do you want to unsubscribe in order to stop receiving notifications regarding "Modbus Common Gateway Interface (CGI)" changes.

Do you want to report abuse regarding "Modbus Common Gateway Interface (CGI)".

  • Information
  • Comments (9)
DOWNLOAD LINK RELATED COMPILER CONTAINS
Other Compiler
  • lib
  • src
  • exa
  • hlp
  • hex
  • sch
  • pcb
  • doc

Project Blog

[2013/02/27] A few minor tweaks, also added error response for reporting invalid crc and repsonse timeout.

[2013/02/25] Added support for modbus TCP.  To communicate with modbus TCP slaves, 

The syntax of the messages is very slightly different, no serial device is required, instead the URL query looks like:

http://address/modbusCGI.exe?r[]=s:IP-Port-Slave,f:5,sa:1,d:[01]

Where IP is the IP or host name, Port is the port to use (normally 502), Slave is the slave address (1 to 255).

http://address/modbusCGI.exe?r[]=s:192.168.0.5-502-1,f:5,sa:1,d:[01]

[2013/02/22] Fixed error in response, where start address is base 1 in the request, it was base 0 in the response, this has been corrected, modbus is base 0 in the protocol, but externally requests and responses are base 1.  Fixed error in coils and discrete response function code 1 and 2, the data was one byte out.

[2013/02/19] Uploaded zip containing both x64 and x86 versions of CGI.

[2013/02/17] Added project to libstock.

The CGI is a HTTP server on one side and a modbus master on the other, it accepts HTTP GET requests and translates these into modbus requests issued to slaves on the serial network.

The HTTP sytnax is as follows:

Where:
  d = COM1,baud,parity,databit,stop eg. COM1,9600,n,8,1
  r[] = s:1,f:1,sa:1,n:8
Where each r[] is a seperate request

For example:

http://[server address]/cgi-bin/modbusCGI.exe?d=COM14,115200,n,8,1&r[]=s:1,f:1,sa:1,n:8&r[]=s:1,f:2,sa:1,n:8

This example makes 2 requests, both to the same slave, read coils and read discrete status inputs.

Typical response from CGI:

  {"d":"com14,115200,n,8,1","q":[{"s":1,"f":1,"sa":0,"q":8,"r":["01"]}]}

Field keys:
  d = device
  q = query, each field in query object
      s  = slave
      f  = function
      sa = start address
      n  = number of items
      r  = response

To write to items:
  r[] = s:1,f:5,sa:1,n:1,d:[01]
or
  r[] = s:1,f:6,sa:1,n:1,d:[000C]
or
  r[] = s:1,f:15,sa:1,n:16,d:[0F-E1]
or
  r[] = s:1,f:16,sa:1,n:3,d:[0001-0002-0003]

You can send multiple requests by appending more 'r[]=' instructions.

Installation:
Take the executable from the archive and put into the cgi-bin folder of your web-server.  It using Apache then edit httpd.conf and ensure that:

<IfModule alias_module>

ScriptAlias /cgi-bin/ "path of your local files/cgi-bin/"

</IfModule>

<Directory "path of your local files/cgi-bin/">  
    AllowOverride AuthConfig FileInfo
    Options +Indexes FollowSymLinks +ExecCGI
    Order allow,deny
    Allow from all
</Directory>


Testing:

I used Apache 2.2 running on a Windows x64 based system, which was connected via serial RS232 to my easyPICv7 board running my modbus slave implementation:

http://www.libstock.com/projects/view/355/serial-modbus-slave


ALSO FROM THIS AUTHOR

LED Faders

0

This project demonstrates my fading structure and functions. You can create multiple faders on any I/O port you specify. Faders can be either individual pins or a mask of multiple pins. You specify the speed of fade, direction (in or out) and what options you want.

[Learn More]

Racing Start Lights for Slot Racers

0

Adds external start lights for any slot racing set.

[Learn More]

KnightRider on easyPIC v7

0

KnightRider style sequence on Ports C & D LED's This project demonstrates the use of several animation structures and a useful fader, you can use these structures for whatever purpose you wish. The only thing I ask is please leave the comment blocks unmodified. Added support for P18F4550 as well as P18F45K22. Feedback welcome.

[Learn More]