From OpenSCADAWiki
Functions of the output transport object (SYS.Transport["Modul"]["out_Transp"]):
- bool isNetwork( ) — the sign — "The transport is network one", what is specified by the timeouts in seconds.
- ElTp cfg( string nm ) — gets the value of the configuration field nm of the object.
- bool cfgSet( string nm, ElTp val ) [access to the appropriate subsystem] — sets the configuration field nm of the object to the value val.
- string status() — string status of the transport.
- bool start( bool vl = EVAL, int tm = 0 ) — returns the transport status "Running", starts/stops it by vl (if it is not EVAL). For starting you can set the specific timeout tm.
- string addr( string vl = "" ) — address of the transport, sets the non-empty value vl.
- string timings( string vl = "", isDef = true ) — timings of the transport, sets the non-empty value vl and as default one for isDef.
- int attempts( int vl = EVAL ) — attempts of the transport connection, sets the non-EVAL value vl.
- ElTp conPrm( string id, ElTp val = EVAL, string cfg = "" ) — common handling the connection time parameter id with setting to the value val at presence; request for configuration parameter of the connection time with registration at the first time from the configuration cfg in the form "{SRC}\n{NAME}\n{HELP}".
- bool setConPrm( string id, ElTp val ) — setting the connection time parameter id to the value val, only for compatibility.
- string messIO( string mess, real timeOut = 0, int inBufLen = -1 ); — sends the message mess via the transport with the waiting time of the response timeOut (in seconds) and reads an response (Buffer) in inBufLen byte. In the case of a zero timeout, this time is taken from the settings of the output transport. The timeOut in negative (< -1e-3) disables the transport request/respond mode and allows for independent reading/writing to a buffer IO, with the reading timeout timeOut in absolute. For negative inBufLen the buffer size sets to STR_BUF_LEN(10000) and "0" disables the reading at all.
If your transport means getting data in parts for a request then for several devices on single bus-transport, use the function into single thread but there is not a way to lock the transport into the user API. Single thread that is any object of controller of DAQ and the module "User protocol" locks the transport internally before self user procedures execution.rez = SYS.Transport.Serial.out_ttyUSB0.messIO(SYS.strFromCharCode(0x4B,0x00,0x37,0x40),0.2); //Wait for all the message tail by timeout and empty result while(rez.length && (trez=SYS.Transport.Serial.out_ttyUSB0.messIO("")).length) rez += trez;
- string messIO( XMLNodeObj req, string prt ); — sends the request req to the protocol prt to perform a communication session through the transport and in assistance of the protocol. Returns a string with error in the format "{errCod}:{errText}" which empty for successful request.
req = SYS.XMLNode("TCP"); req.setAttr("id","test").setAttr("reqTm",500).setAttr("node",1).setAttr("reqTry",2).setText(SYS.strFromCharCode(0x03,0x00,0x00,0x00,0x05)); SYS.Transport.Sockets.out_testModBus.messIO(req,"ModBus"); test = Special.FLibSYS.strDec4Bin(req.text());