# Custom Modbus request to TCP device via Scripting

**URL:** <https://forum.inductiveautomation.com/t/custom-modbus-request-to-tcp-device-via-scripting/48668>\
**Category:** General Discussion\
**Created:** [July 9, 2021, 3:51pm UTC](https://forum.inductiveautomation.com/t/custom-modbus-request-to-tcp-device-via-scripting/48668 "2021-07-09T15:51:18Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![lrichardson](https://avatars.discourse-cdn.com/v4/letter/l/f1d935/32.png) [@lrichardson](https://forum.inductiveautomation.com/u/lrichardson)\
**Post date:** [July 9, 2021, 3:51pm UTC](https://forum.inductiveautomation.com/t/custom-modbus-request-to-tcp-device-via-scripting/48668/1 "2021-07-09T15:51:18Z")

</div>

i am using a 3rd party OPC to connect to a modbus device & am bring back tag data flawlessly. The hardware has historical data stored in indexed archives & uses a non-standard modbus request to read the historical data internally for display on it’s proprietary GUI. The OPC server that I am using doesn’t have the capability via premade driver or user configurable driver to manage indexes & bring in the data. Any experience or tips on using a modbus TCP device connection in conjunction with python scripting to handle such a request?

---

<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:** [July 9, 2021, 3:53pm UTC](https://forum.inductiveautomation.com/t/custom-modbus-request-to-tcp-device-via-scripting/48668/2 "2021-07-09T15:53:20Z")

</div>

Our driver has no facility that allows custom requests to be sent either.

To do this from scripting you’d have to open your own TCP connection to the device and send/receive the data entirely on your own.

---

<div class="post-metadata">

**Author:** ![pturmel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pturmel/32/3295_2.png) [@pturmel](https://forum.inductiveautomation.com/u/pturmel)\
**Post date:** [July 9, 2021, 4:54pm UTC](https://forum.inductiveautomation.com/t/custom-modbus-request-to-tcp-device-via-scripting/48668/3 "2021-07-09T16:54:56Z")

</div>

> [@lrichardson](#):
>
> uses a non-standard modbus request

Do you happen to have docs on this non-standard request? If it is well-documented, I could probably expose it in my driver:

> [@Automation Professionals' Advanced Modbus Driver](http://forum.inductiveautomation.com/t/automation-professionals-advanced-modbus-driver/41312):
>
> Automation Professionals is pleased to announce the first beta for its Advanced Modbus Driver, for Ignition version 7.9. Key features: Server mode, emulating one or more slave [devices](https://www.automation-pros.com/modbus/UserManual.pdf), using any of the three typical connection types, including simultaneous connections of multiple types. Client mode, incorporating all three connection modes in one driver. Support for Modbus Function Codes 20 and 21, File Records. Configure protocol tweaks for troublesome devices per slave unit, enabling suppor…

---

<div class="post-metadata">

**Author:** ![lrichardson](https://avatars.discourse-cdn.com/v4/letter/l/f1d935/32.png) [@lrichardson](https://forum.inductiveautomation.com/u/lrichardson)\
**Post date:** [July 9, 2021, 5:21pm UTC](https://forum.inductiveautomation.com/t/custom-modbus-request-to-tcp-device-via-scripting/48668/4 "2021-07-09T17:21:03Z")

</div>

Thank you Phil. I do have a snip of the request & expected payload. Concurrent connections to the same device is another issue that I’m having to navigate on this application. The notes on your driver indicate that may be addressed as well. I’ll compile & share some info asap.

---

<div class="post-metadata">

**Author:** ![PRAMANJ](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pramanj/32/66935_2.png) [@PRAMANJ](https://forum.inductiveautomation.com/u/PRAMANJ)\
**Post date:** [July 10, 2021, 4:01am UTC](https://forum.inductiveautomation.com/t/custom-modbus-request-to-tcp-device-via-scripting/48668/5 "2021-07-10T04:01:46Z")

</div>

It shouldn't be difficult to connect modbus device on a TCP socket connection using scripts to read/write tags between modbus device and Ignition gateway.

---

<div class="post-metadata">

**Author:** ![nader.chinichian](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/nader.chinichian/32/9261_2.png) [@nader.chinichian](https://forum.inductiveautomation.com/u/nader.chinichian)\
**Post date:** [July 10, 2021, 1:27pm UTC](https://forum.inductiveautomation.com/t/custom-modbus-request-to-tcp-device-via-scripting/48668/6 "2021-07-10T13:27:25Z")

</div>

You can use UCON driver from kepware for this as well but if cost matters, just use python script and open your own TCP connection in ignition.

[https://www.kepware.com/en-us/products/kepserverex/drivers/u-con/](https://www.kepware.com/en-us/products/kepserverex/drivers/u-con/)
