I'm trying to create an interface that will allow my Company's software to interrogate the phones, change their status etc as well as record calls logged for bill purposes.
While the O.L.D driver is I metering mode, I have created an application that monitors TicketCollecotr.xml, and pulls the information out.
What I need to do now is expand on this, so that when the driver is in hotel mode, I can get the call data, but also send Handset commands ( changed the name on the display, block/unblock the handset etc .
with the code (below) and the driver in hotel mode, I can make a connection to port 2561 and send data, but I get no response back. On looking at the log.txt file, I see the data arriving, and then
Thu Sep 08 13:10:54 2022 WARN 32320 AlcAHLLinkLayer::extractMessage : 34 unexpected bytes received, ignored
I've tried with messagesent = (STX)@FFFF(ETX) , but get a simial error ( Less unexcepted bytes ) .
Can anyone expand on what the error means ? do I need to send something prior ? What am I doing wrong ?
Any help is grateful
Thank you
Code: Select all
public static async Task Main()
{
string barfpath = (@"barf.log");
Int32 port = 2561;
IPAddress ipAddr = IPAddress.Parse("127.0.0.1");
try
{
// Establish the remote endpoint for the socket.
IPEndPoint localEndPoint = new IPEndPoint(ipAddr, port);
// Creation TCP/IP Socket using Socket Class Constructor
Socket sender = new Socket(ipAddr.AddressFamily,
SocketType.Stream, ProtocolType.Tcp);
try
{
// Connect Socket to the remote endpoint using method Connect()
sender.Connect(localEndPoint);
// We print EndPoint information that we are connected
Console.WriteLine("Socket connected to -> {0} ",
sender.RemoteEndPoint.ToString());
System.IO.File.AppendAllText(barfpath, DateTime.Now.ToString() + " - Socket connected to -> " + sender.RemoteEndPoint.ToString() + "... " + Environment.NewLine);
// Creation of message that we will send to Server
byte[] messageSent = Encoding.ASCII.GetBytes("0x02 0x40 0x46 0x46 0x46 0x46 0x03");
int byteSent = sender.Send(messageSent);
// Data buffer
byte[] messageReceived = new byte[1024];
// We receive the message using the method Receive(). This method returns number of bytes
// received, that we'll use to convert them to string
int byteRecv = sender.Receive(messageReceived);
Console.WriteLine("Message from Server -> {0}",
Encoding.ASCII.GetString(messageReceived,
0, byteRecv));
System.IO.File.AppendAllText(barfpath, DateTime.Now.ToString() + " - Message from Server -> " + Encoding.ASCII.GetString(messageReceived,0, byteRecv) + Environment.NewLine);
// Close Socket using the method Close()
sender.Shutdown(SocketShutdown.Both);
sender.Close();
}
// Manage of Socket's Exceptions
catch (ArgumentNullException ane)
{
Console.WriteLine("ArgumentNullException : {0}", ane.ToString());
System.IO.File.AppendAllText(barfpath, DateTime.Now.ToString() + " - ArgumentNullException " + ane.ToString() + Environment.NewLine);
}
catch (SocketException se)
{
Console.WriteLine("SocketException : {0}", se.ToString());
System.IO.File.AppendAllText(barfpath, DateTime.Now.ToString() + " - SocketException " + se.ToString() + Environment.NewLine);
}
catch (Exception e)
{
Console.WriteLine("Unexpected exception : {0}", e.ToString());
System.IO.File.AppendAllText(barfpath, DateTime.Now.ToString() + " - Unexpected exception " + e.ToString() + Environment.NewLine);
}
}
catch (Exception e)
{
Console.WriteLine(e.ToString());
System.IO.File.AppendAllText(barfpath, DateTime.Now.ToString() + " - Mains Unexpected exception " + e.ToString() + Environment.NewLine);
}
}