# Using Instrument Interface Module

**URL:** <https://forum.inductiveautomation.com/t/using-instrument-interface-module/6054>\
**Category:** Ignition\
**Created:** [March 19, 2013, 2:05pm UTC](https://forum.inductiveautomation.com/t/using-instrument-interface-module/6054 "2013-03-19T14:05:57Z")\
**Posts on this page:** 13\
**Page:** 1

<div class="post-metadata">

**Author:** ![illank86](https://avatars.discourse-cdn.com/v4/letter/i/c77e96/32.png) [@illank86](https://forum.inductiveautomation.com/u/illank86)\
**Post date:** [March 19, 2013, 2:05pm UTC](https://forum.inductiveautomation.com/t/using-instrument-interface-module/6054/1 "2013-03-19T14:05:57Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Pete.Low](https://avatars.discourse-cdn.com/v4/letter/p/f05b48/32.png) [@Pete.Low](https://forum.inductiveautomation.com/u/Pete.Low)\
**Post date:** [March 19, 2013, 2:55pm UTC](https://forum.inductiveautomation.com/t/using-instrument-interface-module/6054/2 "2013-03-19T14:55:07Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![illank86](https://avatars.discourse-cdn.com/v4/letter/i/c77e96/32.png) [@illank86](https://forum.inductiveautomation.com/u/illank86)\
**Post date:** [March 20, 2013, 4:53am UTC](https://forum.inductiveautomation.com/t/using-instrument-interface-module/6054/3 "2013-03-20T04:53:09Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Pete.Low](https://avatars.discourse-cdn.com/v4/letter/p/f05b48/32.png) [@Pete.Low](https://forum.inductiveautomation.com/u/Pete.Low)\
**Post date:** [March 20, 2013, 3:57pm UTC](https://forum.inductiveautomation.com/t/using-instrument-interface-module/6054/4 "2013-03-20T15:57:47Z")

</div>

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:

```auto
#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.

---

<div class="post-metadata">

**Author:** ![illank86](https://avatars.discourse-cdn.com/v4/letter/i/c77e96/32.png) [@illank86](https://forum.inductiveautomation.com/u/illank86)\
**Post date:** [March 22, 2013, 7:56am UTC](https://forum.inductiveautomation.com/t/using-instrument-interface-module/6054/5 "2013-03-22T07:56:18Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Pete.Low](https://avatars.discourse-cdn.com/v4/letter/p/f05b48/32.png) [@Pete.Low](https://forum.inductiveautomation.com/u/Pete.Low)\
**Post date:** [March 22, 2013, 4:21pm UTC](https://forum.inductiveautomation.com/t/using-instrument-interface-module/6054/6 "2013-03-22T16:21:16Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![illank86](https://avatars.discourse-cdn.com/v4/letter/i/c77e96/32.png) [@illank86](https://forum.inductiveautomation.com/u/illank86)\
**Post date:** [March 27, 2013, 11:02am UTC](https://forum.inductiveautomation.com/t/using-instrument-interface-module/6054/7 "2013-03-27T11:02:49Z")

</div>

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

```auto
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

 ![](https://us1.discourse-cdn.com/inductiveautomation/original/2X/5/546eb97d8bd54fb08f5f080638c99becb6aec979.png)

---

<div class="post-metadata">

**Author:** ![Pete.Low](https://avatars.discourse-cdn.com/v4/letter/p/f05b48/32.png) [@Pete.Low](https://forum.inductiveautomation.com/u/Pete.Low)\
**Post date:** [March 27, 2013, 3:05pm UTC](https://forum.inductiveautomation.com/t/using-instrument-interface-module/6054/8 "2013-03-27T15:05:46Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![illank86](https://avatars.discourse-cdn.com/v4/letter/i/c77e96/32.png) [@illank86](https://forum.inductiveautomation.com/u/illank86)\
**Post date:** [March 28, 2013, 12:29am UTC](https://forum.inductiveautomation.com/t/using-instrument-interface-module/6054/9 "2013-03-28T00:29:28Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Kevin.Herron](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/kevin.herron/32/7259_2.png) [@Kevin.Herron](https://forum.inductiveautomation.com/u/Kevin.Herron)\
**Post date:** [March 28, 2013, 5:50pm UTC](https://forum.inductiveautomation.com/t/using-instrument-interface-module/6054/10 "2013-03-28T17:50:04Z")

</div>

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

See:

[system.serial.writeBytes](http://inductiveautomation.com/support/usermanuals/ignition/system_serial_readbytes.htm)  
[system.serial.readBytes](http://inductiveautomation.com/support/usermanuals/ignition/system_serial_writebytes.htm)

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](http://www.inductiveautomation.com/forum/viewtopic.php?f=70&t=9641&start=0&st=0&sk=t&sd=a)

---

<div class="post-metadata">

**Author:** ![illank86](https://avatars.discourse-cdn.com/v4/letter/i/c77e96/32.png) [@illank86](https://forum.inductiveautomation.com/u/illank86)\
**Post date:** [March 29, 2013, 12:07am UTC](https://forum.inductiveautomation.com/t/using-instrument-interface-module/6054/11 "2013-03-29T00:07:16Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Carl.Gould](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/carl.gould/32/7262_2.png) [@Carl.Gould](https://forum.inductiveautomation.com/u/Carl.Gould)\
**Post date:** [May 23, 2013, 6:54pm UTC](https://forum.inductiveautomation.com/t/using-instrument-interface-module/6054/12 "2013-05-23T18:54:49Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![markdobtech](https://avatars.discourse-cdn.com/v4/letter/m/71e660/32.png) [@markdobtech](https://forum.inductiveautomation.com/u/markdobtech)\
**Post date:** [May 23, 2013, 7:56pm UTC](https://forum.inductiveautomation.com/t/using-instrument-interface-module/6054/13 "2013-05-23T19:56:34Z")

</div>

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.
