Connot comminicating with hercules or devices (SOLVED)

Dec 30, 2011 at 2:10 PM


I tried socket examples its working well with telnet.

But when i try it with devices and hercules tcp test program its not working.

I check the comminication with wire shark, wire shark is show the data but tcp server didnt dont shown in CustomCommandParser-> Parse command


Dec 30, 2011 at 2:26 PM

Did you take a look at the test case class TestSocketServer? You can verify the correction by NUnit.


It might be an encoding issue?

Dec 30, 2011 at 2:33 PM
Edited Dec 30, 2011 at 3:10 PM


        private const byte CR = 0xD;
        private const byte LF = 0xA;
        public override void StartSession()
            byte[] byteData = Encoding.Default.GetBytes("V" + (char)CR + (char)LF);
            StringBuilder sbc = new StringBuilder(byteData.Length * 2);
            for (int i = 0; i < byteData.Length; i++)
                byte b = byteData[i];
                sbc.AppendFormat("{0:x2}", b);
            this.SocketSession.SendResponse(byteData, 0, byteData.Length);


I get encoding from the old socket server program. 

How can i change the Default Encoding ?

Can you please try to receive data from hercules.

I look the test case class but actually i dont know how to use NUnit.

hercules download link -> its small file

Dec 31, 2011 at 1:28 AM

The class CommandLineProtocol has a constructor which has an encoding parameter...

Dec 31, 2011 at 8:18 AM
Edited Dec 31, 2011 at 8:21 AM

I found the problem that server waiting endofline for comminication, but I dont set it.  I added this $0D$0A end off the line and problem is solved.

Our comminication line ending is marked with two string char like "vs".

When the client connected i send it to one char "v" and client send me own serial number. So in the first comminication I couldnt use custom command.

when i get the serial number i send client to -> SendResponse("" + (char)0xFF + (char)0x02 + (char)0x4C + (char)0x0D);

and then client send me more string data.

So first off all i must change end of line dynamically.