Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

State remains in Connected and not going into Selected #84

Closed
Mihai-BB opened this issue Jul 5, 2023 · 0 comments
Closed

State remains in Connected and not going into Selected #84

Mihai-BB opened this issue Jul 5, 2023 · 0 comments

Comments

@Mihai-BB
Copy link

Mihai-BB commented Jul 5, 2023

Hi and thanks for sharing this secs library.
I am trying to use secs4net in testing with xunit. Basically just sending commands to a client and receiving the reply.
Your demo app works great but importing the code to a async xunit fact is not working.
I just used the code you wrote on the Enable button event and the connector state will not change to Selected and remains in Connected.
The options that Im using are:
Active:true
Ip: 127.0.0.1
DeviceId:0

Should I try setting also a custom T7 timeout?
Below is the code I am using (xunit test)
`
[Fact(DisplayName = "Check Host -> Client Connect")]
public async void Verify_SECS_HostConnection()
{
_secsGem?.Dispose();

        if (_connector is not null) await _connector.DisposeAsync();

        var options = Options.Create(new SecsGemOptions
        {
            IsActive = true,
            IpAddress = "127.0.0.1",
            Port = 5000,
            SocketReceiveBufferSize = 65535,
            DeviceId = 0,
        });

        _connector = new HsmsConnection(options, _logger);
        _secsGem = new SecsGem(options, _connector, _logger);

        _connector.ConnectionChanged += delegate
        {
            Console.WriteLine(_connector.State.ToString());
        };

        _ = _connector.StartAsync(_cancellationTokenSource.Token);

        try
        {
            await foreach (var primaryMessage in _secsGem.GetPrimaryMessageAsync(_cancellationTokenSource.Token))
            {
                recvBuffer.Add(primaryMessage);
            }
        }
        catch (OperationCanceledException)
        {

        }

}`

UPDATE:
After reviewing more detailed your code, I think this issue can be moved to closed: There was an exception generated by T7 timer which generated the problem and I was able to fix it myself

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant