Netduino home hardware projects downloads community

Jump to content


The Netduino forums have been replaced by new forums at community.wildernesslabs.co. This site has been preserved for archival purposes only and the ability to make new accounts or posts has been turned off.
Photo

System.Exception in GoBusSerialTransport.dll


  • Please log in to reply
5 replies to this topic

#1 GregR

GregR

    Advanced Member

  • Members
  • PipPipPip
  • 32 posts
  • LocationKeller, Tx

Posted 18 November 2012 - 04:35 PM

I have upgraded my ShieldBase to the beta 4 firmware and my Go to the 4.2.1.0 firmware. I also unzipped the ShieldBase DLL stuff into the SecretLabs Assemblies directory. And I made sure I added that reference to my project. The simple code below throws a "An unhandled exceptopn of type 'System.Exception' occurred in GoBusSerialTransport.dll" when I try to create the ShieldBase object. Below is some very simple code that fails. I need to know what is causing this issue. I am sure I have just missed something with all of the manual ShieldBase file installations. The line below with ====>> is the line of the exception.

using System;
using System.IO.Ports;
using System.Threading;
using Microsoft.SPOT;
using Microsoft.SPOT.Hardware;
using SecretLabs.NETMF.Hardware;
using SecretLabs.NETMF.Hardware.NetduinoGo;


namespace GoTest
{
    public class Program
    {
====>>> public static NetduinoGo.ShieldBase sb = new NetduinoGo.ShieldBase(GoSockets.Socket4);
        public static SerialPort SP = new SerialPort(sb.SerialPorts.COM2, 9600, Parity.None, 8, StopBits.One);

        public static void Main()
        {
            Debug.Print("Program starting");
            Thread.Sleep(Timeout.Infinite);
          }
    }
}


#2 Lunddahl

Lunddahl

    Advanced Member

  • Members
  • PipPipPip
  • 152 posts
  • LocationEurope, Denmark

Posted 18 November 2012 - 05:30 PM

Hi Greg! Two things spring to my mind: 1. The evil caching of assemblies in Visual Studio, try making a new project, only pasting your code. 2. Random initializing of static objects, you can not be sure the shieldbase is initialized before the serial port, declare the objects outside of main, then initialize them inside main, then you are sure things happen in the right order. It might be something else, but that was just what sprung to my mind. - Ulrik

#3 GregR

GregR

    Advanced Member

  • Members
  • PipPipPip
  • 32 posts
  • LocationKeller, Tx

Posted 19 November 2012 - 08:50 PM

Thanks Ulrik...After playing around with this I do not think it has anything to do with the order or placement of the initializations. But..just to be safe I have done like you said. It looks like the exceptions were from doing a restart within VS and the Shieldbase was not getting reset when the Netduino go is rebooted...which seems like an issue to me that needs to be fixed.

If I am understanding things correctly then the following 2 code chunks should work identically...the first on the Netduino Plus and the second on the Netduino Go with a Shieldbase connected. (of course they are separate projects and include the appropriate reference for the Netduino model being used).

        public static SerialPort SP;

        public static void Main()
        {
            Debug.Print("Program starting");
            SP = new SerialPort(SerialPorts.COM2, 9600, Parity.None, 8, StopBits.One);
            SP.Open();
            Thread.Sleep(500);
            volume(0x16);
            Thread.Sleep(500);
            set_mode(0x00);
            Thread.Sleep(500);
            Debug.Print("Play SD Track 1");
            play_sd(0x0001);
            Thread.Sleep(500);
            SP.close();
            Debug.Print("Sleep.....");
            Thread.Sleep(Timeout.Infinite);
        }


        public static NetduinoGo.ShieldBase sb;
        public static SerialPort SP;



        public static void Main()
        {
            Debug.Print("Program starting");
            sb = new NetduinoGo.ShieldBase(GoSockets.Socket5);
            SP = new SerialPort(sb.SerialPorts.COM2, 9600, Parity.None, 8, StopBits.One);
            SP.Open();
            Thread.Sleep(500);
            volume(0x16);
            Thread.Sleep(500);
            set_mode(0x00);
            Thread.Sleep(500);
            Debug.Print("Play SD Track 1");
            play_sd(0x0001);
            Thread.Sleep(500);
            SP.close();
            Debug.Print("Sleep.....");
            Thread.Sleep(Timeout.Infinite);
        }


Of course all of the functions I call (volume, set_mode, etc) are included in the project but did not need to be included here as they work on one device but not the other. The only difference between the two chunks of code is that the second one creates a Shieldbase object which is then used in the SerialPort declaration.

When I attach the shield I am working with to my Netduino Plus and use the first code snippet it works perfectly fine and plays audio as expected.

When I attach it to my Netduino Go with a Shieldbase and use the second code snippet above it nevers plays any audio.

So something is not working right with the Shieldbase when trying to use the serial port. I know I've read that other people are using the serial port without issue...so I am trying to understand if I just have something misconfigured or if there is an problem with the Shieldbase stuff, etc. The code is not doing anything weird...it just sends commands as 3 or 4 bytes (one byte at a time) to the shield via the serial port.

Greg

#4 Chris Walker

Chris Walker

    Secret Labs Staff

  • Moderators
  • 7767 posts
  • LocationNew York, NY

Posted 19 November 2012 - 09:17 PM

Hi Greg, The static constructors (and the order they're called in) can be an issue in NETMF. Moving the constructors to your Main function where you control the order is the thing to do. Now that you've done that, are you getting the exception? Can you tell what data is being sent from the COM2 port on Shield Base? Do you happen to have a logic analyzer (or a cable to attach COM2 to your PC...so you can capture the received data there)? We're using Shield Base with COM in projects here and it's working great so far. But there is always potential for something that we need to tweak or improve. If we can find out what's going on in your scenario, we can help address it and get you back up and running. Chris

#5 GregR

GregR

    Advanced Member

  • Members
  • PipPipPip
  • 32 posts
  • LocationKeller, Tx

Posted 19 November 2012 - 09:50 PM

Hi Greg,

The static constructors (and the order they're called in) can be an issue in NETMF. Moving the constructors to your Main function where you control the order is the thing to do.

Now that you've done that, are you getting the exception?

Can you tell what data is being sent from the COM2 port on Shield Base? Do you happen to have a logic analyzer (or a cable to attach COM2 to your PC...so you can capture the received data there)?

We're using Shield Base with COM in projects here and it's working great so far. But there is always potential for something that we need to tweak or improve. If we can find out what's going on in your scenario, we can help address it and get you back up and running.

Chris



Chris...it looks like the exceptions are gone. So we will let that go for now. :)

I will begin doing some tinkering to see if I can capture the data that the Netduino Plus sends as well as the Go. It might take me a few days or so to do this so don't give up on me just becuase I don't respond back to this immediately!

Thanks for the help!

Greg

#6 GregR

GregR

    Advanced Member

  • Members
  • PipPipPip
  • 32 posts
  • LocationKeller, Tx

Posted 19 November 2012 - 11:33 PM

Chris...it looks like the exceptions are gone. So we will let that go for now. :)

I will begin doing some tinkering to see if I can capture the data that the Netduino Plus sends as well as the Go. It might take me a few days or so to do this so don't give up on me just becuase I don't respond back to this immediately!

Thanks for the help!

Greg



Chris,

Problem solved...as soon as I captured some of that data I saw that something was amiss. I found the issue in the way I was sending the data to the com port and corrected...now everything works on both boards as expected. It's really cool to see how transparent the GO/Shieldbase is really going to be! Thanks again for your help...and thanks again to Ulrik for his help too!


Greg




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users

home    hardware    projects    downloads    community    where to buy    contact Copyright © 2016 Wilderness Labs Inc.  |  Legal   |   CC BY-SA
This webpage is licensed under a Creative Commons Attribution-ShareAlike License.