fix(ab-transport): RegisterSession carries a zero sender context (found by Task 17 controllogix)
ab_server's RegisterSession sanity check rejects any non-zero sender context with encapsulation status 1 and a header-only reply, so every native session against the simulator failed with BadCommunicationError. libplctag sends zero (logix-register-session.hex); the codec test now matches that capture byte for byte instead of excluding the context, and a client test pins the zero on the wire.
This commit is contained in:
@@ -82,7 +82,7 @@ public sealed class EncapsulationClient : IAsyncDisposable
|
||||
try
|
||||
{
|
||||
var (header, _) = await client.ExchangeAsync(connected: false,
|
||||
(ctx, _) => EncapsulationCodec.RegisterSession(ctx), timeout, ct).ConfigureAwait(false);
|
||||
(_, _) => EncapsulationCodec.RegisterSession(), timeout, ct).ConfigureAwait(false);
|
||||
client.SessionHandle = header.SessionHandle;
|
||||
return client;
|
||||
}
|
||||
|
||||
@@ -30,9 +30,13 @@ public static class EncapsulationCodec
|
||||
return w.ToArray();
|
||||
}
|
||||
|
||||
/// <summary>RegisterSession: protocol version 1, option flags 0.</summary>
|
||||
public static byte[] RegisterSession(ulong ctx) =>
|
||||
Finish(Header(EncapCommand.RegisterSession, 0, ctx).U16(1).U16(0));
|
||||
/// <summary>RegisterSession: protocol version 1, option flags 0, and a <b>zero</b> sender context.</summary>
|
||||
/// <remarks>The sender context is always zero, as libplctag sends it (<c>logix-register-session.hex</c>):
|
||||
/// ab_server's RegisterSession sanity check rejects any non-zero context with encapsulation status 1
|
||||
/// and a header-only reply, so a per-request context here failed every native session against the
|
||||
/// simulator. The reply is still matched — unconnected matching tolerates a zero context.</remarks>
|
||||
public static byte[] RegisterSession() =>
|
||||
Finish(Header(EncapCommand.RegisterSession, 0, 0).U16(1).U16(0));
|
||||
|
||||
/// <summary>UnRegisterSession: header only, no data.</summary>
|
||||
public static byte[] UnRegisterSession(uint session, ulong ctx) =>
|
||||
|
||||
Reference in New Issue
Block a user