Hello experts,

I'm currently trying to make program that sends commands to my home security system. I have it connected to my computer trough the COM port, this feature allow me to control my system by sending hex ASCII codes.

I hope that someone could help me make a function that converts the command numbers into hex ASCII codes, calculates the checksum and adds the end of packet codes.

Here is an example of a complete command:

One of the commands I want to send is: “6543”.
The ASCII codes for this would be: 36 35 34 33

The Checksum = 36+35+34+33 = D2
D = 44 (ASCII)
2 = 32 (ASCII)

“0D” and “0A” needs to be added at the end of the transmission (End of Packet).

The complete transmission need to be in a continuous string. In this example the finalized string would be: 3635343344320D0A.


5 Years
Discussion Span
Last Post by Zalo83

I have made some progress but I am struggling with calculating the checksum and adding the end of packet signs.

I will use this code to convert the numbers into Hex ASCII code:

#region StringToHex

        public string ConvertToHex(string msgtext)
            string hex = "";
            foreach (char c in msgtext)
                int tmp = c;
                hex += String.Format("{0:x2}", (uint)System.Convert.ToUInt32(tmp.ToString()));

            return hex;

Edited by Zalo83: n/a

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.