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]
Rating:
Author: Simon Platten
Last Updated: 2013-02-27
Package Version: 1.0.0.4
Category: Communication
Downloaded: 1806 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.
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)".
DOWNLOAD LINK | RELATED COMPILER | CONTAINS |
---|---|---|
1361956160_modbus_common_ga_other_other.zip [23.04KB] | Other Compiler |
|
[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