Closed mgbee8 closed 2 years ago
Will test and get back to you on this
I could not reproduce this issue. I have used the libraries from this repo in the project CD4.AstmInterface. Can you please check whether you can reproduce the issue with this project.
What settings are you using. Serial or ethernet(client or server)?
Here is some example code from CD4.AstmInterface
. If you decide to check out CD4.AstmInterface
, please use the branch named EvidenceInvestigator-RandoxLaboratories in this repo or use the updated master
branch.
private async Task InitializeAstmAsync()
{
switch (Settings.ConnectionMode)
{
case ConnectionMode.Ethernet: //if using ethernet
var isPortValid = ushort.TryParse(Settings.Port.ToString(), out var uShortPort);
if (!isPortValid) { _logger.Error($"Invalid port defined: {Settings.Port}. Max value allowed for port is 65535"); return; }
_lowLevelConnection = new Lis01A02TCPConnection(Settings.IpAddress, uShortPort);
_lisConnection = new Lis01A2Connection(_lowLevelConnection);
await ConnectAsync();
break;
case ConnectionMode.Serial: // if using serial port
_lowLevelConnection = new Lis01A02RS232Connection(Settings.SerialPort);
_lisConnection = new Lis01A2Connection(_lowLevelConnection);
await ConnectAsync();
break;
default:
break;
}
}
private async Task ConnectAsync()
{
_lisParser = new LISParser(_lisConnection);
_lisParser.OnSendProgress += LISParser_OnSendProgress; //Send data progress will trigger this event
_lisParser.OnReceivedRecord += LISParser_OnReceivedRecord; //incoming LIS frames will trigger this event
try
{
//open a socket and listen if physical layer is ethernet and configured as listener
if (Settings.IsSever && Settings.ConnectionMode == ConnectionMode.Ethernet)
{
await ((Lis01A02TCPConnection)_lowLevelConnection).StartListeningAsync();
}
else //if the connection is serial or TCPIP and configured as client then just connect
{
_lisParser.Connection.Connect();
}
}
catch (Exception ex)
{
_logger.Error($"Error connecting: {ex.Message}\n{ex.StackTrace}");
MessageBox.Show(ex.Message);
}
}
Sorry, closed by mistake, re-opened. Please feel free to comment again
I just understood your question, it is suppose to sit there in the ReceiveLoop
. You just have to put it in another thread. It will raise events as data is received on socket. The above code and the AstmInterface
should give you an idea.
Thanks for the issue.
Thanks was able to get it working, have a different isue with the ENQ not responding. Not related to this project.
@mgbee8 i'v the same issue can you share how did you make it work plz ? ty
When calling LISParser.Connection.Connect(); the method never returns just sits in the ReceiveLoop and so never can call the send records method. Am I doing something incorrect. Just modified the example to separate order creation from order transmission and found this.