Skip to content
View in the app

A better way to browse. Learn more.

Power Forum - Renewable Energy Discussion

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Calling all programmers - help!

Featured Replies

Hi All,

 

Need some advice as I am stumped/stupid. I am trying to fiddle around in C# to call the inverter with certain commands. I got the basics going and get the NAK response. (Been a LONG time since I programmed so snails pace.)

 

The problems are as follows:

 

  1. Could someone please help me with the fixed CRC codes to send for the following commands - I know they are calculated but after that remains the same:
    • POP00 = Run off Utility
    • POP02 = Run off Batteries
    • QPIGS
    • QPIRI
  2. How on earth do I send these CRC values to the serial port in C# - I have tried serialport.write (send string & hex byte, serialport.writeline (send string as hex translated to char) etc.

I get the NAK response if using serialport.writeline("QPIGS") - that obviously should not work, but that proves the port is open and readable.

 

Please?

//TO SENDSerialPort sp = new SerialPort(); sp.PortName = "COM3";            sp.BaudRate = 2400;            sp.DataBits = 8;            sp.Parity = Parity.None;            sp.StopBits = StopBits.One;            sp.Open();            sp.DataReceived += new SerialDataReceivedEventHandler(DataReceivedHandler);            sp.ErrorReceived += new SerialErrorReceivedEventHandler(DataErrorReceivedHandler);            ProtocolCommand.command = "QPI";            byte[] tx = ProtocolCommand.GetBytes(Encoding.ASCII.GetString(ProtocolCommand.QPI),                        CRC16.Calculate(Encoding.UTF8.GetBytes(Encoding.ASCII.GetString(ProtocolCommand.QPI))));            sp.Write(tx, 0, tx.Length);//RECIEVE RESPONSESpublic void DataReceivedHandler(object sender, SerialDataReceivedEventArgs e)        {            var sp = sender as SerialPort;            MemoryStream _rxBuffer = new MemoryStream();            bool _gotResponse = false;            if ((sp != null) && (!_gotResponse))            {                while (sp.BytesToRead > 0)                {                    byte b = (byte)sp.ReadByte();                    _rxBuffer.WriteByte(;                    if (b == 0x0d)                    {                        _gotResponse = true;                        break;                    }                }            }            _gotResponse = false;            _rxBuffer.Position = 0;            SetText(Encoding.ASCII.GetString(_rxBuffer.ToArray()));            Datalogger.insertRecord(ProtocolCommand.command, Encoding.ASCII.GetString(_rxBuffer.ToArray()));            _rxBuffer.Dispose();        }

Hope this helps :)

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.