# Serial Connection API

**URL:** <https://forum.inductiveautomation.com/t/serial-connection-api/8066>\
**Category:** Ignition\
**Created:** [February 26, 2014, 1:31am UTC](https://forum.inductiveautomation.com/t/serial-connection-api/8066 "2014-02-26T01:31:47Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![bokechal](https://avatars.discourse-cdn.com/v4/letter/b/6f9a4e/32.png) [@bokechal](https://forum.inductiveautomation.com/u/bokechal)\
**Post date:** [February 26, 2014, 1:31am UTC](https://forum.inductiveautomation.com/t/serial-connection-api/8066/1 "2014-02-26T01:31:47Z")

</div>

I’m developing a tool control application which interfaces through serial connection. I have successfully established connection and communication through hyperterminal and what I like about hyperterminal is that there is a status message at the bottom left corner of the window stating that it’s connected with the connecting time.  
I can send command through hyperterminal and get response from the equipment fine.

Now I want to move on with the development to connect through the Ignition Gateway. I’m starting with Serial Support Client module. But eventually I will reconfigure to use Serial Support Gateway module (we have connected this equipment with a device that converts serial connection to ethernet network).

These are what we have right now.  
-Ignition Gateway 7.6.4  
-Serial Module 1.6.4  
-Client Windows XP SP3  
-Java 1.7.0\_25

By following the documentation in the User manual, I have this in the client startup script

[code]system.serial.configureSerialPort(  
port=“COM7”,  
bitRate=system.serial.BIT\_RATE\_9600,  
dataBits=system.serial.DATA\_BITS\_8,  
handshake=system.serial.HANDSHAKE\_NONE,  
hardwareFlowControl=False,  
parity=system.serial.PARITY\_NONE,  
stopBits=system.serial.STOP\_BITS\_1)

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

In the Timer script, I have

`system.serial.write("COM7", ":STAT?")
stat = system.serial.readLine("COM7", 2000)
system.tag.write("[Client]Status/State", stat)`

And in the Shutdown script, I have

```auto
system.serial.closeSerialPort("COM7")
```

My questions are:

- I want to get the status of the connection so I can show in the UI if the connection is good. Is there any function to check that? As of now, I can only assume that after the configureSerialPort() and openSerialPort(), it will connect to the tool.
- When the timer script get executed, it returns zero bytes error. I looked up in forum and found one topic discussed about this error. It’s said that it was fixed in the module 1.5.1, however, I still got this error even though I have 1.6.4.
- Where can I find a more detail documentation on this system.serial?

Thank you

---

<div class="post-metadata">

**Author:** ![bokechal](https://avatars.discourse-cdn.com/v4/letter/b/6f9a4e/32.png) [@bokechal](https://forum.inductiveautomation.com/u/bokechal)\
**Post date:** [March 2, 2014, 6:19am UTC](https://forum.inductiveautomation.com/t/serial-connection-api/8066/2 "2014-03-02T06:19:53Z")

</div>

Just want to update…

When I append \n to the command in write function  
system.serial.write(“COM7”, “:STAT?\n”)  
I no longer get zero bytes returned from readLine().
