Basic

You can change most of the Ewon gateway’s behavior (e.g.: changing tag values, configuration modifications, handling files, controlling serial and IP connections,…) through BASIC scripting.

Among the BASIC functions, some of them will help you develop your own client/master protocol in order to make the Ewon gateway compatible with your device. This is particularly useful if the field device can only be polled using a protocol that is not supported by the  Ewon gateway.

One of the most interesting BASIC functions for developing custom protocols is the OPEN command: it allows control of the Ewon gateway’s serial port or creation of a TCP/UDP IP connection.

Example of serial protocol

REM open port 1 - 9600,N,8,1
OPEN "com:1,9600,8n1n" FOR BINARY OUTPUT AS 1

REM Compute request 0xF5 0xFA 0X01 0X01 
A$ = Chr$ 245 + Chr$ 250 + Chr$ 1 + Chr$ 1

REM Send Request
PUT 1,A$

TSET 1,1
ONTIMER 1,"GOTO RECEIVE"
END

RECEIVE:
	REM Receive code
	B$ = GET 1

	IF (B$ <> "") THEN
		REM normal poll rate (1 sec) + Process data
		TSET 1,1
		REM Write decimal value coded in Byte 1,2,3 of response in Tag named "RESULT"
		RESULT@ = ASCII B$(1) * 65536 + ASCII B$(2) * 256 + ASCII B$(3) 
	ELSE
		REM TIMEOUT
		TSET 1,5
	ENDIF

	REM Retry
	PUT 1,A$
END

You can find more details Ewon BASIC script in the RG-0006-01 - Programming Reference Guide which can also be found on the Basic Programming page.

You can also find more BASIC script examples on the Basic Programming page.