title: C# MODBUS RTU for REGISTER READING
body: <p>I am currently in the process of writing a c# program in VS where it reads the holding registers of a Panasonic KW9M-A Power Meter using Modbus-RTU. The holding register i'm trying to read is:
  00A4H to 00A5H; Unsigned 32bit</p>
  <p>Note: I wrote this in Console app. I used NModbus4 by Maxwe11
  Idk what i'm missing since i'm a beginner in programming. Can someone please assist me? Thank you in advance :)</p>
  <p>Here is what i have so far:</p>
  <pre><code>using System;
  using System.Collections.Generic;
  using System.IO.Ports;
  using System.Linq;
  using System.Text;
  using System.Threading.Tasks;
  
  namespace Console_ye
  {
      class Program
      {
  
          public static void Main(string[] args)
          {
              SerialPort serialPort = new SerialPort(&quot;COM13&quot;, 115200, Parity.Odd, 8, StopBits.One);
              serialPort.Open();
  
              Console.WriteLine(&quot;This is the beginning: &quot;);
  
              string hex_add = &quot;0x00A4&quot;;
              ushort dec_add = Convert.ToUInt16(hex_add, 16);
  
              Console.WriteLine(&quot;Value of hex: &quot; + hex_add);
              Console.WriteLine(&quot;Value of ushort: &quot; + dec_add);
  
              byte slaveId = 1;
              ushort startAddress = dec_add;
              ushort numberOfPoints = 8;
              IModbusMaster masterRTU = ModbusSerialMaster.CreateRtu (serialPort);
              ushort[] ushortArray = masterRTU.ReadHoldingRegisters(slaveId, startAddress, numberOfPoints);
  
              Console.WriteLine(&quot;Here &quot; + ushortArray[0]);
              foreach (ushort item in ushortArray)
              {
                  Console.WriteLine(string.Join (&quot;\n&quot;, item));
              }
          }
      }
  } 
  </code></pre>