diff --git a/docs/drivers/FOCAS.md b/docs/drivers/FOCAS.md
index 34f7a0635..1d433f668 100644
--- a/docs/drivers/FOCAS.md
+++ b/docs/drivers/FOCAS.md
@@ -640,7 +640,7 @@ test fixtures (`tests/.../Driver.FOCAS.Tests/Fixtures/v3/`). Client-visible chan
| What | Before | Now |
|------|--------|-----|
-| `cnc_rdmacro` decimal | read at payload offset 4 — a constant `10` length field — so `#500 = 1.0` published `0.01` | `dec_val` at offset 6; `mantissa / 10^dec`. Vacant variable → `BadNoData`; fractional value on an integer tag → `BadTypeMismatch`; integer tags receive the exact whole value |
+| `cnc_rdmacro` decimal | read at payload offset 4 — a constant `10` length field — so `#500 = 1.0` published `0.01` | `dec_val` at offset 6; `mantissa / 10^dec`. Vacant variable → `BadNoData`; fractional value on an integer tag → `BadTypeMismatch`; integer tags receive the exact whole value. A reply too short to decode (macro, parameter) is `BadTypeMismatch` on that tag with no health impact: the CNC answered and the session is intact (#1036, `FocasWirePayloadException`) |
| Axis positions | scaled by `cnc_getfigure` (0x00D3), which does not exist — on hardware: raw counts | scaled by each block's own `base^exponent`; undescribable block → `BadNoData` |
| Axis / spindle names | first 2 of 4 record bytes — `AA6`/`AA7` collapsed to `AA` | whole record up to the first NUL (residue after it discarded) — ⚠️ `Axes/AA_1`→`Axes/AA6` on such a machine |
| `ServoLoad` | `value / 10^base` (offset 4 is the base, 10) — always ~0 | `value / base^exponent`, a direct percentage |
diff --git a/src/Drivers/ZB.MOM.WW.OtOpcUa.Driver.FOCAS/Wire/FocasWireClient.cs b/src/Drivers/ZB.MOM.WW.OtOpcUa.Driver.FOCAS/Wire/FocasWireClient.cs
index ad59440e3..de237a35e 100644
--- a/src/Drivers/ZB.MOM.WW.OtOpcUa.Driver.FOCAS/Wire/FocasWireClient.cs
+++ b/src/Drivers/ZB.MOM.WW.OtOpcUa.Driver.FOCAS/Wire/FocasWireClient.cs
@@ -1362,7 +1362,7 @@ public sealed class FocasWireClient : IAsyncDisposable, IDisposable
private static void RequireLength(byte[] payload, int length, string call)
{
if (payload.Length < length)
- throw new FocasWireException($"{call} returned {payload.Length} bytes; expected at least {length}.", rc: null);
+ throw new FocasWirePayloadException($"{call} returned {payload.Length} bytes; expected at least {length}.");
}
private static bool IsTransientException(Exception exception)
diff --git a/src/Drivers/ZB.MOM.WW.OtOpcUa.Driver.FOCAS/Wire/FocasWireException.cs b/src/Drivers/ZB.MOM.WW.OtOpcUa.Driver.FOCAS/Wire/FocasWireException.cs
index 37e493caa..2ac954229 100644
--- a/src/Drivers/ZB.MOM.WW.OtOpcUa.Driver.FOCAS/Wire/FocasWireException.cs
+++ b/src/Drivers/ZB.MOM.WW.OtOpcUa.Driver.FOCAS/Wire/FocasWireException.cs
@@ -62,3 +62,19 @@ public class FocasWireException : Exception
IsTransient = isTransient;
}
}
+
+///
+/// A well-formed reply whose payload is too short to decode (#1036). The CNC answered and the session is
+/// intact, so this is a decode refusal for the one tag - not a comms fault - and maps to
+/// BadTypeMismatch rather than BadCommunicationError (which would degrade driver health and feed
+/// the #527 watchdog over a shape problem that no reconnect can fix).
+///
+public sealed class FocasWirePayloadException : FocasWireException
+{
+ /// Initializes a new short/malformed-payload exception.
+ /// The exception message.
+ public FocasWirePayloadException(string message)
+ : base(message, rc: null)
+ {
+ }
+}
diff --git a/src/Drivers/ZB.MOM.WW.OtOpcUa.Driver.FOCAS/Wire/WireFocasClient.cs b/src/Drivers/ZB.MOM.WW.OtOpcUa.Driver.FOCAS/Wire/WireFocasClient.cs
index 918a1d195..f5ed42987 100644
--- a/src/Drivers/ZB.MOM.WW.OtOpcUa.Driver.FOCAS/Wire/WireFocasClient.cs
+++ b/src/Drivers/ZB.MOM.WW.OtOpcUa.Driver.FOCAS/Wire/WireFocasClient.cs
@@ -403,7 +403,7 @@ public sealed class WireFocasClient : IFocasClient
}
catch (FocasWireException ex)
{
- return (null, ex.Rc is short rc ? FocasStatusMapper.MapFocasReturn(rc) : FocasStatusMapper.BadCommunicationError);
+ return (null, MapWireFailure(ex));
}
}
@@ -419,7 +419,7 @@ public sealed class WireFocasClient : IFocasClient
}
catch (FocasWireException ex)
{
- return (null, ex.Rc is short rc ? FocasStatusMapper.MapFocasReturn(rc) : FocasStatusMapper.BadCommunicationError);
+ return (null, MapWireFailure(ex));
}
}
@@ -460,6 +460,20 @@ public sealed class WireFocasClient : IFocasClient
};
}
+ ///
+ /// The status a wire failure publishes: the CNC's own rc when it sent one; BadTypeMismatch for a reply
+ /// whose payload is too short to decode (#1036 - the session is intact and the CNC answered, so a shape problem
+ /// is a per-tag refusal, never a comms fault); otherwise BadCommunicationError.
+ ///
+ /// The wire failure.
+ /// The OPC UA status to publish for the tag.
+ internal static uint MapWireFailure(FocasWireException ex)
+ => ex.Rc is short rc
+ ? FocasStatusMapper.MapFocasReturn(rc)
+ : ex is FocasWirePayloadException
+ ? FocasStatusMapper.BadTypeMismatch
+ : FocasStatusMapper.BadCommunicationError;
+
private async Task<(object? value, uint status)> ReadMacroAsync(
FocasAddress address, FocasDataType type, CancellationToken cancellationToken)
{
@@ -472,7 +486,7 @@ public sealed class WireFocasClient : IFocasClient
}
catch (FocasWireException ex)
{
- return (null, ex.Rc is short rc ? FocasStatusMapper.MapFocasReturn(rc) : FocasStatusMapper.BadCommunicationError);
+ return (null, MapWireFailure(ex));
}
}
diff --git a/tests/Drivers/ZB.MOM.WW.OtOpcUa.Driver.FOCAS.Tests/FocasMacroDecodeTests.cs b/tests/Drivers/ZB.MOM.WW.OtOpcUa.Driver.FOCAS.Tests/FocasMacroDecodeTests.cs
index 15bcdaab6..1b35d595b 100644
--- a/tests/Drivers/ZB.MOM.WW.OtOpcUa.Driver.FOCAS.Tests/FocasMacroDecodeTests.cs
+++ b/tests/Drivers/ZB.MOM.WW.OtOpcUa.Driver.FOCAS.Tests/FocasMacroDecodeTests.cs
@@ -95,6 +95,27 @@ public sealed class FocasMacroDecodeTests
Should.Throw(() => FocasWireClient.ParseMacro(1, new byte[length]));
}
+ // #1036: a short payload is a decode refusal on a live session, not a comms fault.
+ [Theory]
+ [InlineData(0)]
+ [InlineData(7)]
+ public void A_short_macro_payload_publishes_BadTypeMismatch_not_BadCommunicationError(int length)
+ {
+ var ex = Should.Throw(() => FocasWireClient.ParseMacro(1, new byte[length]));
+ WireFocasClient.MapWireFailure(ex).ShouldBe(FocasStatusMapper.BadTypeMismatch);
+ }
+
+ [Fact]
+ public void Wire_failures_without_a_payload_shape_problem_keep_their_comms_mapping()
+ {
+ WireFocasClient.MapWireFailure(new FocasWireException("link down", rc: null))
+ .ShouldBe(FocasStatusMapper.BadCommunicationError);
+ WireFocasClient.MapWireFailure(new FocasWireException("closed", new System.IO.IOException(), isTransient: true))
+ .ShouldBe(FocasStatusMapper.BadCommunicationError);
+ WireFocasClient.MapWireFailure(new FocasWireException("refused", rc: 7))
+ .ShouldBe(FocasStatusMapper.MapFocasReturn(7));
+ }
+
// ---- published value / quality ----
[Fact]