ScriptName "RS output" ScriptAuthor "(dA)" ScriptVersion "[19]" SetErrorHandler ( : AddressLable1 ) ; var vb_error : Byte ; // V1.0 17.07.02 create example // V1.1 28.10.02 include SetErrorHandler // SendRS writes the given number of characters to the output buffer of the // gateway. As the Buffer is filled with data the hardware (no longer the // software) is responsible for accessing serial lines. // With the action SendRS the script has no more control over the data, // it is not possible to clear output string etc. // Number is a variable containing the number of bytes to be sent, source // is a variable containing the data itself. // Path: communication -> RS output // SendRS ( v1 , v2 ) ; // SendRS ( Source=v1 , Number Char=v2 ) ; // Fieldbus -> no // RS 232 -> yes // min value = 0 // But no effect. // max value for Number of Char = see the specification of the device ; // max send value = max value - 1 Byte // if the number of char greater then the "max send value" you get following error // EXEC_SEND_LEN_ERROR = 45 dec. // Notice: The "max value" can be get with Get ( RSOutBufFree , v1 ) ; // Example Var var1 : BUFFER[31] ; MoveConst ( var1[0] , "Helloabcdefghijklmnopqrstuvwxyz" ) ; // make sure that your Buffer-Size is equal or greater the number of charīs you will fill up // ! NOTE ! : the number of char in one "moveconst" command has to be a maximum of 252 ! // if you need more, you can make several moveconst command with the special index after another Var var2 : WORD ; Set ( Parity , none ) ; // Following values are default enable, Set ( Stopbits , 1 ) ; // if you do not include this Set parameter Set ( Startbits , 1 ) ; Set ( Databits , 8 ) ; Set ( Baudrate , 9600 ) ; : start ; Moveconst ( var2 , 5 ) ; SendRS ( var1[0] , var2 ) ; // The Script send the word "Hello" for 5 characters to the RS232 interface. //Example 2 //SendRS ( var1[5] , var2 ) ; // The Script send the charīs "abcde" for 5 characters to the RS232 interface. //Example 3 //Moveconst ( var2 , 10 ) ; //SendRS ( var1[0] , var2 ) ; // The Script send the first 10 charīs "Helloabcde" to the RS232 interface. //Example 4 //Example for an error //Var var3 : WORD ; MoveConst ( var3 , 1 ) ; //Var var4 : WORD ; //Var var5 : WORD ; //Get ( RSOutBufFree16 , var4 ) ; //CalculateWord ( var3 , var4 , add , var5 ) ; //SendRS ( var1[0] , var5 ) ; // The Script send the NO char to the RS232 interface. // you get the error No 45 jump :start ; : AddressLable1 ; Get ( ErrorCode , vb_error ) ; //user evaluation for the value of Errorcode return ;