# ModbusTCP with Strings

**URL:** <https://forum.inductiveautomation.com/t/modbustcp-with-strings/111504>\
**Category:** Ignition\
**Tags:** ignition81\
**Created:** [October 16, 2025, 5:26am UTC](https://forum.inductiveautomation.com/t/modbustcp-with-strings/111504 "2025-10-16T05:26:25Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![David\_Stone](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/david_stone/32/79749_2.png) [@David\_Stone](https://forum.inductiveautomation.com/u/David_Stone)\
**Post date:** [October 16, 2025, 5:26am UTC](https://forum.inductiveautomation.com/t/modbustcp-with-strings/111504/1 "2025-10-16T05:26:25Z")

</div>

Doing the same as this thread here:

> [@Automation Direct ViewMarQ](https://forum.inductiveautomation.com/t/automation-direct-viewmarq/11266/7):
>
> Reviving an old thread here in hopes someone can help. We finally are trying a Viewmarq with Ignition via Modbus TPC and I’m having a hard time with the addressing and setup. I have an established connection on the gateway and set up a message on the Viewmarq; our first step was to try and write a variable but this isn’t working. We then went back and tried the example above (adopted for our device name) and still no joy. I’d really love to get this working. Tech support at both Inductive and A…

I need to send the following string:  
`<ID 0><CLR><WIN 0 0 287 31><POS 0 0><LJ><BL N><CS 0><GRN><T>Testing</T>`  
This needs to be terminated by a carriage return $0D in ascii.

```python
Msg = '<ID 0><CLR><WIN 0 0 287 31><POS 0 0><LJ><BL N><CS 0><GRN><T>Testing2</T>' + chr(13) + chr(13)
length = len(Msg)
system.opc.writeValues('Ignition OPC UA Server',['[Sign]1.HRS11000:'+str(length)],[Msg])

```

[ModbuCapture.pcapng](https://forum.inductiveautomation.com/uploads/short-url/u4Xkg3KfujuphFwGGxYEJCfncMC.pcapng) (7.4 KB)

In the Wireshark capture, the characters are reverse byte order, and "Testing2" string does not work, but "Testing" does work. "Testing" is sent with the manufacturers tool running on the same computer as the gateway. "Testing2" is sent with the code above.

Does anyone have any great ideas about what is different in these packets? I see the `CC 0D` terminating string, but Ignition will not send the packet if I put in a `chr(204) + chr(13)` as the end of the string.

---

<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:** [October 16, 2025, 11:46am UTC](https://forum.inductiveautomation.com/t/modbustcp-with-strings/111504/2 "2025-10-16T11:46:01Z")

</div>

> [@David\_Stone](#):
>
> the characters are reverse byte order

There's setting for that.

> [@David\_Stone](#):
>
> `['[Sign]1.HRS11000:'+str(length)]`

Just use a constant length. Ignition will null-pad.

> [@David\_Stone](#):
>
> will not send the packet if I put in a `chr(204) + chr(13)` as the end of the string

Characters in jython are not bytes. They are unicode codepoints and will be encoded as bytes. I'm not sure what you need for this, perhaps a byte array.

If you cannot get this work, consider using my driver's `system.opc.rawModbus()` function.

---

<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:** [October 16, 2025, 11:51am UTC](https://forum.inductiveautomation.com/t/modbustcp-with-strings/111504/3 "2025-10-16T11:51:16Z")

</div>

> [@pturmel](#):
>
> > [@David\_Stone](#):
> >
> > will not send the packet if I put in a `chr(204) + chr(13)` as the end of the string
> 
> Characters in jython are not bytes. They are unicode codepoints and will be encoded as bytes. I'm not sure what you need for this, perhaps a byte array.

Yeah this bit has me curious. Wondering if there's some unicode roundtrip stuff going on, since this is a String he's writing to after all.

---

<div class="post-metadata">

**Author:** ![David\_Stone](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/david_stone/32/79749_2.png) [@David\_Stone](https://forum.inductiveautomation.com/u/David_Stone)\
**Post date:** [October 16, 2025, 8:58pm UTC](https://forum.inductiveautomation.com/t/modbustcp-with-strings/111504/4 "2025-10-16T20:58:27Z")

</div>

> [@pturmel](#):
>
> perhaps a byte array

```python
s="<ID 1><CLR><WIN 0 0 287 31><POS 0 0><LJ><BL N><CS 0><GRN><T>rTest</T>\r\r"
sEncode = s.encode("ascii")
sArray = bytes(sEncode)
system.opc.writeValue("Ignition OPC UA Server","[Sign]1.HRS10999:"+ str(len(sArray)),sArray)

```

This actually works... Good call on using a non string datatype.

> [@pturmel](#):
>
> Just use a constant length. Ignition will null-pad.

This is true, but then it sends a full length packet every time, and that's not what the display is designed to handle for some reason according to the manual.
