0

I transmit data using an UDP connection to the program on my server. The data is transmitted by an modem from Quectel BC66. The AT command from terminal is shown below:

AT+QISEND=0,20,12345678910111213112

OK

SEND OK

When the data appears on the server instead of showing the data which was sent it shows question marks:

enter image description here

The code of the program is shown below:

class Program
    {
        static void Main(string[] args)
        {
            try
            {
                IPEndPoint ip = new IPEndPoint(IPAddress.Any, 29030);
                UdpClient server = new UdpClient(ip);
                Console.ForegroundColor = ConsoleColor.Green;
                Console.WriteLine("[UDP] [Listenning]");
                while (true)
                {
                    byte[] data = server.Receive(ref ip);
                    string ch = Encoding.Unicode.GetString(data, 0, data.Length);
                    Console.ForegroundColor = ConsoleColor.Green;
                    Console.WriteLine(ch + " " + DateTime.Now.ToString());
                    string serv_msg = "Server received the data";
                    byte[] msg = Encoding.Unicode.GetBytes(serv_msg);
                    server.Send(msg, msg.Length, ip);
                    server.Send(new byte[] { 1 }, 1, ip);
                }
            }
            catch
            {
                Console.WriteLine("Warrning:connection failed");
                Console.ReadKey();
            }
        }
    }
}

Do you have any suggestion on how to show the sent data identical on the server program?

AdiT
  • 539
  • 5
  • 18

1 Answers1

0

It seems like your terminal application does not support the Unicode characters you are trying to show.

Try changing your settings to allow unicode characters or switch to another terminal emulator like ConEmu.

Hope this helps!

ZektorH
  • 2,680
  • 1
  • 7
  • 20