# \[Bug\] system.opc.readValues() misses some values until system.opc.readValue() is used on them

**URL:** <https://forum.inductiveautomation.com/t/bug-system-opc-readvalues-misses-some-values-until-system-opc-readvalue-is-used-on-them/94652>\
**Category:** Ignition\
**Tags:** ignition81, perspective\
**Created:** [August 14, 2024, 2:19pm UTC](https://forum.inductiveautomation.com/t/bug-system-opc-readvalues-misses-some-values-until-system-opc-readvalue-is-used-on-them/94652 "2024-08-14T14:19:47Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Ryan\_Deardorff](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/ryan_deardorff/32/63815_2.png) [@Ryan\_Deardorff](https://forum.inductiveautomation.com/u/Ryan_Deardorff)\
**Post date:** [August 14, 2024, 2:19pm UTC](https://forum.inductiveautomation.com/t/bug-system-opc-readvalues-misses-some-values-until-system-opc-readvalue-is-used-on-them/94652/1 "2024-08-14T14:19:47Z")

</div>

I have some code that reads a list of OPC values using `system.opc.readValues()`, and noticed that often some values were returning as `None`. As soon as I would read the same path using the OPC Quick Client, suddenly the value would start showing up using `system.opc.readValues()`. This made me wonder if iterating through each path individually with `system.opc.readValue()` would work, and indeed it does, so I now have a check for `None` that causes the individual iteration to kick in if the batch read doesn't work:

```python
def toolingUpdateFanuc(thorough=False):
	fos = getFasOpcServers()
	for machine in fos.keys():
		# REDACTED (populate tCounts and tPresets)
		counts = []
		if thorough:
			for i in range(numCounts):
				counts.append(system.opc.readValue(server, tCounts[i]))
			for i in range(numCounts):
				counts.append(system.opc.readValue(server, tPresets[i]))
		else:
			counts = system.opc.readValues(server, tCounts + tPresets)	# This doesn't always successfully read all values, hence the need for 'thorough'
		rawVals = []
		for i in range(numCounts):
			if counts[i].value is not None and counts[i + numCounts].value is not None:
				rawVals.append(tStations[i] + ' = ' + str(int(float(counts[i].value))) + ', ' + str(int(float(counts[i + numCounts].value))))
			else:
				if not thorough:	# Count and/or preset are None, so retry as 'thorough'
					toolingUpdateFanuc(True)
					return
				raise Exception(str(tStations[i]) + ' = ' + str(counts[i].value) + ', ' + str(counts[i + numCounts].value))
		system.tag.writeBlocking([machine + '/' + machine + '/_OPC/Tooling/Raw/Counts'], [rawVals])

```

---

<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:** [August 14, 2024, 2:30pm UTC](https://forum.inductiveautomation.com/t/bug-system-opc-readvalues-misses-some-values-until-system-opc-readvalue-is-used-on-them/94652/2 "2024-08-14T14:30:42Z")

</div>

This isn't necessarily a bug.

It sounds like whatever server/driver you're reading from batches read items into requests and some combinations include invalid addresses or addresses that otherwise cause the request to fail.

---

<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:** [August 14, 2024, 2:32pm UTC](https://forum.inductiveautomation.com/t/bug-system-opc-readvalues-misses-some-values-until-system-opc-readvalue-is-used-on-them/94652/3 "2024-08-14T14:32:32Z")

</div>

> [@Ryan\_Deardorff](#):
>
> `getFasOpcServers()`

Ha, if this is a fanuc OPC server then I take it back, it probably _is_ a bug... in that server.

---

<div class="post-metadata">

**Author:** ![Ryan\_Deardorff](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/ryan_deardorff/32/63815_2.png) [@Ryan\_Deardorff](https://forum.inductiveautomation.com/u/Ryan_Deardorff)\
**Post date:** [August 14, 2024, 2:33pm UTC](https://forum.inductiveautomation.com/t/bug-system-opc-readvalues-misses-some-values-until-system-opc-readvalue-is-used-on-them/94652/4 "2024-08-14T14:33:14Z")

</div>

> Ha, if this is a fanuc OPC server

Yes, yes it is...

---

<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:** [August 14, 2024, 2:33pm UTC](https://forum.inductiveautomation.com/t/bug-system-opc-readvalues-misses-some-values-until-system-opc-readvalue-is-used-on-them/94652/5 "2024-08-14T14:33:46Z")

</div>

Well, if you disable security on that OPC connection and get a Wireshark capture then we can see for sure what's happening.

---

<div class="post-metadata">

**Author:** ![Ryan\_Deardorff](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/ryan_deardorff/32/63815_2.png) [@Ryan\_Deardorff](https://forum.inductiveautomation.com/u/Ryan_Deardorff)\
**Post date:** [August 14, 2024, 2:42pm UTC](https://forum.inductiveautomation.com/t/bug-system-opc-readvalues-misses-some-values-until-system-opc-readvalue-is-used-on-them/94652/6 "2024-08-14T14:42:56Z")

</div>

I have other more pressing items on my plate at the moment, and since my workaround seems to address the issue I need to move on to them, but hopefully I'll get a chance to revisit this since it isn't an ideal solution...
