Main Site Documentation

Cerbuino Net Socket 1 RS232 Error


#1

I have a cerbuino net where i use socket 1 and 2 with the RS232 module.
I also use the onboard network adapter.
The module on socket 2 is working fine.
The module on socket 1 throws an error when i call configure on the RS232 module.
Error: A first chance exception of type ‘System.ArgumentException’ occurred in Microsoft.SPOT.Hardware.dll

The code for configuring the RS232 modules is the same.
The cerbuino is running MF net 4.3
The GHI assembly is 4.3.3.0

How can i solve this problem?


#2

Hi andre,

This is the code to configure the module.
I have the same code for ledsMaster2 on socket 2 and it works fine.
If i switch the socket numbers then the other function throws the error.
The same code runs on a hydra where everything works fine.
I also tested the code on an other cerbruino net, then i get the same error.

 
       private static RS232 ledsMaster1;

        public static void Connect(RS232 portMaster1)
        {
            try
            {
                ledsMaster1 = portMaster1;
                ledsMaster1.Configure(19200, SerialParity.None, SerialStopBits.One, 8, HardwareFlowControl.NotRequired);
                ledsMaster1.Port.Open();
                ledsMaster1.Port.NewLine = "\r";

                ledsMaster1.Port.LineReceived += Port_LineReceived;
            }
            catch (Exception ex)
            {
                Debug.Print("ledsMaster1 Connect error: " + ex.Message);
            }            
        }
 

#3

//------------------------------------------------------------------------------
// <auto-generated>
//     This code was generated by a tool.
//     Runtime Version:4.0.30319.18444
//
//     Changes to this file may cause incorrect behavior and will be lost if
//     the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------

namespace MFC.Micro.Cerbuino {
    using Gadgeteer;
    using GTM = Gadgeteer.Modules;
    
    
    public partial class Program : Gadgeteer.Program 
    {             
        /// <summary>The RS232 module using socket 1 of the mainboard.</summary>
        private Gadgeteer.Modules.GHIElectronics.RS232 ledsMaster1;   
        /// <summary>The RS232 module using socket 2 of the mainboard.</summary>
        private Gadgeteer.Modules.GHIElectronics.RS232 ledsMaster2; 
        /// <summary>This property provides access to the Mainboard API. This is normally not necessary for an end user program.</summary>
        protected new static GHIElectronics.Gadgeteer.FEZCerbuinoNet Mainboard 
        {
            get 
            {
                return ((GHIElectronics.Gadgeteer.FEZCerbuinoNet)(Gadgeteer.Program.Mainboard));
            }
            set 
            {
                Gadgeteer.Program.Mainboard = value;
            }
        }
        
        /// <summary>This method runs automatically when the device is powered, and calls ProgramStarted.</summary>
        public static void Main() {
            // Important to initialize the Mainboard first
            Program.Mainboard = new GHIElectronics.Gadgeteer.FEZCerbuinoNet();
            Program p = new Program();
            p.InitializeModules();
            p.ProgramStarted();
            // Starts Dispatcher
            p.Run();
        }
        
        private void InitializeModules() 
        {
            this.ledsMaster1 = new GTM.GHIElectronics.RS232(1);
            this.ledsMaster2 = new GTM.GHIElectronics.RS232(2);            
        }
    }
}





namespace MFC.Micro.Cerbuino
{
    public partial class Program
    {

        private const string MC_STATIC_IP = "10.0.0.75";
        private const string MC_SUBNET = "255.255.255.0";
        private const string MC_GATEWAY = "10.0.0.1";
        private const string MC_DNS = "10.0.0.1";
        private const int PORT = 5006; 

        // This method is run when the mainboard is powered up or reset.   
        void ProgramStarted()
        {
            Debug.Print("Program Started");

            Thread setup = new Thread(InitModules);
            setup.Start();
        }

        private void InitModules()
        {

            SetupEthernet();
            State.CreateAddressTable();
            LedCommMaster1.Connect(ledsMaster1);
            LedCommMaster2.Connect(ledsMaster2);
            Thread.Sleep(1500);
            SetupSocketServer();

        }

        private void SetupSocketServer()
        {
            try
            {
                SocketServer socketServer = new SocketServer();
                socketServer.Start(PORT);
            }
            catch (Exception ex)
            {
                Debug.Print("SetupSocketServer error: " + ex.Message);
                string[] msg = "0;0;2;4".Split(';');
                State.SetLeds(msg);
            }

       
```cs
 }

        private void SetupEthernet()
        {
            try
            {
                Network n

etwork = new Network();
network.StartEthernet(MC_STATIC_IP, MC_SUBNET, MC_GATEWAY, MC_DNS);
}
catch (Exception ex)
{
Debug.Print("SetupEthernet error: " + ex.Message);
string[] msg = “0;0;1;4”.Split(’;’);
State.SetLeds(msg);
}

    }
}

}


#4

@ JohnnyM - I ran your code on our latest SDK and I didn’t get any exceptions. I would try to update to the latest SDK first.


#5

Hi John,

I have tried to update the cerbuino to the latest SDK but i fails every time around 80% of the update process.
I have update my Hydra to the latest SDK without any problems.
Is there a special procedure for updating the Cerbuino?

Anyway i have tried something else to get socket 1 working.
I saw in the code of the cerbuino that socket 1 was named COM6 en socket 2 COM2.
Instead of using the RS232 module i have created a SerialPort on COM1.
This seams to work.

Do you have an explanation for this?


#6

@ JohnnyM - I was able to find your issue, it will be fixed for the next SDK. Socket 1 should be COM1, not COM6.