Up | Editing scripts | Script Details | RS232 | TCP/IP | System | Scheduler | HistoryList | ImageView

 

  

 
RS232
The Python classRS232TDVCmdProtocol gives access to the integrated communication RS232 component

The following events are available:

  • PacketStart()
  • PacketEnd()
  • Command(Command)
  • Value(Name,Value)

PacketStart and PacketEnd are used for packet separation. Each packet may contain multiple Command and Value events but normally a packet contains a leading Command followed by optional Value events. Internal in Scorpion, the PacketStart event is used to Reset of previous events, the Command and Value events is validated and collected and in PacketEnd the complete command-event sequence is executed.

A  typical command is

  • <stx>SetValue;A.Value=12.0<stx>

The following events are generated :

  • PacketStart
  • Command - where Command=SetValue
  • Value where Name=A.Value and Value=12.0
  • PacketEnd

Returning 1 in the these events will be ignored by Scorpion.

Note ! Any changes to the component configuration will be persistent. If these settings is temporarely the script must retrieve the origin settings before setting new values and finally restore origin settings when done.

The following methods are available for the RS232TDVCmdProtocol instance

Method Parameters Comment
Send(value) string  sends a TDVCMD formatted string
GetTimeout() none returns timeout in seconds
SetTimeout(value) int no of seconds
GetPortNo() none returns current COM port
SetPortNo(value) int sets current COM port (RS232)
GetPortOpen() none returns 0/1 - closed/open
SetPortOpen(value) int 1=open, 0=closed
GetPortParametres() none returns current settings as semocolonseparater string
RS232 : 'baud;bytelen;parity;stopbits'
SetPortParametres(value) string format must be in following order:
RS232: 'baud;bytelen;parity;stopbits'

Example - send some results over rs-232.

resX=str(GetValue('CenterLine.Line_x'))                   #get x position
resY=str(GetValue('CenterLine.Line_y'))                   #get y position
RS232TDVCmdProtocol.Send('INSP;X=' + resX + ';Y=' + resY) #send the result

 

Scorpion Vision Version XII : Build 646 - Date: 20170225
Scorpion Vision Software® is a registered trademark of Tordivel AS.
Copyright © 2000 - 2017 Tordivel AS.