Skip to main content
Skip table of contents

CGI Legacy Handler

Version

Changelog

Date

Download

1.0.0

Initial Release

package.zip

Application Version: 1.0.0
Compatible Firmware: Flexa Firmware min. v2.3.0
Device Compatibility: Barionet M44

Overview

The BM44 CGI Legacy Handler provides a simple HTTP API for reading and controlling Input/Output (IO) addresses on the Barionet M44 device. The API uses standard HTTP GET requests with specific URL parameters to interact with relays, digital inputs, analog inputs, counters, and other device features. This application is meant to offer retro-compatibility with Barionet 50 / 100 CGI based API (only for rc.cgi and bas.cgi endpoints. NOT including settings.cgi or others).

API Endpoints

The server provides two identical endpoints:

  • /rc.cgi

  • /bas.cgi

Both endpoints accept the same parameters and provide identical functionality.

Base URL Format

CODE
http://[DEVICE_IP]:[PORT]/[ENDPOINT]?[PARAMETERS]

Example: http://192.168.1.100:8080/rc.cgi?state=1

This example provides a query used to retrieve the current state of relay 1.

Port 8080 is the default port used by the application, but it is configurable from the app’s UI tab.

Reading Values

Request Format

CODE
GET /rc.cgi?state=[ADDRESS]
GET /bas.cgi?state=[ADDRESS]

Parameters

  • state: The IO address number to read

Response Format

CODE
<ADDRESS>VALUE<ADDRESS>

Examples

Read relay 1 status:

CODE
GET http://192.168.1.100:8080/rc.cgi?state=1
Response: <1>0<1>

Read digital input 1:

CODE
GET http://192.168.1.100:8080/bas.cgi?state=201
Response: <201>1<201>

Read analog input 1:

CODE
GET http://192.168.1.100:8080/rc.cgi?state=501
Response: <501>1564<501>

Writing Values

Request Format

CODE
GET /rc.cgi?o=[ADDRESS],[VALUE]
GET /bas.cgi?o=[ADDRESS],[VALUE]

Parameters

  • o: Output parameter containing address and value separated by comma

  • ADDRESS: The IO address number to write

  • VALUE: The value to write (see value types below)

Response Format

CODE
200 OK

Value Types

For 1-bit Addresses (Relays, Digital Outputs, Virtual bits)

  • 0: Turn OFF

  • 1: Turn ON

  • 999: Toggle state (if OFF becomes ON, if ON becomes OFF)

  • 2-998: Timed ON duration in tenths of seconds (e.g., 50 = 5.0 seconds)

  • 1000-9999: Timed ON duration in tenths of seconds (e.g., 1200 = 120.0 seconds)

For Multi-bit Addresses (Counters, Analog values)

  • Direct value: Any value within the address bit-size limits

    • 16-bit addresses: 0 to 65,535

    • 32-bit addresses: 0 to 4,294,967,295

Examples

Turn ON relay 1:

CODE
GET http://192.168.1.100:8080/rc.cgi?o=1,1
Response: 200 OK

Turn OFF relay 2:

CODE
GET http://192.168.1.100:8080/rc.cgi?o=2,0
Response: 200 OK

Toggle relay 3:

CODE
GET http://192.168.1.100:8080/rc.cgi?o=3,999
Response: 200 OK

Turn ON relay 1 for 5 seconds then auto-OFF:

CODE
GET http://192.168.1.100:8080/rc.cgi?o=1,50
Response: 200 OK

Turn ON relay 2 for 30 seconds then auto-OFF:

CODE
GET http://192.168.1.100:8080/rc.cgi?o=2,300
Response: 200 OK

Common IO Addresses

Relays (1-bit, Read/Write)

  • 1-4: Built-in relays 1-4

  • 11-18: UX8 Extension relays (Address 1)

  • 19-26: UX8 Extension relays (Address 2)

Digital Inputs (1-bit, Read-only)

  • 201-204: Built-in digital inputs 1-4

  • 209: CTS input

  • 211-218: UX8 Extension digital inputs (Address 1)

  • 219-226: UX8 Extension digital inputs (Address 2)

Control Features (1-bit, Read/Write)

  • 9: RS232 RTS output

  • 301-304: Pull-up resistors for digital inputs 1-4

  • 1207: USB port enable/disable

Counters (32-bit, Read/Write)

  • 401-404: Digital input counters for inputs 1-4

  • 411-418: UX8 Extension input counters (Address 1)

  • 419-426: UX8 Extension input counters (Address 2)

Analog Inputs (16-bit, Read-only)

NOTE: Readings in mV

  • 501-504: Built-in analog inputs 1-4

  • 511-518: UX8 Extension analog inputs (Address 1)

  • 519-526: UX8 Extension analog inputs (Address 2)

Temperature (16-bit, Read-only)

NOTE: Readings in mC°

  • 601-650: Temperature senor values (up to 50x temperature sensors can be connected)

  • 651-700: Temperature Sensor Addresses (1-wire) - lower 32bits (signed integer is returned. Must be converted in HEX to get the “lower portion” of the sensor serial number)

  • 701-750: Temperature Sensor Addresses (1-wire) - higher 32bits (signed integer is returned. Must be converted in HEX to get the “higher portion” of the sensor serial number)

Device Status (Read-only)

  • 1201: Device supply current (mA)

  • 1202: Device supply voltage (mV)

  • 1203: CPU temperature (m°C)

  • 1204: Device uptime (seconds)

  • 1205: Hardware type ID

  • 1206: Firmware version

Virtual IO (Read/Write)

  • 10, 43-100, 109-200, 210, 243-300, 309-400: 1-bit virtual addresses

  • 409-500: 32-bit virtual registers

  • 509-600, 751-1200: 16-bit virtual registers

Error Responses

Invalid Address

CODE
Request: GET http://192.168.1.100:8080/rc.cgi?state=99999
Response: Invalid Address

Invalid Value

CODE
Request: GET http://192.168.1.100:8080/rc.cgi?o=201,1
Response: Invalid value for the requested address

Access Denied (when IP filtering is enabled)

CODE
Response: Access denied

Usage Notes

  1. Timed Operations: When using timed values (2-998, 1000-9999), the relay turns ON immediately and automatically turns OFF after the specified duration.

  2. Toggle Cancellation: Starting a new timed operation on the same address cancels any existing timed operation.

  3. Read-only Addresses: Attempting to write to read-only addresses (like digital inputs, device status) will return an error.

  4. Value Limits: Multi-bit addresses have specific value ranges. Exceeding these limits will return an error.

  5. Immediate Effect: All successful write operations take effect immediately.

Example Client Code

Python with requests

PY
import requests

# Read relay 1 status
response = requests.get('http://192.168.1.100:8080/rc.cgi?state=1')
print(response.text)  # <1>0<1>

# Turn ON relay 1
response = requests.get('http://192.168.1.100:8080/rc.cgi?o=1,1')
print(response.text)  # 200 OK

# Turn ON relay 2 for 10 seconds
response = requests.get('http://192.168.1.100:8080/rc.cgi?o=2,100')
print(response.text)  # 200 OK

curl command line

BASH
# Read digital input 1
curl "http://192.168.1.100:8080/rc.cgi?state=201"

# Toggle relay 3
curl "http://192.168.1.100:8080/rc.cgi?o=3,999"

# Turn ON relay 1 for 5 seconds
curl "http://192.168.1.100:8080/rc.cgi?o=1,50"

JavaScript fetch

JS
// Read analog input 1
fetch('http://192.168.1.100:8080/rc.cgi?state=501')
  .then(response => response.text())
  .then(data => console.log(data)); // <501>2048<501>

// Turn OFF relay 2
fetch('http://192.168.1.100:8080/rc.cgi?o=2,0')
  .then(response => response.text())
  .then(data => console.log(data)); // 200 OK

This API provides complete control over the Barionet M44's IO capabilities through simple HTTP requests, making it easy to integrate with any system that can make HTTP calls.

Compatible Hardware

Primary Platform: The CGI Legacy Handler Application is designed for Barionet M44 devices running the Flexa Firmware v2.3.0.

Installation Process

Installing the CGI Legacy Handler Application requires uploading a package file directly to your Barionet device through its web interface. This process is straightforward but requires careful attention to ensure proper installation.

NOTE: If your Barionet M44 is already running an application you must RESET TO DEFAULTS before proceeding and installing a new one.

Step 1: Access the Device Web Interface

  1. Open your web browser and navigate to your Barionet device's IP address

  2. Enter your administrator username and password when prompted

  3. Wait for the main interface to load completely before proceeding

    image-20250729-134518.png

Step 2: Upload the Application Package

  1. Navigate to the HOME tab in the main menu

  2. Locate the "Upload" button next to “Install Package” within the page

  3. Click the file selection button and browse to the “package.zip” which was downloaded from this page

  4. Choose an appropriate version number for tracking purposes (this can be any number you prefer for identification)

  5. Click the UPLOAD button to begin the installation process

Step 3: Device Reboot and Verification

After the upload completes, your Barionet device will automatically initiate a reboot sequence. This reboot is necessary to properly integrate the new application into the system. The reboot process typically takes 30..40s

  1. Wait for the device to complete its reboot cycle

  2. Reconnect to the web interface using the same IP address and credentials

  3. Navigate back to the HOME tab

  4. Verify that the CGI Legacy Handler Application appears with a status of "running"

    image-20250804-123151.png

Configuration Overview

Once successfully installed, the CGI Legacy Handler Application configuration interface becomes available through the CGI Legacy API tab in your device's web interface. This dedicated configuration page provides access to all settings necessary to control the application.

image-20250804-123440.png

Here are the improved configuration parameter descriptions:

Configuration Parameters

Port

Specifies the TCP port number on which the CGI Legacy Handler will listen for incoming HTTP API requests.

  • Valid Range: 1025-65535 (ports below 1025 are reserved for system services)

  • Default: 8080

  • Example: Set to 8080 for http://device-ip:8080/rc.cgi

Allowed IP Addresses

Defines IP address-based access control for the CGI Legacy Handler. When configured, only requests from the specified IP addresses will be processed; all other requests will be rejected with an "Access denied" response.

  • Format: Comma-separated list of IPv4 addresses

  • Default: Empty (accepts requests from any IP address)

  • Example: 192.168.1.10,192.168.1.50,10.0.0.100

Behavior:

  • Empty field: No IP filtering - accepts requests from any source IP

  • With IPs listed: Only the specified IP addresses can access the API

  • Blocked requests: Return HTTP 403 "Access denied" - thes erequets are logged as security events

Remote Syslog

Enables centralized logging by forwarding all application log messages to a remote syslog server using UDP protocol. This provides centralized monitoring, audit trails, and troubleshooting capabilities.

Syslog Enabled

  • Default: Disabled

  • When Enabled: All log messages are sent to the specified syslog server

Syslog IP Address

  • Format: IPv4 address of the syslog server

  • Default: None

  • Example: 192.168.1.200 (your log server)

Syslog Port

  • Format: UDP port number of the syslog service

  • Default: 514 (standard syslog port)

  • Range: 1-65535

Logged Information:

  • All HTTP API requests and responses

  • IO operations (read/write/toggle operations)

  • Security events (blocked IP addresses)

  • Timed toggle operations (start/stop/cancel)

  • System errors and warnings

  • Application startup/shutdown events

Configure your syslog server to accept UDP messages on the specified port. Log messages use the format: BM44WebServer[PID]: LEVEL - MESSAGE

Software Disclaimer

IMPORTANT:

This software application ("Software") is provided "AS IS" without warranty of any kind, express or implied, including but not limited to the warranties of merchantability, fitness for a particular purpose, and non-infringement. In no event shall the author, developer, or distributor be liable for any claim, damages, or other liability, whether in an action of contract, tort, or otherwise, arising from, out of, or in connection with the Software or the use or other dealings in the Software.

Use at Your Own Risk: The user assumes all responsibility and risk for the use of this Software. The author makes no representations or warranties regarding the accuracy, reliability, completeness, or timeliness of the Software or its suitability for any particular purpose.

No Support Obligation: The provision of this Software does not create any obligation to provide technical support, maintenance, updates, enhancements, or modifications. The Software is provided for educational and reference purposes only.

Third-Party Dependencies: This Software may utilize third-party libraries and components. The user is responsible for ensuring compliance with all applicable licenses and terms of use for such dependencies.

Network and Security: The user is solely responsible for implementing appropriate security measures and network configurations. The author is not responsible for any security vulnerabilities, data breaches, or network disruptions that may result from the use of this Software.

Compliance: Users are responsible for ensuring that their use of this Software complies with all applicable laws, regulations, and organizational policies in their jurisdiction.

Limitation of Liability: Under no circumstances shall the total liability of the author exceed zero dollars ($0.00) for any damages arising out of or related to the use of this Software.

By using this Software, you acknowledge that you have read, understood, and agree to be bound by the terms of this disclaimer.

JavaScript errors detected

Please note, these errors can depend on your browser setup.

If this problem persists, please contact our support.