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); } } }
System.Exception in GoBusSerialTransport.dll
#1
Posted 18 November 2012 - 04:35 PM
#2
Posted 18 November 2012 - 05:30 PM
#3
Posted 19 November 2012 - 08:50 PM
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
Posted 19 November 2012 - 09:17 PM
#5
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
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