Using Instrument Interface Module

Hi All,

how to use this Instrument Interface with Barcode reader…?

So, i have installed the Instrument Interface module and also the Serial Support Client Module…

Barcode reader is installed in the Client PC.

still not able to read the value from barcode in client PC…

is there any document step by step other than user manual?

i have set all the configuration

Thanks

Hi,
The Serial Controller component has properties that give indications of what might be going on. You can place 3 labels on the window and bind them to these properties:

Last Data Sent At Last Data Received At Error Message
Also on the Serial Controller you can see the raw data read by placing script in the event onBeforeParse and looking at the property event.getData() It will return a string with the read data.

These should give some insight on what is occurring.

ok, everything is works… thanks

btw, Next Question, if i get the data like this :

7000 300 124304 89,9

how to parse this raw data to

7000
300
124304
89,9

and each data will bind to tag…

appriciate for your help…

thanks

In the parse template you are able to define parsing boxes that will extract the parts of the data you want.
If the data is delimited then you can use a CSV parse box and select the appropriate delimiter to read the data. Remember that CSV parser will always return data in parse row collection even if it is just one line.
Add script in the onAfterParseEvent to get the data:

#get parse results
parseResults = event.getParseResults()
if parseResults != None:
	if parseResults.isValid():
		#a CSV box in a template will return rows of data
		#get all the rows parsed for the defined template box
		rowCollection = parseResults.getRowCollection("CSVColumnBox")
		#get a list of each row
		parseRowList = rowCollection.getParseRows()
		#cycle through each row in list
		for parseRow in parseRowList:
			#get a list of the values in the row
			parseValueList = parseRow.getParseValues()
			#cycle through all the values and pull out the ones you are interested in.
			for parseValue in parseValueList:
				if parseValue.getName()=="Time":
					time = str(parseValue.getValue())
				if parseValue.getName()=="DataField1":
					fld1 = str(parseValue.getValue())

			print "%s, Datafield1 = %s" % (time, fld1)
			print "------------------"

This is just an example, you will need to define the fields you want and instead of printing to the console you can write the values to a tag.
The manual has examples of parsing data using fixed position or label value pair also.

im not parsing from CSV, but from serial, here is the data that i got from Serial port.

i got this data from serial port monitoring:
01 8c 36 f0 01 01 04 02 00 01 [color=#FF0000]00 00 03 41[/color] 00 02…
[color=#FF0000]01 1f 36 c3[/color] 00 04 00 00 03 41 00 05 05 18 b9 95
00 07 00 00 03 41 00 08 05 17 d2 cb 00 0a [color=#FF0000]00 00
1b ff [/color]00 0d [color=#FF0000]00 00 05 e4[/color] ff ff 2e

i want to insert the data which has red colour into TAGS, so how can i do that?

one more thing, how to send data to Serial port?

Thanks

What is the data you are seeing returned in the onAfterParse event of the serial controller component?
In the event you could send the data to a text area like this:

event.source.parent.getComponent('Text Area').text=event.getData()

Once you know the data you are getting you just need to extract the parts you want by splitting the string with the character that it is being delimited by.

Hi Pete,

sorry for late reply, i have tried write and read data from ignition, but i still have problem.

the device that i want to read is Flow Comp from Master Load AH (Avery Hardoll) which has port RS422, and i used RS422 to RS232 Converter.

the problem is that i cant get the value from the device.

to get value from device i need to write 81H to serial port

if i use Ignition to send 81H, i get no data from device, even the data was sent to serial port (no reply)

but if i use Serial port monitoring, and send 81H, i get the data form Device

im using 3 button :

  1. Openport :

[code]system.serial.configureSerialPort(“COM2”)
.setBitRate(system.serial.BIT_RATE_1200)
.setDataBits(system.serial.DATA_BITS_8)
.setHandshake(system.serial.HANDSHAKE_NONE)
.setHardwareFlowControl(False)
.setParity(system.serial.PARITY_ODD)
.setStopBits(system.serial.STOP_BITS_1)

system.serial.openSerialPort(“COM2”)[/code]

  1. Send data

port="COM2" system.serial.writeBytes(port, "\x01\x8d\x0c\xf0\x01\x00\x04\x03\x00\x00\x00\x0a\x00\x00\x0b\xb8\x30")

  1. Close Port
system.closeSerialPort("COM2")

if i use serial port monitoring when open port from ignition, there is so many timeout (please see attachment)

please advice…

Thanks


It looks like you are dealing with binary data. The Instrument Interface module works for ASCII data, so you will not be able to use the Instrument Interface module.

You need to be certain that the port settings are correct and the port is actually opened before sending the code.

im sure that the setting was right and port was opened, even there so many time out.

so, is there any solution for binary data?

i really need to make ignition able to send and read binary (Hex) from serial.
Please advice.

thanks

The Serial Support Module adds scripting functions for reading from/writing to serial ports in Ignition.

See:

system.serial.writeBytes
system.serial.readBytes

and also this forum thread where someone else dealt with similar issues:

viewtopic.php?f=70&t=9641&start=0&st=0&sk=t&sd=a

hi kevin,

i have seen that link and i have tried those code (as you can see in my previous post) to write Hex to serial port and there is no response from the device, even if i sniff it, ignition sent the right command.

if i write command 81H to device, it should response with the data which is array bit, the next thing is how to handle (read) array bit in ignition?

Thanks for the support

I don’t understand quite what you’re asking. What’s stopping you? The readBytes function does just that…

We use the Ignition serial module to write and read hex from various devices with no problem. Are you sure 1.) you have the correct cable for the device (straight through or crossover) and have no handshake in place on the device side and 2.) have the port open and 3.) have code in place to look into the buffer and read the contents. If you can point to the comm documentation for the device, I will be glad to take a look at it.