9 appendi x 9.1 macro pro tocol: description, 1 checksum calculation procedures, 2 test progra m example – Videotec SM164B User Manual

Page 72

Advertising
background image

Page 32

MNVCSM84A_0408

9 APPENDI X

9.1 Macro Pro tocol: description

The Macro protocol is characterized by messages consisting only of printable ASCII characters, delimited by
two terminator characters ‘[‘ and ‘]’. Within the message, upper and lower case letters are differentiated and
there are NEVER any space separators. The format of a typical message consists of a character string
‘[VA1PC1VidS1,12A]’ which can be interpreted as follows:

[

Start of message

VA1

Receiver of message

(1)

Video unit number 1

PC1

Sender of message

(1)

PC number 1

VidS

Command

Switch

1

First parameter

(2)

Monitor 1

,

Parameter separator

(2)

12

Second parameter

(2)

Camera 12

A

Checksum

]

End of message

(1)

Even though in this case the Receiver and Sender units have no address it is necessary to insert an

imaginary id. number.

(2)

Depending on the command, there are a maximum of 4 numeric parameters separated by a comma: to transmit

the number 123 it is necessary to send the three characters ‘1’ (ASCII 49), ‘2’ (ASCII 50) and ‘3’ (ASCII 51).

9.1.1 Checksum calculation procedures

Calculate the sum of the ASCII codes of all the message characters, excluding the terminators ‘[‘ and ‘]’
1) calculate the value of the sum (mod 26) (the remainder after division by 26, always a whole number between
0 and 25)
2) add 65 to the calculated modulus and find the corresponding character in the ASCII table: the result should
be an upper case letter of the alphabet from ‘A’ to ‘Z’.
The message will only be interpreted by the matrix if the checksum is correct.

9.1.2 Test progra m example

The following is a simple test program in BASIC, which can be used as the basis to create more complicated
control systems. The program uses the serial port COM1 with baudrate 9600.

OPEN "COM1:9600,N,8,1,BIN,RB1000,DS0,CS0,CD0,RS" FOR RANDOM AS #1
COM(1) ON

ON COM(1) GOSUB Reception

DO WHILE (1)
A$ = UCASE$(INKEY$)

‘ recognises a key being pressed down

SELECT CASE A$

CASE “1”: ‘ switch camera 1 to monitor 1
PRINT #1, “[VA1PC1VidS1,1C]”;

CASE “2”: ‘switch camera 2 to monitor 1
PRINT #1, “[VA1PC1VidS1,2D]”;

CASE “S”: ‘automatic switching sequence on monitor 1
PRINT #1, “[VA1PC1VidA1V]”;

CASE CHR(27):

‘ exit program with ESC

END

END SELECT
LOOP

Reception:
DO WHILE NOT(EOF(1))
B$ = INPUT$(1,1)
IF B$ = “[” THEN PRINT
PRINT B$;
LOOP
RETURN

Advertising