GHI Electronics NETMF SDK 2015 R1 Pre-Release 3

@ Dat -

UART.Handshake = Handshake.None; //Exception if not None

Handshake.None was what worked for the functioning app (when using firmware 4.3.6.0)

Also tried Handshake.RequestToSend

@ willgeorge -

Full feature was just added in few previous versions which may not in 4.3.6.0

I think 4.3.7.9 is fully added.

@ Dat -
Thanks for your replies…

The more I think about it I should not have been using a K socket even though I could do what I wanted when using firmware 4.3.6.0.

Because a K socket supports RTS/CTS I should not be trying to change their state.

Anyway, Using firmware 4.3.7.9, I changed to using socket 1 (SUY) COM4 and I can set/reset RTS/CTS to what I want once the serial port is created.

Have a great day!

With this pre-release it still seems to be impossible to update a G400 (fez raptor) SSL Seed. I always have to resort to using MFDeploy.

Also (and this maybe something wrong with my code) when plugging in the network cable, once an IP address has been obtained, the character display corrupts.

Here is my sample code:

        
        private MenuContent mainDisplayContent = new MenuContent();

        private void NetworkChange_NetworkAddressChanged(object sender, EventArgs e)
        {
            var ip = IPAddress.GetDefaultLocalAddress();
            if (!ip.Equals(IPAddress.Any))
            {
                if (ip.ToString().Length <= 12)
                {
                    mainDisplayContent.Line1 = "IP: " + ip;
                }
                else
                {
                    mainDisplayContent.Line1 = ip.ToString();
                }
            }
            else
            {
                mainDisplayContent.Line1 = "Awaiting DHCP...";
            }
            Display.Flush();
        }


public class MenuContent
    {
        public MenuContent()
        {
            Name = "";
            Line1 = "";
            Line2 = "";
        }

        public string Name { get; set; }
        public string Line1 { get; set; }
        public string Line2 { get; set; }

        public override string ToString()
        {
            return Line1 + "                \n" + Line2 + "                "; //TODO: this is a hack to make the display refresh properly
        }
    }

    public static class Display
    {

        public static ArrayList Menu = new ArrayList();
        static int currentMenuId = 0;

        public static CharacterDisplay m_display { get; set; }


        public static void EnableBacklight(int Timeout)
        {
            m_display.BacklightEnabled = true;
            GT.Timer backlightTimer = new GT.Timer(Timeout);
            backlightTimer.Tick += backlightTimer_Tick;
            backlightTimer.Start();

        }

        static void backlightTimer_Tick(GT.Timer timer)
        {
            m_display.BacklightEnabled = false;
            timer.Stop();
        }

        public static void Flush()
        {

            if (Menu[currentMenuId] != null)
            {
                MenuContent item = Menu[currentMenuId] as MenuContent;

                m_display.SetCursorPosition(0, 0);

                if (item.Line1 == string.Empty || item.Line2 == string.Empty)
                    m_display.Clear();

                m_display.Print(item.ToString());
            }

        }

        public static void RotateMenu()
        {
            if (currentMenuId < Menu.Count -1)
            {
                currentMenuId += 1;
                Flush();
            }
            else
            {
                currentMenuId = 0;
                Flush();
            }
        }

    }

Sorry, for some reason, the main piece of code doesn’t seem to want to fully show in the code block, so here it is in plain text:

    private void NetworkChange_NetworkAddressChanged(object sender, EventArgs e)
    {
        var ip = IPAddress.GetDefaultLocalAddress();
        if (!ip.Equals(IPAddress.Any))
        {
            if (ip.ToString().Length <= 12)
            {
                mainDisplayContent.Line1 = "IP: " + ip;
            }
            else
            {
                mainDisplayContent.Line1 = ip.ToString();
            }
        }
        else
        {
            mainDisplayContent.Line1 = "Awaiting DHCP...";
        }
        Display.Flush();
    }

@ andre.m - GHI.Utilities.Crc still exists in GHI.Hardware.dll.

@ networkfusion - What socket do you have the character display connected to? Do you get any error from FEZ Config when trying to update the seed?

Checked it,
A minor issue in there is, when open com2 it also reset those pins. So create serial port then create those 2 pins after that is a solution for now.

@ John -

Character display is on port 16

I have updated my display tostring code to:


        public override string ToString()
        {
            string line1 = Line1;
            while (line1.Length < 16)
                line1 += " ";

            string line2 = Line2;
            while (line2.Length < 16)
                line2 += " ";

            return line1 + "\n" + line2;
        }

and this only corrupts for a couple of cycles before amending it’s self. Maybe it is some form of buffer overflow?!

FezConfig doesn’t show an error or confirmation, you just click the button and it seems to do nothing.

My experience has been that += on strings is a Bad Thing in NETMF. For padding some finite amount, I would recommend either doing a substring of a padding string:

string padding = "                ";
foo = leftSide + padding.Substring(0, 16 - leftSide.Length);

or for bigger or more complex concatenations, use StringBuilder.

No idea if that is the source of your problem (probably isn’t), but it certainly lept out at me as a general practice. Avoid += concatenation when there are other options.

@ networkfusion - It doesn’t look like I have enough of code to run it. Can you post a complete but minimal example? Ideally using only our classes.

lots happened since I asked - native SPI display support. Is it in this firmware, if so where do I find it to start testing :slight_smile:

@ Brett - It’s actually been in the past few SDKs for Cerberus. It did change a bit recently though. Take a look at GHI.Display. You’ll want to set Width, Height, DisplayType, Bpp, and SpiModule at a minimum, also ChipSelectPin and CurrentRotation if desired. For the N18, we also support BacklightPin, ResetPin, and ControlPin. Then call Save. Similar to what you do for LCD displays.

Take a look at: https://bitbucket.org/ghi_elect/gadgeteer/src/149f0b6877b684744b6fd52ce68d59154185019f/Mainboards/GHIElectronics/FEZCerberus/FEZCerberus_43/FEZCerberus_43.cs?at=master#cl-265

Right now, SPI display support is pretty hard coded to work with the N18 since that was originally added, along with the GameO display, to improve performance on the Cerb family. Today, it works on the G80 as well. If you set ControlPin, it will initialize the N18 for you, if you set BacklightPin, it’ll enable that, and if you set ResetPin, it’ll reset the display before initializing. In the following SDK, we plan to look into expanding this support to all boards with a more generic API.

As mentioned in the announcement news post, the display is tied to the N18 resolution today. But you can make creative use of the draw window and the Flush(int, int, int, int) overload to draw a different sized screen.

Thanks @ John. Can’t seem to find GHI.Display in https://www.ghielectronics.com/downloads/man/Library_Documentation_v4.3/html/R_Project_NETMF_Libraries_API_Reference.htm is that just not up to date ? And I can’t find GHI.Display in object browser either.

@ Brett - Sorry about that, GHI.Processor.Display.

@ andre.m - I do not remember anything changing on CAN. Show some code please.

Ignore that exception, try to reset and deploy again.
That exception doesn’t relate to CAN.
Are you using USBHost in your device?

@ andre.m - It’s an issue we’ve been trying to track down for a while now. It is possible that we can catch it internally so you do not see it, so we will look into that. The exception is usually transient and only affects the program when you’re debugging because VS catches it.

Change to Hibernate behaviour on EMX

I’m porting a fairly large established application from 4.2 to 4.3, using this release (4.3.7.9), pretty well everything seems to be working, however the new Hibernate implementation is giving me problems. I haven’t found anything on the forum, is this a known issue?
I’ve changed my Hibernate implementation from:


public override void Hibernate()
{ 
    Power.Hibernate(Power.WakeUpInterrupt.InterruptInputs); 
 }

to:

 
public override void Hibernate()
{ 
   PowerState.WakeupEvents |= HardwareEvent.OEMReserved1;
   PowerState.Sleep(SleepLevel.DeepSleep, HardwareEvent.OEMReserved1);
}

and the device goes into Hibernate as expected, and comes out at the touch of a button, however when it comes out the LCD display output is garbled and unreadable. As far as I can tell (without a display or debugger after hibernate) everything else is working ok, the Analog inputs and output, PCM LEDs, input buttons, USB switching in and out of Disk Drive Mode, etc.

The LCD is a standard 16x2, driven from IO7,13,15,16,17,18,20,21.

If I comment out the two PowerState lines, everything proceeds normally (pre-standby message, backlight out, immediate return), no problems with display. So the problem is something that happens in the DeepSleep mode, most likely to do with one or more of those IO lines.

I did see some mention of problems with CAN and Hibernate in the forums, and as IO20 is also CAN that may be a clue?
It connects to E on my display.

@ C-Born - The same display maintained its output after hibernate in 4.2? How about during hibernate?

@ John - Before going into Hibernate we display “In Standby”, then turn off the backlight. On coming out of Hibernate the backlight is turned on, and normal display restored.
With both 4.2 and 4.3 firmware the “In Standby” message remains on the display during Hibernate and briefly afterwards, until the normal display resumes - correctly with 4.2, garbage (or incorrect/out of sync) characters with 4.3.